:root {
  color-scheme: light dark;
  --bg: #f4f1eb;
  --surface: #fffdf8;
  --surface-2: #ebe7de;
  --ink: #171713;
  --muted: #6d6b63;
  --line: rgba(23, 23, 19, 0.1);
  --accent: #d4543d;
  --accent-soft: #f4d9ce;
  --green: #376c52;
  --shadow: 0 12px 34px rgba(60, 45, 30, 0.08);
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11110f;
    --surface: #1a1a17;
    --surface-2: #24231f;
    --ink: #f6f1e8;
    --muted: #aaa69b;
    --line: rgba(255, 255, 255, 0.1);
    --accent: #ef765d;
    --accent-soft: #4a2922;
    --green: #7cb493;
    --shadow: 0 16px 42px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--bg); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.login-screen { min-height: 100dvh; padding: max(26px, env(safe-area-inset-top)) 18px max(26px, env(safe-area-inset-bottom)); display: grid; place-items: center; }
.login-card { width: min(100%, 430px); padding: clamp(28px, 7vw, 42px); border: 1px solid var(--line); border-radius: 28px; background: var(--surface); box-shadow: var(--shadow); }
.login-mark { margin-bottom: 30px; }
.login-card h1 { font-size: clamp(42px, 11vw, 62px); }
.login-copy { margin: 18px 0 30px; color: var(--muted); line-height: 1.55; }
.login-card form { display: grid; gap: 9px; }
.login-card label { margin-top: 9px; color: var(--muted); font-size: 12px; font-weight: 700; }
.login-card input { width: 100%; min-height: 50px; padding: 0 14px; border: 1px solid var(--line); border-radius: 14px; outline: none; color: var(--ink); background: var(--bg); }
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
.login-button { width: 100%; min-height: 50px; margin-top: 16px; }
.login-button:disabled { opacity: .65; }
.form-error { margin: 8px 0 0; color: var(--accent); font-size: 13px; }

.app-shell { width: min(100%, 1080px); margin: 0 auto; min-height: 100dvh; padding: env(safe-area-inset-top) 18px calc(92px + env(safe-area-inset-bottom)); }
.topbar { height: 78px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand > span:last-child { display: grid; line-height: 1; gap: 3px; }
.brand strong { font-size: 17px; letter-spacing: -0.02em; }
.brand small { color: var(--muted); font-size: 12px; }
.brand-mark { display: block; width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: transparent; filter: drop-shadow(0 2px 5px rgba(20, 10, 5, .18)); }
.brand-mark.large { width: 58px; height: 58px; flex: 0 0 auto; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.status-pill, .location-chip { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; }
.status-pill { padding: 8px 11px; font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 16%, transparent); }
.status-pill.partial .status-dot { background: #d39b3f; }
.status-pill.error .status-dot { background: var(--accent); }
.icon-button { width: 40px; height: 40px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font-size: 22px; }
.icon-button.loading span { display: inline-block; animation: spin .7s linear infinite; }

.view { display: none; animation: appear .22s ease-out; }
.view.active { display: block; }
.today-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin: 22px 0 30px; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 12px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
h1 { margin: 0; max-width: 720px; font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: clamp(34px, 7vw, 58px); letter-spacing: -.04em; line-height: .98; }
h2 { margin: 0; font-size: 19px; letter-spacing: -.025em; }
.location-chip { max-width: 45%; padding: 10px 13px; font-size: 13px; white-space: nowrap; overflow: hidden; }
.location-chip span:last-child { overflow: hidden; text-overflow: ellipsis; }

.card, .hero-card, .weather-strip, .about-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.hero-card { position: relative; overflow: hidden; min-height: 220px; padding: clamp(24px, 5vw, 38px); background: var(--ink); color: var(--bg); }
.hero-card::after { content: ""; position: absolute; width: 270px; height: 270px; right: -100px; bottom: -170px; border: 60px solid var(--accent); border-radius: 50%; opacity: .8; }
.hero-card .kicker { position: relative; z-index: 1; color: color-mix(in srgb, var(--bg) 68%, transparent); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
.hero-card h3 { position: relative; z-index: 1; margin: 22px 0 14px; max-width: 640px; font-family: Georgia, serif; font-size: clamp(28px, 6vw, 46px); font-weight: 500; line-height: 1.02; letter-spacing: -.035em; }
.hero-card p { position: relative; z-index: 1; margin: 0; max-width: 620px; color: color-mix(in srgb, var(--bg) 78%, transparent); }
.hero-meta { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.hero-meta span { padding: 8px 11px; border-radius: 999px; background: rgba(255,255,255,.1); font-size: 12px; }

.weather-strip { display: grid; grid-template-columns: 1.2fr repeat(3, minmax(0, .65fr)); gap: 10px; align-items: stretch; margin-top: 14px; padding: 12px; }
.weather-main, .weather-stat { min-height: 76px; padding: 13px; border-radius: 16px; background: var(--surface-2); }
.weather-main { display: flex; align-items: center; gap: 13px; }
.weather-symbol { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 15px; background: var(--accent-soft); color: var(--accent); font-size: 24px; }
.weather-main strong { display: block; font-size: 24px; letter-spacing: -.04em; }
.weather-main small, .weather-stat small { color: var(--muted); }
.weather-stat { display: grid; align-content: center; gap: 5px; }
.weather-stat strong { font-size: 16px; }

.section-heading { display: flex; justify-content: space-between; align-items: center; margin: 30px 2px 12px; }
.section-heading > span { color: var(--muted); font-size: 12px; }
.text-button { padding: 5px; border: 0; background: transparent; color: var(--accent); cursor: pointer; font-weight: 650; }
.quick-task-form { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; margin-bottom: 10px; }
.quick-task-form input { min-width: 0; min-height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); background: var(--surface); outline: none; }
.quick-task-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
.quick-task-form input[type="date"] { width: 152px; color: var(--muted); }
.quick-task-form .primary-button { min-height: 46px; }
.quick-task-form button:disabled { opacity: .6; }
.list-card { overflow: hidden; }
.list-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 13px; min-height: 68px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 13px; background: var(--surface-2); color: var(--accent); font-weight: 800; }
.list-copy { min-width: 0; }
.list-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.list-copy small { display: block; margin-top: 4px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.list-trailing { color: var(--muted); font-size: 12px; white-space: nowrap; }
.task-check { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 13px; color: transparent; background: var(--surface-2); cursor: pointer; font-weight: 850; }
.task-check:hover, .task-check:focus-visible { color: white; border-color: var(--green); background: var(--green); }
.task-check:disabled { opacity: .55; cursor: wait; }
.empty-state { padding: 26px 18px; color: var(--muted); text-align: center; }

.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.compact-card { min-height: 170px; padding: 20px; }
.compact-card .card-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 13px; background: var(--accent-soft); color: var(--accent); }
.compact-card h3 { margin: 24px 0 7px; font-size: 18px; }
.compact-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

.view:not([data-view="oggi"]) { padding-top: 28px; }
.view:not([data-view="oggi"]) > h1 { margin-bottom: 34px; }
.project-grid, .link-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.project-card, .link-card { min-height: 128px; padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.project-card strong, .link-card strong { display: block; margin-top: 26px; }
.project-card small, .link-card small { display: block; margin-top: 5px; color: var(--muted); }
.link-card > span { color: var(--accent); font-size: 22px; }
.about-card { display: flex; gap: 16px; align-items: center; margin-top: 24px; padding: 20px; }
.about-card p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

.bottom-nav { position: fixed; z-index: 20; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; grid-template-columns: repeat(4, 1fr); width: min(calc(100% - 24px), 560px); padding: 7px; border: 1px solid var(--line); border-radius: 24px; background: color-mix(in srgb, var(--surface) 88%, transparent); box-shadow: 0 15px 45px rgba(20, 20, 15, .18); backdrop-filter: blur(18px); }
.nav-item { display: grid; place-items: center; gap: 3px; min-height: 52px; border: 0; border-radius: 17px; background: transparent; color: var(--muted); cursor: pointer; }
.nav-item span { font-size: 18px; line-height: 1; }
.nav-item small { font-size: 11px; }
.nav-item.active { color: var(--ink); background: var(--surface-2); }

.skeleton-stack { display: grid; gap: 14px; }
.skeleton-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.skeleton { min-height: 120px; border-radius: var(--radius); background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface) 48%, var(--surface-2) 66%); background-size: 250% 100%; animation: shimmer 1.25s infinite; }
.skeleton-hero { min-height: 220px; }
.skeleton-list { min-height: 190px; }
.error-card { padding: 26px; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: var(--radius); background: var(--accent-soft); }
.error-card p { color: var(--muted); }
.primary-button { padding: 11px 16px; border: 0; border-radius: 13px; color: white; background: var(--accent); cursor: pointer; font-weight: 700; }
.secondary-button { padding: 11px 16px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); background: var(--surface); cursor: pointer; font-weight: 700; }
.logout-button { width: 100%; margin-top: 18px; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(calc(100% - 36px), 460px); padding: 13px 16px; border-radius: 15px; color: #fff; background: var(--green); box-shadow: 0 14px 40px rgba(15, 15, 10, .24); text-align: center; font-size: 13px; font-weight: 700; }
.toast.error { background: var(--accent); }

@media (max-width: 680px) {
  .app-shell { padding-left: 14px; padding-right: 14px; }
  .today-heading { display: block; margin-top: 18px; }
  .location-chip { max-width: 100%; margin-top: 18px; }
  .weather-strip { grid-template-columns: 1fr 1fr 1fr; }
  .weather-main { grid-column: 1 / -1; }
  .two-column { grid-template-columns: 1fr; }
  .status-pill { display: none; }
  .quick-task-form { grid-template-columns: minmax(0, 1fr) auto; }
  .quick-task-form input[name="title"] { grid-column: 1 / -1; }
  .quick-task-form input[type="date"] { width: 100%; }
}

@media (min-width: 880px) {
  .app-shell { padding-left: 34px; padding-right: 34px; }
  .today-heading { margin-top: 38px; }
  .bottom-nav { bottom: 20px; }
}

@media (prefers-reduced-motion: reduce) { * { animation-duration: .001ms !important; scroll-behavior: auto !important; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position-x: -250%; } }
@keyframes appear { from { opacity: 0; transform: translateY(5px); } }
