@import url("../vendor/fonts.css");

:root{
  --bg:#f6f5f1; --surface:#ffffff; --surface-2:#f0eee8; --surface-3:#e8e5dd;
  --text:#1c1b19; --muted:#6b6862; --faint:#9c988f;
  --border:#e4e1d9; --border-strong:#cfcbc1;
  --ink:#1c1b19; --on-ink:#ffffff;
  --danger:#c2352f; --ok:#1f8a4c; --star:#b45309; --star-bg:#fef3c7;
  --shared:#7c3aed;
  --radius:14px; --radius-sm:9px; --radius-lg:20px;
  --gap:12px;
  --font:'General Sans', ui-sans-serif, system-ui, sans-serif;
  --tabbar-h:84px; --header-h:96px;
  color-scheme: light;
}
[data-theme="dark"]{
  --bg:#121210; --surface:#1c1b19; --surface-2:#252421; --surface-3:#2f2d29;
  --text:#f2f0ea; --muted:#a8a49b; --faint:#77736b;
  --border:#2f2d29; --border-strong:#45423c;
  --ink:#f2f0ea; --on-ink:#121210;
  --star-bg:#45320f; --star:#fbbf24;
  color-scheme: dark;
}

*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html{font-size:16px;height:100%}
@media (min-width:900px){ html{font-size:22px} :root{--tabbar-h:5.2rem;--header-h:5.6rem} }
body{margin:0;height:100%;background:var(--bg);color:var(--text);font-family:var(--font);font-weight:400;line-height:1.35;
  -webkit-font-smoothing:antialiased;overscroll-behavior:none;user-select:none}
input,textarea,select,button{font:inherit;color:inherit}
input,textarea,select{user-select:text}
button{cursor:pointer;border:0;background:none;padding:0}
:focus-visible{outline:3px solid var(--shared);outline-offset:2px}
.hidden{display:none!important}
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}

/* ---------- App frame ---------- */
#app{height:100%;display:grid;grid-template-rows:var(--header-h) 1fr var(--tabbar-h)}
.header{display:flex;align-items:center;justify-content:space-between;padding:0 1.1rem;border-bottom:1px solid var(--border);background:var(--bg)}
.clock{font-size:2.6rem;font-weight:600;letter-spacing:-.02em;line-height:1;font-variant-numeric:tabular-nums}
.date{font-size:1rem;color:var(--muted);margin-top:.2rem}
.weather-btn{display:flex;align-items:center;gap:.6rem;padding:.5rem .9rem;border:1px solid var(--border);border-radius:999px;min-height:3rem}
.weather-btn .t{font-size:1.5rem;font-weight:600}
.weather-btn .d{font-size:.85rem;color:var(--muted);text-align:left;line-height:1.2}
.weather-btn svg{width:1.8rem;height:1.8rem}
main{overflow:hidden;position:relative}
.view{position:absolute;inset:0;overflow:auto;padding:.9rem 1.1rem 1.1rem;display:flex;flex-direction:column;gap:.8rem}

.tabbar{display:grid;grid-template-columns:repeat(6,1fr) 4.5rem;border-top:1px solid var(--border-strong);background:var(--bg)}
.tab{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:.25rem;color:var(--muted);font-size:.8rem;font-weight:500;position:relative}
.tab svg{width:1.6rem;height:1.6rem}
.tab[aria-current="page"]{color:var(--text);font-weight:600;background:var(--surface-2)}
.tab[aria-current="page"]::before{content:"";position:absolute;top:0;left:18%;right:18%;height:3px;border-radius:0 0 3px 3px;background:var(--ink)}
.tab:active{background:var(--surface-3)}

/* ---------- Mobile ---------- */
@media (max-width:899px){
  #app{grid-template-rows:auto 1fr calc(4.2rem + env(safe-area-inset-bottom))}
  .header{padding:calc(.5rem + env(safe-area-inset-top)) 1rem .5rem}
  .clock{font-size:1.6rem}.date{font-size:.8rem}
  .weather-btn{padding:.3rem .7rem;min-height:2.4rem}.weather-btn .t{font-size:1.1rem}.weather-btn .d{display:none}
  .tabbar{grid-template-columns:repeat(4,1fr) 3.6rem;padding-bottom:env(safe-area-inset-bottom)}
  .tab[data-tab="youtube"],.tab[data-tab="netflix"]{display:none}
  .view{padding:.8rem .8rem 1rem}
}

/* ---------- Controls ---------- */
.toolbar{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap}
.toolbar .spacer{flex:1}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:.4rem;min-height:2.9rem;padding:0 1rem;border-radius:var(--radius-sm);
  border:1px solid var(--border-strong);background:var(--surface);font-weight:500;font-size:.95rem;white-space:nowrap}
.btn:active{transform:scale(.97);background:var(--surface-2)}
.btn.primary{background:var(--ink);color:var(--on-ink);border-color:var(--ink);font-weight:600}
.btn.danger{color:var(--danger);border-color:color-mix(in srgb,var(--danger) 40%,var(--border))}
.btn.icon{width:2.9rem;padding:0}
.btn svg{width:1.2rem;height:1.2rem}
.seg{display:inline-flex;border:1px solid var(--border-strong);border-radius:var(--radius-sm);overflow:hidden;background:var(--surface)}
.seg button{min-height:2.9rem;padding:0 .9rem;font-size:.95rem;font-weight:500;color:var(--muted)}
.seg button[aria-pressed="true"]{background:var(--surface-3);color:var(--text);font-weight:600}
.chip{display:inline-flex;align-items:center;gap:.45rem;min-height:2.9rem;padding:0 .9rem;border-radius:999px;border:1px solid var(--border-strong);background:var(--surface);font-size:.95rem;font-weight:500}
.chip .dot{width:.75rem;height:.75rem;border-radius:50%;background:var(--c)}
.chip[aria-pressed="false"]{opacity:.45}
.chip[aria-pressed="false"] .dot{background:transparent;border:2px solid var(--c)}
.range-label{font-size:1.15rem;font-weight:600;min-width:7rem;text-align:center}

.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:.9rem 1rem}
.section-title{font-size:.75rem;text-transform:uppercase;letter-spacing:.08em;color:var(--faint);font-weight:600;margin:0 0 .5rem}
.empty{color:var(--muted);text-align:center;padding:2rem 1rem}
.banner{display:flex;align-items:center;gap:.8rem;padding:.8rem 1rem;border-radius:var(--radius);background:var(--surface-2);border:1px solid var(--border)}
.banner .grow{flex:1}
.banner.warn{background:color-mix(in srgb,#f59e0b 14%,var(--surface));border-color:color-mix(in srgb,#f59e0b 35%,var(--border))}

/* ---------- Forms ---------- */
.field{display:flex;flex-direction:column;gap:.35rem}
.field label,.field .label{font-size:.85rem;color:var(--muted);font-weight:500}
.input,select.input,textarea.input{min-height:3rem;border:1px solid var(--border-strong);border-radius:var(--radius-sm);background:var(--surface);padding:.55rem .8rem;font-size:1rem;width:100%}
textarea.input{min-height:5rem;resize:vertical}
.row{display:flex;gap:.7rem}.row>*{flex:1}
.switch{display:flex;align-items:center;gap:.7rem;min-height:3rem}
.switch input{width:2.6rem;height:1.5rem;accent-color:var(--ink)}
.form-error{color:var(--danger);font-size:.9rem;min-height:1.2em}

/* ---------- Sheets / modals ---------- */
.overlay{position:fixed;inset:0;background:rgba(10,10,8,.45);display:flex;align-items:flex-end;justify-content:center;z-index:50;animation:fade .15s ease}
.sheet{background:var(--bg);width:min(100%,46rem);max-height:88%;overflow:auto;border-radius:var(--radius-lg) var(--radius-lg) 0 0;padding:1.2rem 1.2rem calc(1.2rem + env(safe-area-inset-bottom));
  display:flex;flex-direction:column;gap:.9rem;animation:up .2s ease}
@media (min-width:900px){.overlay{align-items:center}.sheet{border-radius:var(--radius-lg);max-height:80%}}
.sheet h2{margin:0;font-size:1.35rem;font-weight:600}
.sheet .actions{display:flex;gap:.6rem;justify-content:flex-end;flex-wrap:wrap;margin-top:.3rem}
@keyframes fade{from{opacity:0}}
@keyframes up{from{transform:translateY(24px);opacity:.6}}
.toast{position:fixed;left:50%;bottom:calc(var(--tabbar-h) + 1rem);transform:translateX(-50%);background:var(--ink);color:var(--on-ink);padding:.7rem 1.1rem;border-radius:999px;font-weight:500;z-index:60;animation:up .2s ease}

/* PIN pad */
.pin-dots{display:flex;justify-content:center;gap:.8rem;margin:.4rem 0}
.pin-dots i{width:1rem;height:1rem;border-radius:50%;border:2px solid var(--border-strong)}
.pin-dots i.on{background:var(--ink);border-color:var(--ink)}
.pin-pad{display:grid;grid-template-columns:repeat(3,1fr);gap:.6rem;max-width:18rem;margin:0 auto;width:100%}
.pin-pad button{min-height:4rem;border-radius:var(--radius);background:var(--surface);border:1px solid var(--border);font-size:1.5rem;font-weight:600}
.pin-pad button:active{background:var(--surface-3)}

/* ---------- Auth ---------- */
.auth{height:100%;display:grid;place-items:center;padding:1.5rem}
.auth .card{width:min(100%,26rem);display:flex;flex-direction:column;gap:.9rem;padding:1.6rem}
.auth h1{margin:0;font-size:1.8rem;font-weight:600;letter-spacing:-.02em}
.auth p{margin:0;color:var(--muted)}
.linkish{color:var(--text);text-decoration:underline;text-underline-offset:3px;font-weight:500}

/* ---------- Calendar ---------- */
.cal{flex:1;min-height:0;display:flex;flex-direction:column;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);overflow:hidden}
.cal-head{display:grid;grid-template-columns:3rem repeat(var(--days),1fr);border-bottom:1px solid var(--border)}
.cal-head .dh{padding:.45rem 0 .5rem;text-align:center;font-size:.8rem;color:var(--muted);font-weight:500}
.cal-head .dh b{display:block;font-size:1.25rem;color:var(--text);font-weight:600;margin-top:.1rem}
.cal-head .dh.today b{display:inline-grid;place-items:center;min-width:2.1rem;height:2.1rem;border-radius:999px;background:var(--ink);color:var(--on-ink)}
.cal-allday{display:grid;grid-template-columns:3rem repeat(var(--days),1fr);border-bottom:1px solid var(--border);min-height:2.1rem}
.cal-allday .lbl{font-size:.6rem;color:var(--faint);display:flex;align-items:center;justify-content:center;text-align:center;line-height:1.1}
.cal-allday .cell{padding:.2rem;display:flex;flex-direction:column;gap:.2rem;border-left:1px solid var(--border)}
.cal-body{flex:1;overflow:auto;position:relative}
.cal-grid{display:grid;grid-template-columns:3rem repeat(var(--days),1fr);position:relative;height:calc(var(--hours) * var(--hour-h))}
.cal-gutter{position:relative}
.cal-gutter span{position:absolute;right:.4rem;transform:translateY(-.55em);font-size:.7rem;color:var(--faint);font-variant-numeric:tabular-nums}
.cal-col{position:relative;border-left:1px solid var(--border);
  background-image:linear-gradient(var(--border) 1px,transparent 1px);background-size:100% var(--hour-h)}
.cal-col.today{background-color:color-mix(in srgb,var(--surface-2) 70%,transparent)}
.now-line{position:absolute;left:0;right:0;height:2px;background:var(--danger);z-index:3}
.now-line::before{content:"";position:absolute;left:-5px;top:-4px;width:10px;height:10px;border-radius:50%;background:var(--danger)}
.ev{position:absolute;border-radius:7px;padding:.25rem .35rem;overflow:hidden;font-size:.75rem;line-height:1.2;text-align:left;
  background:color-mix(in srgb,var(--c) 16%,var(--surface));color:color-mix(in srgb,var(--c) 70%,var(--text));border-left:4px solid var(--c);z-index:2}
[data-theme="dark"] .ev{background:color-mix(in srgb,var(--c) 28%,var(--surface));color:color-mix(in srgb,var(--c) 35%,white)}
.ev b{display:block;font-weight:600;font-size:.8rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ev:active{filter:brightness(.95)}
.ev.allday{position:static;padding:.2rem .4rem;font-size:.72rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:600}

.month{flex:1;display:grid;grid-template-rows:auto repeat(var(--weeks),1fr);min-height:0}
.month .mh{display:grid;grid-template-columns:repeat(7,1fr);border-bottom:1px solid var(--border)}
.month .mh div{text-align:center;font-size:.75rem;color:var(--muted);padding:.4rem 0;font-weight:500}
.month .mw{display:grid;grid-template-columns:repeat(7,1fr);border-bottom:1px solid var(--border);min-height:0}
.month .md{border-left:1px solid var(--border);padding:.25rem;display:flex;flex-direction:column;gap:.2rem;overflow:hidden;text-align:left;min-height:0}
.month .md:first-child{border-left:0}
.month .md .n{font-size:.8rem;font-weight:600;width:1.7rem;height:1.7rem;display:grid;place-items:center;border-radius:999px}
.month .md.out .n{color:var(--faint)}
.month .md.today .n{background:var(--ink);color:var(--on-ink)}
.month .more{font-size:.68rem;color:var(--muted);padding-left:.2rem}

.agenda{display:flex;flex-direction:column;gap:.8rem;overflow:auto}
.agenda .day h3{margin:0 0 .4rem;font-size:.9rem;color:var(--muted);font-weight:600}
.agenda .day.today h3{color:var(--text)}
.agenda .item{display:flex;gap:.8rem;align-items:stretch;padding:.7rem .8rem;border-radius:var(--radius-sm);background:var(--surface);border:1px solid var(--border);margin-bottom:.4rem;width:100%;text-align:left}
.agenda .item .bar{width:5px;border-radius:3px;background:var(--c)}
.agenda .item .time{min-width:4.8rem;font-size:.9rem;font-variant-numeric:tabular-nums;color:var(--muted)}
.agenda .item .t{font-weight:600}
.agenda .item .s{font-size:.85rem;color:var(--muted)}

.strip{display:grid;grid-template-columns:1.3fr 1fr 1fr;gap:.8rem}
.strip .card{padding:.8rem .9rem;min-height:0}
.upnext .e{display:flex;gap:.6rem;align-items:center;padding:.35rem 0}
.upnext .e .bar{width:4px;align-self:stretch;border-radius:2px;background:var(--c)}
.upnext .e .t{font-weight:600;font-size:.95rem}
.upnext .e .s{font-size:.8rem;color:var(--muted)}
.meal-line{display:flex;justify-content:space-between;gap:.5rem;padding:.2rem 0;font-size:.9rem}
.meal-line span:first-child{color:var(--muted)}
.meal-line.dinner span:last-child{font-weight:600}
@media (max-width:899px){.strip{display:none}}

.detail-row{display:flex;gap:.8rem;align-items:flex-start;font-size:1rem}
.detail-row svg{width:1.3rem;height:1.3rem;flex:none;color:var(--muted);margin-top:.1rem}
.cal-pick{display:flex;gap:.5rem;flex-wrap:wrap}

/* ---------- Settings ---------- */
.settings{max-width:46rem;width:100%;margin:0 auto;display:flex;flex-direction:column;gap:.9rem}
.settings h2{margin:.3rem 0 0;font-size:1.1rem;font-weight:600}
.kv{display:flex;align-items:center;justify-content:space-between;gap:1rem;padding:.55rem 0;border-bottom:1px solid var(--border)}
.kv:last-child{border-bottom:0}
.kv .k{font-weight:500}.kv .v{color:var(--muted);font-size:.9rem;text-align:right}
.swatch{width:1.1rem;height:1.1rem;border-radius:50%;background:var(--c);display:inline-block;vertical-align:middle;margin-right:.4rem}
.placeholder{flex:1;display:grid;place-items:center;text-align:center;color:var(--muted)}
.placeholder h2{color:var(--text);margin:.6rem 0 .3rem;font-weight:600}
.launch{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1.2rem;text-align:center}
.launch .big{display:flex;align-items:center;gap:.9rem;padding:1.2rem 2rem;border-radius:var(--radius-lg);background:var(--ink);color:var(--on-ink);font-size:1.4rem;font-weight:600}
.launch .big svg{width:2.4rem;height:2.4rem}
.launch p{color:var(--muted);max-width:28rem;margin:0}
.skeleton{background:linear-gradient(90deg,var(--surface-2),var(--surface-3),var(--surface-2));background-size:200% 100%;animation:sk 1.2s infinite linear;border-radius:var(--radius-sm)}
@keyframes sk{to{background-position:-200% 0}}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
#app.auth{display:grid;grid-template-rows:none;place-items:center;height:100%}
a{color:inherit;text-decoration:none}
.cal-head .dh.today b{display:grid;margin:.1rem auto 0;width:2.1rem}
@media (max-width:899px){.range-label{min-width:0;font-size:1rem}.toolbar .btn{padding:0 .7rem}}
.ev b{white-space:normal;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
