:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #2f2420;
  background: #f6efe5;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --red: #b5282f;
  --red-dark: #7d1720;
  --paper: #fffaf2;
  --ink: #2f2420;
  --muted: #786a62;
  --gold: #d4a246;
  --line: rgba(82, 51, 39, .14);
  --shadow: 0 24px 70px rgba(77, 40, 27, .13);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #f6efe5; }
body { min-height: 100%; margin: 0; background:
  radial-gradient(circle at 15% 8%, rgba(213, 164, 73, .12), transparent 28rem),
  radial-gradient(circle at 88% 82%, rgba(181, 40, 47, .08), transparent 28rem),
  #f6efe5;
}
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }
a { color: inherit; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  min-height: 72px; padding: .8rem clamp(1rem, 4vw, 3rem);
  background: rgba(255, 250, 242, .88); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.app-brand { display: inline-flex; align-items: center; gap: .8rem; text-decoration: none; }
.app-brand strong { display: block; letter-spacing: .13em; font-size: 1rem; }
.app-brand small { display: block; color: var(--muted); font-size: .72rem; }
.brand-mark { width: 42px; height: 42px; border-radius: 50% 50% 45% 45%; background: var(--red); display: grid; grid-template-columns: 1fr 1fr; gap: 5px; place-content: center; padding: 10px; box-shadow: inset 0 -5px 0 rgba(80, 10, 15, .18); }
.brand-mark__eye { width: 8px; height: 8px; border-radius: 50%; background: #fff7e8; border: 2px solid #251716; }
.app-header__actions { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; justify-content: flex-end; }
.header-button { border: 1px solid var(--line); background: rgba(255,255,255,.68); color: var(--ink); border-radius: 999px; padding: .62rem .9rem; font-size: .83rem; font-weight: 750; }
.header-button:hover { border-color: rgba(181, 40, 47, .35); transform: translateY(-1px); }
.header-button--quiet { background: transparent; color: var(--muted); }

.app-footer { margin-top: auto; display: flex; justify-content: center; align-items: center; gap: .8rem; flex-wrap: wrap; padding: 1.2rem; color: var(--muted); font-size: .76rem; border-top: 1px solid var(--line); }
.app-footer a { color: var(--red); font-weight: 800; text-decoration: none; }

.auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(340px, .8fr); }
.auth-hero { position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 3rem; text-align: center; background:
  linear-gradient(145deg, rgba(255,255,255,.62), rgba(250,232,214,.88)),
  repeating-linear-gradient(0deg, transparent, transparent 18px, rgba(114,74,50,.025) 19px);
}
.auth-hero::before, .auth-hero::after { content: ""; position: absolute; width: 270px; height: 270px; border: 1px solid rgba(181,40,47,.09); border-radius: 50%; }
.auth-hero::before { left: -120px; top: -120px; box-shadow: 0 0 0 28px rgba(181,40,47,.035), 0 0 0 58px rgba(181,40,47,.025); }
.auth-hero::after { right: -140px; bottom: -130px; box-shadow: 0 0 0 28px rgba(212,162,70,.05), 0 0 0 58px rgba(212,162,70,.03); }
.auth-hero h1 { margin: .15rem 0 0; font-size: clamp(3.2rem, 8vw, 7.2rem); line-height: .9; letter-spacing: .16em; color: var(--red-dark); text-indent: .16em; }
.auth-hero__lead { max-width: 39rem; margin: 1.2rem auto .3rem; font-family: Georgia, serif; font-size: clamp(1.1rem, 2vw, 1.5rem); color: #5c4940; }
.auth-hero__quote { max-width: 34rem; margin: .2rem auto 0; color: var(--muted); font-size: .92rem; }
.auth-panel { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: clamp(2rem, 7vw, 5rem); background: rgba(255,250,242,.9); border-left: 1px solid var(--line); }
.auth-tabs { display: inline-flex; width: fit-content; padding: .25rem; border-radius: 999px; background: #efe3d5; margin-bottom: 2.2rem; }
.auth-tabs button { border: 0; background: transparent; border-radius: 999px; padding: .65rem 1rem; color: var(--muted); font-weight: 800; }
.auth-tabs button.active { background: var(--paper); color: var(--red); box-shadow: 0 4px 12px rgba(67,42,30,.1); }
.auth-panel__copy h2 { font-family: Georgia, serif; font-size: clamp(2rem, 4vw, 3rem); margin: 0; }
.auth-panel__copy p { color: var(--muted); margin: .55rem 0 2rem; }

.eyebrow { margin: 0; color: var(--red); letter-spacing: .2em; font-size: .72rem; font-weight: 900; text-transform: uppercase; }
.soft-copy { max-width: 28rem; color: var(--muted); text-align: center; line-height: 1.65; }
.card { background: rgba(255,250,242,.92); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); }
.form-stack { display: grid; gap: 1rem; }
.field { display: grid; gap: .42rem; }
.field > span { font-size: .8rem; font-weight: 850; color: #4e3d35; }
.field input, .field textarea { width: 100%; border: 1px solid rgba(88,57,42,.18); background: rgba(255,255,255,.78); color: var(--ink); border-radius: 14px; padding: .9rem 1rem; outline: none; transition: .18s ease; }
.field textarea { resize: vertical; min-height: 112px; }
.field input:focus, .field textarea:focus { border-color: rgba(181,40,47,.55); box-shadow: 0 0 0 4px rgba(181,40,47,.08); background: #fff; }
.button { min-height: 48px; border: 0; border-radius: 14px; padding: .82rem 1.15rem; font-weight: 900; letter-spacing: .01em; transition: transform .18s ease, box-shadow .18s ease, background .18s ease; }
.button:not(:disabled):hover { transform: translateY(-2px); }
.button--primary { color: white; background: linear-gradient(145deg, #cc3439, #971a24); box-shadow: 0 11px 26px rgba(151,26,36,.23); }
.button--secondary { color: var(--ink); background: #eadfce; box-shadow: none; }
.text-button { border: 0; background: transparent; color: var(--red); font-weight: 800; padding: .55rem; }
.text-button--muted { color: var(--muted); }

.daruma-wrap { width: min(310px, 74vw); margin: .8rem auto; animation: darumaFloat 5s ease-in-out infinite; transform-origin: 50% 100%; }
.daruma-wrap--compact { width: 110px; margin: 0; animation: none; }
.daruma-wrap--celebrating { width: min(270px, 62vw); animation: celebrateBounce .9s ease-in-out infinite alternate; }
.daruma-svg { width: 100%; height: auto; overflow: visible; }
.painted-eye { transform-box: fill-box; transform-origin: center; animation: eyePaint .48s cubic-bezier(.2,1.7,.45,1); }
@keyframes darumaFloat { 0%,100% { transform: rotate(-1.2deg) translateY(0); } 50% { transform: rotate(1.2deg) translateY(-5px); } }
@keyframes eyePaint { from { transform: scale(.05); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes celebrateBounce { from { transform: rotate(-3deg) translateY(0) scale(1); } to { transform: rotate(3deg) translateY(-10px) scale(1.03); } }

.loading-screen { flex: 1; min-height: 65vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; color: var(--muted); }
.centered-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.recovery-card { width: min(480px, 100%); padding: 2rem; text-align: center; }
.recovery-card .brand-mark { margin: 0 auto 1rem; }
.recovery-card h1 { font-family: Georgia, serif; }
.fatal-error { min-height: 100vh; display: grid; place-content: center; text-align: center; padding: 2rem; }

.new-dream-layout { flex: 1; display: grid; grid-template-columns: minmax(280px, .75fr) minmax(420px, 1.25fr); gap: clamp(1.5rem, 4vw, 4rem); align-items: center; width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: clamp(2rem, 5vw, 5rem) 0; }
.new-dream-visual { display: flex; flex-direction: column; align-items: center; }
.dream-form-card { padding: clamp(1.4rem, 4vw, 3rem); }
.dream-form-card h1 { margin: 0 0 .6rem; font-family: Georgia, serif; font-size: clamp(2rem, 4vw, 3.3rem); }
.dream-form-card > p { color: var(--muted); margin: 0 0 1.8rem; }

.dream-page { flex: 1; display: grid; place-items: center; padding: clamp(1.5rem, 5vw, 4rem); }
.dream-stage { width: min(1050px, 100%); display: grid; grid-template-columns: minmax(280px, .8fr) minmax(430px, 1.2fr); gap: clamp(1rem, 5vw, 4rem); align-items: center; }
.ritual-card { position: relative; padding: clamp(1.5rem, 4vw, 3.5rem); background: rgba(255,250,242,.94); border: 1px solid var(--line); border-radius: 30px; box-shadow: var(--shadow); }
.ritual-card::before { content: ""; position: absolute; inset: 14px; border: 1px solid rgba(212,162,70,.2); border-radius: 22px; pointer-events: none; }
.ritual-card > * { position: relative; }
.ritual-card__explanation { color: var(--muted); line-height: 1.65; margin: 1.5rem 0; }
.ritual-card .button { width: 100%; }
.ritual-card .text-button { width: 100%; margin-top: .5rem; }

.dream-summary__owner { margin: .8rem 0 .45rem; color: var(--muted); }
.dream-summary h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(1.9rem, 4vw, 3.4rem); line-height: 1.08; overflow-wrap: anywhere; }
.dream-summary blockquote { margin: 1.2rem 0; padding-left: 1rem; border-left: 3px solid var(--gold); color: #68544a; font-family: Georgia, serif; font-style: italic; }
.dream-meta { display: flex; gap: 1rem; flex-wrap: wrap; margin: 1.5rem 0 0; }
.dream-meta > div { min-width: 150px; border-top: 1px solid var(--line); padding-top: .75rem; }
.dream-meta dt { color: var(--muted); font-size: .72rem; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
.dream-meta dd { margin: .2rem 0 0; font-weight: 800; }

.active-layout { flex: 1; display: grid; grid-template-columns: minmax(300px, .72fr) minmax(460px, 1.28fr); gap: clamp(1.5rem, 5vw, 5rem); align-items: center; width: min(1200px, calc(100% - 2rem)); margin: 0 auto; padding: clamp(2rem, 5vw, 5rem) 0; }
.active-visual { display: flex; flex-direction: column; align-items: center; }
.active-card { padding: clamp(1.5rem, 4vw, 3.2rem); }
.active-card > .button { width: 100%; margin-top: 1.3rem; }
.active-card > .text-button { display: block; width: 100%; margin-top: .5rem; }
.progress-ring { --progress: 0deg; width: 120px; height: 120px; margin-top: -18px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--gold) var(--progress), rgba(94,65,51,.11) 0); box-shadow: 0 14px 34px rgba(82,51,39,.13); }
.progress-ring__inner { width: 94px; height: 94px; border-radius: 50%; display: grid; place-content: center; text-align: center; background: var(--paper); }
.progress-ring strong { font-size: 1.55rem; color: var(--red); }
.progress-ring span { font-size: .7rem; color: var(--muted); }
.linear-progress { width: 100%; height: 10px; border-radius: 999px; overflow: hidden; background: #e7dccd; margin: 1.5rem 0; }
.linear-progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), var(--red)); transition: width .55s ease; }
.days-card { display: flex; flex-direction: column; gap: .15rem; padding: 1rem 1.15rem; border-radius: 16px; background: #f0e5d5; }
.days-card strong { font-size: 1.15rem; color: var(--red-dark); }
.days-card span { color: var(--muted); font-size: .83rem; }
.eye-status { display: grid; grid-template-columns: auto 1fr auto; align-items: center; margin: 1.5rem 0; }
.eye-status__item { display: flex; align-items: center; gap: .65rem; }
.eye-status__item > span { width: 35px; height: 35px; border-radius: 50%; display: grid; place-items: center; border: 2px solid rgba(67,42,30,.22); background: white; font-size: 1.1rem; }
.eye-status__item--done > span { color: var(--red); border-color: rgba(181,40,47,.35); background: #fff5ed; }
.eye-status__item strong, .eye-status__item small { display: block; white-space: nowrap; }
.eye-status__item small { color: var(--muted); font-size: .68rem; }
.eye-status__line { height: 1px; margin: 0 .8rem; background: var(--line); }

.notice-floating { position: fixed; z-index: 90; top: 84px; left: 50%; transform: translateX(-50%); width: min(560px, calc(100% - 2rem)); }
.notice { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1rem; border-radius: 14px; box-shadow: 0 12px 30px rgba(44,31,25,.16); font-size: .86rem; font-weight: 700; }
.notice--info { color: #473b34; background: #f4e6cf; border: 1px solid #e2cda9; }
.notice--error { color: #681a22; background: #fde5e6; border: 1px solid #f2b9bd; }
.notice--success { color: #2e563a; background: #e4f3e7; border: 1px solid #b9dbbf; }
.notice__close { border: 0; background: transparent; color: inherit; font-size: 1.2rem; }
.app-shell > .notice { border-radius: 0; box-shadow: none; justify-content: center; }

.modal-backdrop, .drawer-backdrop { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 1rem; background: rgba(31,19,16,.58); backdrop-filter: blur(8px); animation: fadeIn .18s ease; }
.modal { width: min(470px, 100%); padding: 1.7rem; border-radius: 26px; background: var(--paper); border: 1px solid rgba(255,255,255,.5); box-shadow: 0 34px 90px rgba(29,14,12,.35); text-align: center; animation: modalIn .28s cubic-bezier(.2,1.2,.4,1); }
.modal--ceremonial { background:
  radial-gradient(circle at top, rgba(212,162,70,.15), transparent 48%),
  var(--paper); }
.modal__symbol { width: 46px; height: 46px; display: grid; place-items: center; margin: 0 auto .6rem; border-radius: 50%; border: 1px solid rgba(181,40,47,.25); color: var(--red); font-size: 2rem; }
.modal h2 { margin: .3rem 0 .8rem; font-family: Georgia, serif; font-size: 1.8rem; }
.modal__content { color: #5f4d44; line-height: 1.65; }
.modal__actions { display: flex; justify-content: center; gap: .65rem; margin-top: 1.3rem; }
.modal__actions .button { flex: 1; }
.modal-quote { font-family: Georgia, serif; font-size: 1.15rem; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.96); } }

.drawer-backdrop { place-items: stretch end; padding: 0; }
.history-drawer { width: min(520px, 100%); height: 100%; overflow: auto; padding: 1.4rem; background: #f9f1e7; box-shadow: -20px 0 60px rgba(30,17,14,.24); animation: drawerIn .3s ease; }
@keyframes drawerIn { from { transform: translateX(100%); } }
.history-drawer__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.history-drawer h2 { margin: .2rem 0 0; font-family: Georgia, serif; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); background: var(--paper); border-radius: 50%; font-size: 1.5rem; }
.empty-history { min-height: 70vh; display: grid; place-content: center; justify-items: center; text-align: center; color: var(--muted); }
.history-list { display: grid; gap: .85rem; }
.history-item { display: grid; grid-template-columns: 86px 1fr; gap: .85rem; align-items: center; padding: 1rem; border-radius: 20px; background: rgba(255,250,242,.92); border: 1px solid var(--line); }
.history-item .daruma-wrap--compact { width: 78px; }
.history-item__body h3 { margin: .45rem 0; font-family: Georgia, serif; font-size: 1.05rem; line-height: 1.25; }
.history-item__body p { margin: 0; color: var(--muted); font-size: .76rem; }
.status-pill { display: inline-flex; padding: .25rem .55rem; border-radius: 999px; background: #e9ded0; color: #705e54; font-size: .66rem; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.history-item--achieved .status-pill { color: #7c4f07; background: #f6dfae; }

.celebration { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 1rem; overflow: auto; background:
  radial-gradient(circle at 50% 30%, rgba(255,237,174,.95), transparent 30%),
  linear-gradient(145deg, #8f1720, #4e1117); }
.celebration::before { content: ""; position: fixed; inset: 0; opacity: .16; background-image: radial-gradient(#ffe1a1 1px, transparent 1px); background-size: 24px 24px; }
.celebration__card { position: relative; width: min(600px, 100%); padding: 1.5rem clamp(1.2rem, 4vw, 3rem) 2rem; border-radius: 34px; text-align: center; background: rgba(255,250,242,.97); box-shadow: 0 40px 100px rgba(20,5,7,.45); }
.celebration__jp { margin: 0; color: var(--gold); font-family: Georgia, serif; font-size: 1.2rem; letter-spacing: .25em; }
.celebration h1 { margin: .35rem 0; font-family: Georgia, serif; font-size: clamp(2rem, 6vw, 4rem); color: var(--red-dark); }
.celebration__dream { margin: .8rem auto; max-width: 33rem; font-family: Georgia, serif; font-size: 1.25rem; font-weight: 700; }
.celebration__copy { color: var(--muted); line-height: 1.6; }
.celebration__card .button { margin-top: .8rem; }
.celebration__petals { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.celebration-petal { position: absolute; top: -30px; left: var(--x); width: 14px; height: 8px; border-radius: 100% 0 100% 0; background: #ffcc75; transform: rotate(var(--rotation)); animation: petalFall var(--duration) linear var(--delay) infinite; }
.celebration-petal:nth-child(3n) { background: #f17a75; }
.celebration-petal:nth-child(4n) { background: #fff2cf; }
@keyframes petalFall { to { transform: translate(-60px, 110vh) rotate(720deg); } }

@media (max-width: 920px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-hero { min-height: auto; padding: 2.4rem 1.2rem 1.2rem; }
  .auth-hero .daruma-wrap { width: min(230px, 58vw); }
  .auth-panel { min-height: auto; border-left: 0; border-top: 1px solid var(--line); padding: 2rem 1.2rem 3rem; }
  .auth-panel__copy h2 { font-size: 2rem; }
  .new-dream-layout, .dream-stage, .active-layout { grid-template-columns: 1fr; }
  .new-dream-layout, .active-layout { width: min(680px, calc(100% - 1.4rem)); padding: 2rem 0; }
  .new-dream-visual .daruma-wrap, .active-visual .daruma-wrap { width: min(240px, 60vw); }
  .dream-stage { width: min(680px, 100%); }
  .dream-page { padding: 1.2rem; }
  .active-visual { order: 0; }
  .active-card { order: 1; }
}

@media (max-width: 620px) {
  .app-header { align-items: flex-start; min-height: 68px; padding: .72rem; }
  .app-brand small { display: none; }
  .app-header__actions { gap: .25rem; }
  .header-button { padding: .52rem .68rem; font-size: .72rem; }
  .auth-hero h1 { font-size: 3.2rem; }
  .auth-hero__lead { font-size: 1rem; }
  .dream-form-card, .active-card, .ritual-card { border-radius: 22px; padding: 1.2rem; }
  .dream-summary h1 { font-size: 2rem; }
  .dream-meta { display: grid; }
  .eye-status { grid-template-columns: 1fr; gap: .7rem; }
  .eye-status__line { width: 1px; height: 24px; margin-left: 17px; }
  .modal__actions { flex-direction: column-reverse; }
  .app-footer { gap: .4rem .7rem; }
  .celebration__card { border-radius: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .001ms !important; }
}
