:root {
  color-scheme: light;
  --paper: #fffaf5;
  --canvas: #f3ebdf;
  --text: #2b232e;
  --hint: #625665;
  --accent: #583b66;
  --tint: #efe3ee;
  --border: #dacbd8;
  --dark: #211a31;
  --gold: #f1c993;
  --art: url("assets/dream-hero.webp");
  --serif: "Yu Mincho", YuMincho, "Hiragino Mincho ProN", "Noto Serif CJK JP", serif;
  --sans: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
}
.lucky-page { --accent: #315448; --tint: #e3ece1; --border: #cbd7c9; --dark: #163029; --art: url("assets/lucky-hero.webp"); }
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--canvas); color: var(--text); font: 1rem/1.72 var(--sans); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .49; }
a { color: inherit; text-underline-offset: .2em; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex="-1"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, h3, p { margin-top: 0; }
h2, h3 { font-family: var(--serif); line-height: 1.4; }
h2 { margin-bottom: 16px; font-size: clamp(1.45rem, 2.4vw, 2.05rem); }
h3 { margin-bottom: 8px; font-size: 1.1rem; }
.tools-wrap { width: min(100% - 64px, 1150px); margin-inline: auto; }
.almanac-header { background: #fffbf6; border-bottom: 1px solid #eadfd5; }
.tool-top { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.tool-brand { display: flex; align-items: center; gap: 10px; flex: none; font: 700 1.05rem/1.2 var(--serif); text-decoration: none; }
.tool-moon { display: grid; place-items: center; width: 36px; aspect-ratio: 1; border-radius: 50%; color: #ffe3b7; background: #38243e; font: 1.55rem/1 Georgia, serif; }
.tool-tabs { display: flex; flex-wrap: wrap; gap: clamp(6px, 2vw, 28px); align-items: center; }
.tool-tabs a { padding: 9px 2px; font-size: .875rem; font-weight: 650; white-space: nowrap; text-decoration: none; }
.tool-tabs a:hover, .tool-tabs a[aria-current="page"] { color: var(--accent); text-decoration: underline; }
.tool-hero { color: #fff5e8; background: linear-gradient(90deg, var(--dark) 1%, color-mix(in srgb, var(--dark) 91%, transparent) 29%, transparent 84%), var(--dark) var(--art) center 57% / cover no-repeat; }
.tool-intro { min-height: clamp(350px, 38vw, 490px); padding: clamp(56px, 8vw, 106px) 0 92px; }
.tool-intro h1 { font: 650 clamp(2.9rem, 7vw, 5.4rem)/1.11 var(--serif); letter-spacing: .025em; margin-bottom: 24px; text-wrap: balance; }
.tool-intro h1 span:not(.dream-heading) { display: block; color: var(--gold); font-size: .37em; line-height: 1.35; margin-bottom: 10px; }
.dream-heading { display: block; }
.tool-intro p { max-width: 32em; color: #fff3ea; line-height: 1.9; margin-bottom: 0; text-shadow: 0 1px 5px #101121; }
.work-area { position: relative; margin-top: -56px; margin-bottom: 34px; }
.tool-panel { background: var(--paper); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 13px 38px #241d2a16; }
.panel-pad { padding: clamp(21px, 3.8vw, 43px); }
.dream-page .work-area { max-width: 1000px; }
.dream-example { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: clamp(16px, 3vw, 30px) clamp(18px, 4vw, 40px); margin-bottom: 14px; background: #f8edf5; border-color: #dbc6d6; }
.dream-example p { margin: 0 0 4px; color: var(--accent); font-size: .875rem; font-weight: 700; }
.dream-example h2 { margin: 0; font-size: clamp(1.2rem, 2.8vw, 1.9rem); }
.dream-quick-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 15px; }
.dream-quick-actions a { display: inline-flex; align-items: center; }
#dream-form { scroll-margin-top: 14px; }
fieldset { border: 0; padding: 0; margin: 0 0 20px; min-width: 0; }
legend { color: var(--text); font-weight: 700; padding: 0; margin-bottom: 9px; }
.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.mood-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; width: 1em; height: 1em; opacity: 0; inset: 0; }
.choice span { display: grid; place-items: center; min-height: 45px; padding: 5px; text-align: center; text-wrap: balance; color: var(--text); background: #fffdf9; border: 1px solid var(--border); border-radius: 8px; font-size: .9375rem; line-height: 1.35; }
.choice input:checked + span { background: var(--accent); border-color: var(--accent); color: white; font-weight: 650; }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }
.solid, .outline, .icon-button { color: var(--accent); background: var(--paper); border: 1px solid var(--accent); padding: 9px 15px; border-radius: 8px; min-height: 44px; font-size: .9375rem; font-weight: 700; line-height: 1.35; }
.outline:hover, .outline[aria-pressed="true"] { background: var(--tint); }
.solid { color: white; background: var(--accent); }
.solid:hover { background: var(--dark); }
.form-submit { width: 100%; min-height: 50px; margin-top: 6px; }
.tool-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.link-button { color: var(--accent); border: 0; background: transparent; min-height: 44px; padding: 6px 2px; font-size: .875rem; text-decoration: underline; text-underline-offset: .22em; }
.dream-prompt-only .tool-intro { min-height: clamp(300px, 34vw, 420px); }
.dream-prompt-only .tool-intro h1 { font-size: clamp(2.3rem, 6vw, 4.5rem); max-width: 15em; }
.dream-form-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 15px; }
.dream-form-head h2 { margin: 0; }
.dream-scene-label { margin: 0; background: var(--tint); color: var(--accent); font-size: .875rem; font-weight: 700; padding: 3px 9px; border-radius: 6px; }
.dream-invite-card { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 8px 26px; padding: clamp(14px, 2.6vw, 24px); border: 1px solid var(--border); border-radius: 10px; background: #f5ebf3; margin-bottom: 13px; }
.dream-invite-card h3 { margin-bottom: 5px; font-size: 1.25rem; }
.dream-invite-card p { margin: 0; color: var(--hint); font-size: .875rem; }
.dream-result { overflow: hidden; scroll-margin-top: 16px; }
.dream-cover { color: #fff5e7; background: linear-gradient(90deg,#22192ee6 10%, #251b39b3 58%, #2a203540), var(--dark) var(--art) center 51%/cover; }
.dream-cover p { color: #f6d8ac; margin: 0 0 13px; font-size: .875rem; font-weight: 650; }
.dream-cover p.received-label { margin: 0 0 4px; color: #fff3e7; }
.dream-cover h2 { margin: 0; font-size: clamp(1.9rem, 5vw, 3.4rem); text-wrap: balance; }
.dream-cover h2:focus-visible { outline-color: var(--gold); }
.dream-body > p { max-width: 49em; }
.reflection { border-left: 3px solid var(--accent); background: var(--tint); padding: 14px 19px; margin: 23px 0; border-radius: 0 8px 8px 0; }
.reflection p { margin-bottom: 0; }
.under-tool { padding: 30px 0 0; }
.under-tool h2 { margin-bottom: 9px; font-size: 1.2rem; }
.under-tool p, .label-note { color: var(--hint); }
.under-tool p { max-width: 62em; margin-bottom: 8px; }
.tool-footer { display: flex; flex-wrap: wrap; gap: 10px 24px; padding-block: 19px 28px; border-top: 1px solid var(--border); font-size: .875rem; }
.tool-footer a:first-child { font-family: var(--serif); font-weight: 700; }

.lucky-work { display: grid; grid-template-columns: minmax(0, .79fr) minmax(0, 1.21fr); gap: 19px; align-items: start; }
.lucky-filter, .lucky-results { padding: clamp(19px, 2.7vw, 31px); }
.lucky-filter h2, .lucky-result-head h2 { margin-bottom: 4px; }
.label-note { font-size: .875rem; margin-bottom: 12px; }
.lucky-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.lucky-presets button, .view-choice button, .month-heading button { font-size: .875rem; padding-inline: 9px; }
.date-fields { display: grid; gap: 7px; grid-template-columns: repeat(2, minmax(0,1fr)); }
.date-fields label, .field-select { display: grid; gap: 4px; font-size: .875rem; font-weight: 700; color: var(--hint); }
.date-fields input, .field-select select { display: block; width: 100%; min-width: 0; max-width: 100%; min-height: 44px; color: var(--text); background: #fffdf9; padding: 6px; border: 1px solid var(--border); border-radius: 7px; }
.lucky-tag-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
.inline-check, .share-check { display: flex; align-items: center; gap: 7px; margin-top: 8px; min-height: 44px; font-size: .875rem; }
input[type="checkbox"] { accent-color: var(--accent); }
.field-select { margin-bottom: 11px; }
.lucky-result-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; margin-bottom: 6px; }
.view-choice { display: flex; gap: 3px; flex: none; }
.date-list, .incoming-dates { list-style: none; padding: 0; margin: 0 0 10px; }
.date-row { display: grid; grid-template-columns: minmax(71px, .55fr) minmax(0, 1fr) 60px; align-items: center; gap: 8px; padding: 9px 0; border-top: 1px solid var(--border); }
.date-main { font: 700 clamp(1.05rem, 2.3vw, 1.4rem)/1.2 var(--serif); }
.date-main small { display: block; font: 600 .75rem/1.45 var(--sans); color: var(--hint); }
.date-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.date-tags span { display: inline-block; padding: 1px 7px; background: var(--tint); color: var(--accent); border-radius: 4px; font-size: .8125rem; font-weight: 700; }
.date-tags .rare { background: #f1dfbc; color: #654717; }
.date-row .outline { padding-inline: 3px; white-space: nowrap; }
.date-row .outline[aria-pressed="true"], .month-day[aria-pressed="true"] { color: white; background: var(--accent); }
.month-heading { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 10px; }
.month-grid { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: 4px; text-align: center; }
.month-grid > span { line-height: 34px; color: var(--hint); }
.month-day { color: var(--accent); font-weight: 700; border: 1px solid var(--border); border-radius: 6px; background: var(--tint); min-height: 41px; padding: 0; }
.month-day:disabled { background: transparent; border-color: transparent; }
.month-day--rare:not([aria-pressed="true"]) { background: #f1dfbc; color: #654717; }
.empty-state, .picked, #lucky-incoming { background: var(--tint); padding: 14px; margin-top: 12px; border-radius: 8px; }
#lucky-incoming { margin: 0 0 17px; padding: clamp(20px,3vw,36px); }
.incoming-dates { max-width: 600px; }
.incoming-dates .date-row { grid-template-columns: minmax(77px,.48fr) minmax(0,1fr) auto; }
.can-make { display: flex; align-items: center; gap: 4px; min-height: 44px; padding-inline: 2px; font-size: .875rem; white-space: nowrap; cursor: pointer; }
.picked { position: sticky; z-index: 1; top: 8px; border: 1px solid var(--border); box-shadow: 0 4px 12px #211e2c20; margin-bottom: 10px; padding: 8px; }
.picked-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.picked-dates { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.picked-dates button { color: var(--accent); font-size: .875rem; min-height: 42px; background: var(--paper); border: 1px solid var(--border); border-radius: 6px; }
.tool-status { margin: 7px 0 0; font-size: .875rem; color: var(--hint); }
.tool-status:empty { display: none; }

dialog { width: min(100% - 22px, 550px); max-height: 93dvh; border: 1px solid var(--border); border-radius: 15px; color: var(--text); background: var(--paper); padding: clamp(13px, 3vw, 24px); }
dialog::backdrop { background: #211a2bd9; }
body:has(dialog[open]) { overflow: hidden; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.dialog-head h2 { margin: 0; }
.icon-button { width: 44px; padding: 0; font-size: 1.35rem; }
.share-hint { color: var(--hint); font-size: .875rem; margin-bottom: 8px; }
.share-preview { display: grid; place-items: center; border-radius: 8px; background: var(--tint); overflow: hidden; padding: 9px; }
.share-preview img { display: block; width: auto; height: min(39dvh, 390px); max-width: 100%; object-fit: contain; }
.share-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.share-fallback { width: 100%; height: 90px; resize: vertical; margin-top: 8px; }

@media (max-width: 850px) {
  .lucky-work { grid-template-columns: minmax(0, 1fr); gap: 13px; }
}
@media (max-width: 570px) {
  .tools-wrap { width: calc(100% - 28px); }
  .tool-top { flex-wrap: wrap; gap: 3px; padding-block: 10px 4px; }
  .tool-brand { font-size: .96rem; }
  .tool-moon { width: 28px; font-size: 1.3rem; }
  .tool-tabs { gap: 15px; }
  .tool-intro { min-height: 277px; padding: 49px 0 72px; }
  .tool-intro h1 { font-size: clamp(2.22rem, 10vw, 3rem); }
  .tool-intro p br { display: none; }
  .dream-page:not(.dream-prompt-only) .tool-intro { min-height: 258px; padding-top: 37px; }
  .dream-page:not(.dream-prompt-only) .tool-intro h1 { margin-bottom: 14px; font-size: clamp(1.85rem, 8vw, 2.65rem); }
  .dream-example { flex-direction: column; align-items: stretch; gap: 10px; }
  .dream-quick-actions { gap: 3px 12px; }
  .dream-quick-actions .solid { flex: 1 0 auto; }
  .tool-hero { background-image: linear-gradient(90deg,#211927e8 2%,#21192fb3 54%,#21192775), var(--art); background-position: 70% 55%; }
  .lucky-page .tool-hero { background-image: linear-gradient(90deg,#17302aef 2%,#17302abe 58%,#17302a78), var(--art); }
  .dream-prompt-only .tool-intro { min-height: 0; padding: 29px 0 72px; }
  .dream-prompt-only .tool-intro h1 { font-size: clamp(1.8rem, 8vw, 2.3rem); margin-bottom: 13px; }
  .dream-invite-card .solid { width: 100%; }
  .work-area { margin-top: -42px; }
  .panel-pad { padding: 17px; }
  .choice span { font-size: .875rem; }
  .mood-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .date-row { column-gap: 5px; grid-template-columns: minmax(76px,.55fr) minmax(0,1fr) 57px; }
  .date-tags span { padding-inline: 4px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
