:root {
  --ground: #ECE6DA; --surface: #F6F2EA; --ink: #1E1C19; --muted: #5C554A; --rule: #D3C9B6; --rule-strong: #C2B59C;
  --accent: #7A5A2E; --gilt: #A9843F; --lapis: #2C4A7E; --warn: #A4492C; --chip: #EFE7D6; --field: #FBF8F2;
  --glass: rgba(246,242,234,0.82); --glass-line: rgba(169,132,63,0.35); --nav-glass: rgba(246,242,234,0.8);
  --fade: 236,230,218; --hot: #E9C46A;
  --sans: 'Lato', 'Helvetica Neue', Arial, sans-serif; --cinzel: 'Cinzel', serif; --verse: 'EB Garamond', Georgia, serif;
}
:root[data-mode="night"] {
  --ground: #16171A; --surface: #202125; --ink: #EDE6D6; --muted: #A69D8C; --rule: #34353A; --rule-strong: #46474D;
  --accent: #D8B56B; --gilt: #C3A052; --lapis: #93ACD8; --warn: #E08A6B; --chip: #26272C; --field: #1B1C1F;
  --glass: rgba(24,25,28,0.7); --glass-line: rgba(216,181,107,0.3); --nav-glass: rgba(28,29,33,0.78);
  --fade: 22,23,26; --hot: #FFE3A3;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
#local-banner { position: fixed; z-index: 50; top: 0; left: 0; right: 0; padding: 4px 12px; background: #C76A1A; color: #fff; font-size: 12px; text-align: center; }

/* Navigation: Cinzel capitals */
.topnav { display: none; }
.bottomnav { position: fixed; z-index: 20; left: 16px; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); height: 70px; border-radius: 35px;
  background: var(--nav-glass); backdrop-filter: blur(20px) saturate(1.3); -webkit-backdrop-filter: blur(20px) saturate(1.3); border: 1px solid var(--glass-line);
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center; max-width: 520px; margin: 0 auto; }
.bottomnav a { height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); text-decoration: none;
  font-family: var(--cinzel); font-size: 11px; letter-spacing: 0.1em; }
.bottomnav a.on { color: var(--accent); font-weight: 600; }
.bottomnav svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.bottomnav .orb { position: relative; width: 62px; height: 62px; margin: -26px auto 0; justify-self: center; }
.orb .ring { position: absolute; inset: -4px; border-radius: 35px; border: 1.5px solid var(--gilt); }
.orb .core { position: absolute; inset: 0; border-radius: 31px; background: var(--accent); border: 3px solid var(--ground); display: flex; align-items: center; justify-content: center; }
.orb .core svg { width: 24px; height: 24px; stroke: var(--ground); stroke-width: 1.4; }

/* Hero */
.hero { position: relative; height: 520px; overflow: hidden; color: #F7F1E3; }
.hero.short { height: 460px; }
.hero > img, .hero > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero .scrim { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10,10,12,0.5) 0%, rgba(10,10,12,0) 24%, rgba(var(--fade),0) 50%, rgba(var(--fade),0.94) 86%, rgb(var(--fade)) 100%); }
.hero .rays { position: absolute; left: -40%; top: -30%; width: 180%; height: 160%; transform-origin: 50% 30%; mix-blend-mode: screen;
  background: conic-gradient(from 160deg at 50% 30%, rgba(255,232,180,0) 0deg, rgba(255,232,180,0.3) 8deg, rgba(255,232,180,0) 18deg, rgba(255,232,180,0.22) 28deg, rgba(255,232,180,0) 40deg, rgba(255,232,180,0.18) 50deg, rgba(255,232,180,0) 64deg, rgba(255,232,180,0) 360deg); }
.hero .glow { position: absolute; inset: 0; mix-blend-mode: screen; background: radial-gradient(ellipse at 50% 42%, rgba(255,190,110,0.26) 0%, rgba(255,190,110,0.08) 40%, rgba(255,190,110,0) 70%); }
.mote { position: absolute; width: 3px; height: 3px; border-radius: 2px; background: #F6DDA6; opacity: 0; }
.hero-bar { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; justify-content: space-between; padding: calc(18px + env(safe-area-inset-top)) 20px 0 24px; }
.wordmark { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.wordmark svg { width: 26px; height: 26px; fill: none; stroke: #EBCB82; stroke-width: 1.3; stroke-linejoin: round; }
.wordmark span { font-family: var(--cinzel); font-weight: 500; font-size: 16px; letter-spacing: 0.26em; }
.chip-btn { height: 44px; min-width: 44px; padding: 0 14px; border-radius: 22px; border: 1px solid rgba(255,255,255,0.32); background: rgba(255,255,255,0.15);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); color: #F7F1E3; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-decoration: none;
  font-family: var(--cinzel); font-size: 12px; font-weight: 600; letter-spacing: 0.12em; }
.chip-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.hero-title { position: absolute; left: 24px; right: 24px; bottom: 18px; color: var(--ink); }
.hero-title h1 { margin: 0; font-weight: 300; font-size: 48px; line-height: 1; }
.hero-title .lead { font-size: 18px; margin-top: 10px; }

/* Type */
.latin { font-family: var(--cinzel); font-size: 10px; letter-spacing: 0.2em; color: var(--muted); text-transform: uppercase; }
.hero-title .latin { font-size: 12px; letter-spacing: 0.26em; color: var(--accent); margin-top: 6px; }
.verse { font-family: var(--verse); font-style: italic; font-size: 18px; line-height: 1.4; color: var(--lapis); }
.ref { font-family: var(--cinzel); font-size: 10px; letter-spacing: 0.14em; color: var(--muted); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Layout */
.wrap { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: 20px; padding: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.glass { background: var(--glass); backdrop-filter: blur(22px) saturate(1.3); -webkit-backdrop-filter: blur(22px) saturate(1.3); border: 1px solid var(--glass-line); border-radius: 20px; padding: 20px; }
.lift { position: relative; z-index: 2; margin-top: -170px; }
.sec-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.sec-h .t { font-size: 18px; font-weight: 700; color: var(--accent); }
.sec-h .side { font-size: 13px; color: var(--muted); padding-top: 3px; text-align: right; }
.big { font-size: 40px; font-weight: 300; line-height: 1; }
.huge { font-size: 52px; font-weight: 300; line-height: 1; }
.pill { display: inline-block; font-size: 13px; padding: 3px 10px; border-radius: 12px; background: var(--chip); color: var(--accent); }
.pill.warn { color: var(--warn); }
.bar { position: relative; height: 6px; border-radius: 3px; background: var(--rule); overflow: visible; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--gilt); transform-origin: left center; }
.bar > i.warn { background: var(--warn); }
.bar > b { position: absolute; top: -3px; width: 2px; height: 12px; background: var(--ink); opacity: 0.55; }
.thick { height: 8px; border-radius: 4px; }
.thick > i { border-radius: 4px; }
.row { display: flex; align-items: center; gap: 12px; min-height: 56px; border-bottom: 1px solid var(--rule); }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-size: 16px; }
.row .s { font-size: 13px; color: var(--muted); }
.check { width: 24px; height: 24px; flex: none; border-radius: 12px; border: 1.3px solid var(--gilt); background: transparent; display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; }
.check.on { background: var(--gilt); }
.check svg { width: 12px; height: 12px; fill: none; stroke: var(--surface); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn { width: 36px; height: 36px; border-radius: 18px; border: 1px solid var(--rule); background: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--muted); }
.icon-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.btn { min-height: 44px; padding: 0 18px; border-radius: 22px; border: 1px solid var(--rule); background: transparent; color: var(--ink); cursor: pointer; font-size: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--ground); font-weight: 700; }
.field { min-height: 44px; padding: 0 14px; border-radius: 22px; border: 1px solid var(--rule); background: var(--field); outline: none; min-width: 0; }
.field:focus { border-color: var(--gilt); }
.form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.form .field { flex: 1 1 120px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.img-head { position: relative; height: 140px; color: #F7F1E3; }
.img-head img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-head::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(8,8,8,0) 25%, rgba(8,8,8,0.72) 100%); }
.img-head .cap { position: absolute; z-index: 1; left: 18px; right: 18px; bottom: 12px; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.img-head .cap .t { font-size: 26px; line-height: 1; font-weight: 300; }
.img-head .cap .latin { color: #EBCB82; margin-top: 4px; }
.img-head .badge { font-size: 13px; padding: 4px 10px; border-radius: 12px; background: rgba(235,203,130,0.92); color: #2A2116; }
.card-body { padding: 14px 18px 12px; }

/* Area cards on Today */
.area { position: relative; display: block; height: 300px; border-radius: 22px; overflow: hidden; color: #F7F1E3; text-decoration: none; }
.area img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.area::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(8,8,8,0.05) 30%, rgba(8,8,8,0.78) 100%); }
.area .in { position: absolute; z-index: 1; left: 18px; right: 18px; bottom: 16px; display: flex; flex-direction: column; gap: 10px; }
.area .name { font-size: 32px; line-height: 1; font-weight: 300; }
.area .latin { color: #EBCB82; font-size: 11px; margin-top: 4px; }
.area .stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 10px 12px; border-radius: 14px; background: rgba(18,16,14,0.4);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid rgba(255,255,255,0.14); }
.area .stats .v { font-size: 20px; }
.area .stats .k { font-size: 12px; color: #E3D8C2; }
.go { width: 40px; height: 40px; border-radius: 20px; background: rgba(255,255,255,0.16); border: 1px solid rgba(255,255,255,0.3); display: flex; align-items: center; justify-content: center; }
.go svg { width: 16px; height: 16px; fill: none; stroke: #F7F1E3; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Gloria */
.gloria { display: flex; gap: 14px; align-items: flex-start; }
.avatar { position: relative; width: 44px; height: 44px; flex: none; }
.avatar .ring { position: absolute; inset: 0; border-radius: 22px; border: 1.5px solid var(--gilt); }
.avatar .core { position: absolute; inset: 4px; border-radius: 18px; background: var(--accent); display: flex; align-items: center; justify-content: center; }
.avatar svg { width: 17px; height: 17px; fill: none; stroke: var(--ground); stroke-width: 1.6; stroke-linecap: round; }
.say { margin: 0; font-size: 18px; line-height: 1.45; }
.gilt-line { height: 1px; background-image: linear-gradient(90deg, var(--rule) 0%, var(--rule) 38%, var(--hot) 50%, var(--rule) 62%, var(--rule) 100%); background-size: 220% 100%; }

/* Week dots */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; text-align: center; }
.week .d { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.week .dl { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: var(--muted); }
.week .dot { width: 38px; height: 38px; border-radius: 19px; border: 1.5px solid var(--gilt); display: flex; align-items: center; justify-content: center; background: transparent; padding: 0; }
.week .dot.on { background: var(--gilt); }
.week .dot.rest { border-color: var(--rule); }
.week .dot.today { box-shadow: 0 0 0 2px var(--ground), 0 0 0 3.5px var(--ink); }
.week .dot svg { width: 14px; height: 14px; fill: none; stroke: var(--surface); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.week .w { font-size: 11px; line-height: 1.2; color: var(--muted); }

/* Plan timeline */
.phases { position: relative; display: flex; gap: 3px; height: 10px; margin-top: 14px; }
.phases i { border-radius: 3px; background: var(--rule); }
.phases i.past { background: var(--gilt); }
.phases i.now { background: var(--gilt); opacity: 0.55; }
.phases b { position: absolute; top: -5px; width: 2px; height: 20px; border-radius: 1px; background: var(--ink); }
.checkpoints { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; margin-top: 14px; text-align: center; }
.checkpoints > div { padding: 8px 2px; border-radius: 10px; border: 1px solid var(--rule); }
.checkpoints > div.next { border-color: var(--gilt); }
.checkpoints > div.goal { background: var(--accent); color: var(--ground); border-color: var(--accent); }
.checkpoints .v { font-size: 15px; }
.checkpoints .k { font-size: 11px; opacity: 0.8; }

/* Rhythms */
.rhythm { padding: 14px; background: var(--surface); border: 1px solid var(--rule); border-radius: 16px; display: flex; flex-direction: column; gap: 4px; text-align: left; cursor: pointer; }
.rhythm .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rhythm .n { font-size: 16px; }
.rhythm .dotm { width: 8px; height: 8px; border-radius: 4px; background: var(--rule); flex: none; }
.rhythm.kept .dotm { background: var(--gilt); }
.rhythm .st { font-size: 13px; color: var(--muted); }

.page-top { padding-top: calc(30px + env(safe-area-inset-top)); }
body.auth { padding-bottom: 0; }
.pin-dots { display: flex; gap: 18px; justify-content: center; margin: 2px 0 6px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 7px; border: 1.5px solid var(--gilt); transition: background .15s; }
.pin-dots i.on { background: var(--gilt); }
.pin-dots.shake { animation: shake .4s; }
.keypad { display: grid; grid-template-columns: repeat(3, 72px); gap: 14px; justify-content: center; }
.keypad button { width: 72px; height: 72px; border-radius: 36px; border: 1px solid var(--glass-line); background: rgba(255,255,255,0.35); color: var(--ink);
  font-size: 28px; font-weight: 300; cursor: pointer; display: flex; align-items: center; justify-content: center; -webkit-tap-highlight-color: transparent; }
:root[data-mode="night"] .keypad button { background: rgba(255,255,255,0.06); }
.keypad button:active { background: var(--gilt); color: var(--ground); }
@keyframes shake { 0%,100% { transform: none; } 20%,60% { transform: translateX(-8px); } 40%,80% { transform: translateX(8px); } }
body.auth .bottomnav, body.auth .topnav { display: none !important; }
.toast { position: fixed; z-index: 40; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 10px 16px; border-radius: 20px; background: var(--ink); color: var(--ground); font-size: 14px; }
.empty { padding: 14px; border-radius: 14px; background: var(--chip); font-size: 15px; }

@media (prefers-reduced-motion: no-preference) {
  .kb { animation: kb 36s ease-in-out infinite alternate; }
  .rays { animation: rays 16s ease-in-out infinite alternate; }
  .glow { animation: glow 3.2s ease-in-out infinite; }
  .mote { animation: mote 10s linear infinite; }
  .ring { animation: breathe 3.6s ease-in-out infinite; }
  .gilt-line { animation: shimmer 5s linear infinite; }
  #app.animate .rise { animation: rise .9s cubic-bezier(.2,.7,.2,1) both; }
  #app.animate .draw { stroke-dasharray: 600; animation: draw 2.4s cubic-bezier(.3,.7,.2,1) .3s both; }
  #app.animate .bar > i { animation: grow 1.3s cubic-bezier(.3,.7,.2,1) .3s both; }
  .area img { transition: transform .9s cubic-bezier(.2,.7,.2,1); }
  .area:hover img { transform: scale(1.05); }
}
@keyframes kb { from { transform: scale(1.03); } to { transform: scale(1.15) translateY(-2%); } }
@keyframes rays { from { transform: rotate(-7deg); opacity: .5; } to { transform: rotate(7deg); opacity: .95; } }
@keyframes glow { 0%,100% { opacity: .7; } 30% { opacity: 1; } 50% { opacity: .8; } 70% { opacity: .95; } }
@keyframes mote { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: .9; } 100% { transform: translateY(-260px); opacity: 0; } }
@keyframes breathe { 0%,100% { transform: scale(1); opacity: .6; } 50% { transform: scale(1.45); opacity: 0; } }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes draw { from { stroke-dashoffset: 600; } to { stroke-dashoffset: 0; } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

@media (min-width: 900px) {
  body { padding-bottom: 60px; }
  .bottomnav { display: none; }
  .topnav { display: flex; position: fixed; z-index: 20; top: 18px; left: 28px; right: 28px; padding: 8px 10px 8px 20px; border-radius: 40px; align-items: center; justify-content: space-between;
    background: rgba(18,16,14,0.32); backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2); border: 1px solid rgba(255,255,255,0.16); color: #F7F1E3; }
  .topnav .brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
  .topnav .brand svg { width: 26px; height: 26px; fill: none; stroke: #EBCB82; stroke-width: 1.2; stroke-linejoin: round; }
  .topnav .brand span { font-family: var(--cinzel); font-weight: 500; font-size: 18px; letter-spacing: 0.28em; }
  .topnav-links { display: flex; gap: 2px; }
  .topnav-links a { min-height: 44px; display: flex; align-items: center; padding: 0 18px; border-radius: 22px; text-decoration: none; font-family: var(--cinzel); font-size: 13px; letter-spacing: 0.16em; color: #E9DFC9; }
  .topnav-links a.on { background: rgba(255,255,255,0.18); color: #FFF6E2; font-weight: 600; }
  .hero { height: 640px; }
  .hero.short { height: 560px; }
  .hero-bar .wordmark { visibility: hidden; }
  .hero-bar { padding-top: 96px; }
  .wrap { max-width: 1180px; padding: 0 40px; }
  .hero-title { left: max(40px, calc((100vw - 1100px) / 2)); right: 40px; }
  .hero-title h1 { font-size: 72px; }
  .cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
  .cols3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: start; }
  .lift { margin-top: -190px; }
  .area { height: 420px; }
  .page-top { padding-top: 110px; max-width: 760px; }
}
