:root {
  color-scheme: light;
  --ink: #111313;
  --muted: #666a68;
  --paper: #f4f4f1;
  --surface: #ffffff;
  --soft: #e9eae6;
  --line: #d9dad5;
  --yellow: #ffe000;
  --yellow-soft: #fff7ae;
  --danger: #b92922;
  --success: #147a52;
  --tbc: #9f6500;
  --shadow: 0 18px 50px rgba(17, 19, 19, .12);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { min-height: 100%; margin: 0; color: var(--ink); background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(20, 122, 82, .35);
  outline-offset: 2px;
}
[hidden] { display: none !important; }

.login-screen {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) 22px calc(24px + var(--safe-bottom));
  background:
    linear-gradient(145deg, rgba(255, 224, 0, .92) 0 18%, transparent 18% 100%),
    var(--ink);
}

.login-card {
  width: min(100%, 420px);
  padding: 30px 26px;
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.login-logo { display: block; width: 126px; height: 92px; object-fit: contain; object-position: left center; margin-bottom: 20px; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.login-card h1 { max-width: 12ch; margin: 0; font-size: clamp(2.05rem, 10vw, 3rem); line-height: .98; letter-spacing: -.05em; }
.login-copy { margin: 18px 0 28px; color: var(--muted); line-height: 1.5; }
label { display: grid; gap: 8px; color: #303332; font-size: .9rem; font-weight: 750; }
input, select, textarea {
  width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 13px;
  padding: 11px 13px; color: var(--ink); background: #fff; font-size: 1rem;
}
textarea { min-height: 90px; resize: vertical; line-height: 1.45; }
input[readonly] { color: #555; background: #f5f5f2; }
.privacy-note { margin: 16px 0 0; color: var(--muted); font-size: .8rem; line-height: 1.45; }

.button {
  min-height: 48px; border: 1px solid transparent; border-radius: 13px; padding: 11px 16px;
  font-weight: 850; cursor: pointer;
}
.button-primary { color: var(--ink); background: var(--yellow); }
.button-primary:active { background: #efd300; transform: translateY(1px); }
.button-secondary { color: var(--ink); border-color: var(--ink); background: transparent; }
.button-block { width: 100%; margin-top: 16px; }

.app-shell { min-height: 100svh; padding-bottom: calc(90px + var(--safe-bottom)); }
.app-header {
  position: sticky; top: 0; z-index: 10; padding: calc(12px + var(--safe-top)) 18px 13px;
  color: #fff; background: rgba(17, 19, 19, .97); backdrop-filter: blur(18px);
  border-bottom: 3px solid var(--yellow);
}
.header-row { display: grid; grid-template-columns: 46px minmax(0, 1fr) 44px; gap: 12px; align-items: center; }
.header-logo { width: 46px; height: 42px; object-fit: contain; padding: 3px; border-radius: 10px; background: #fff; }
.header-title { min-width: 0; }
.header-title span { display: block; color: #b7bbb8; font-size: .78rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-title h1 { margin: 1px 0 0; font-size: 1.35rem; line-height: 1.15; letter-spacing: -.02em; }
.avatar-button { width: 44px; height: 44px; border: 1px solid #545856; border-radius: 50%; color: #111; background: var(--yellow); font-size: .8rem; font-weight: 900; }
.sync-pill {
  display: inline-flex; align-items: center; gap: 7px; min-height: 44px; margin: 6px 0 0 58px; padding: 7px 10px;
  border: 0; border-radius: 999px; color: #d4d7d5; background: #292c2b; font-size: .75rem;
}
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: #8d9290; }
.sync-pill.is-online .sync-dot { background: #5ce1a3; }
.sync-pill.is-offline .sync-dot { background: #ff8c83; }
.sync-pill.is-conflict .sync-dot { background: #ffb84d; }
.sync-pill.is-syncing .sync-dot { background: var(--yellow); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.main-content { width: min(100%, 760px); min-height: 65vh; margin: 0 auto; padding: 22px 17px 40px; }
.backup-reminder {
  display: grid; gap: 15px; margin-bottom: 18px; padding: 18px;
  border: 2px solid var(--ink); border-radius: 20px; background: var(--surface);
  box-shadow: 7px 7px 0 var(--yellow);
}
.backup-reminder h2 { margin: 0; font-size: 1.28rem; letter-spacing: -.03em; }
.backup-reminder > div > p:last-child { margin: 9px 0 0; color: var(--muted); font-size: .88rem; line-height: 1.45; }
.backup-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.backup-actions .button { margin: 0; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 2px 1px 16px; }
.section-heading h2 { margin: 0; font-size: 1.45rem; letter-spacing: -.03em; }
.section-heading p { margin: 5px 0 0; color: var(--muted); font-size: .9rem; }
.text-action { min-height: 44px; border: 0; padding: 7px 0; color: var(--ink); background: transparent; font-weight: 850; text-decoration: underline; text-decoration-color: var(--yellow); text-decoration-thickness: 3px; text-underline-offset: 4px; }

.hero-actions { display: grid; grid-template-columns: 1.35fr 1fr; gap: 10px; margin-bottom: 18px; }
.hero-action {
  min-height: 92px; border: 0; border-radius: 20px; padding: 17px; text-align: left;
  color: var(--ink); background: var(--yellow); box-shadow: 0 9px 24px rgba(115, 101, 0, .12);
}
.hero-action.secondary { background: var(--ink); color: #fff; box-shadow: none; }
.hero-action strong { display: block; margin-bottom: 8px; font-size: 1.08rem; }
.hero-action span { color: #4d4600; font-size: .85rem; line-height: 1.35; }
.hero-action.secondary span { color: #bdc1bf; }

.summary-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 26px; }
.summary-card { min-height: 116px; padding: 16px; border: 1px solid var(--line); border-radius: 19px; background: var(--surface); }
.summary-card.is-alert { border-color: #efc6c3; background: #fff8f7; }
.summary-label { display: block; min-height: 38px; color: var(--muted); font-size: .82rem; font-weight: 750; line-height: 1.3; }
.summary-value { display: block; margin-top: 3px; font-size: 2rem; font-weight: 900; line-height: 1; letter-spacing: -.05em; }
.summary-meta { display: block; margin-top: 8px; color: var(--muted); font-size: .76rem; }

.feed { display: grid; gap: 10px; }
.activity-card {
  display: grid; grid-template-columns: 50px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  width: 100%; min-height: 86px; border: 1px solid var(--line); border-radius: 18px; padding: 13px;
  color: var(--ink); text-align: left; background: var(--surface);
}
.activity-card.is-complete { opacity: .63; }
.activity-card.is-overdue { border-left: 4px solid var(--danger); }
.time-block { display: grid; place-items: center; align-self: stretch; border-radius: 13px; background: var(--soft); font-weight: 900; font-size: .88rem; }
.time-block.task { color: #3d3600; background: var(--yellow-soft); }
.activity-copy { min-width: 0; }
.activity-copy strong { display: block; font-size: 1rem; line-height: 1.25; }
.activity-copy span { display: block; margin-top: 5px; color: var(--muted); font-size: .82rem; line-height: 1.35; }
.activity-copy small { display: inline-block; margin-top: 8px; color: var(--muted); font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.chevron { color: #8a8e8c; font-size: 1.4rem; }

.status-chip { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 8px; font-size: .75rem; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; }
.status-chip.tbc { color: #684100; background: #fff0c9; }
.status-chip.tbd { color: #555; background: #e9e9e7; }
.status-chip.complete { color: #075b39; background: #dff5e9; }
.status-chip.high { color: #8d1712; background: #ffe5e2; }

.toolbar { display: flex; gap: 9px; margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.toolbar::-webkit-scrollbar { display: none; }
.filter-button { flex: 0 0 auto; min-height: 44px; border: 1px solid var(--line); border-radius: 999px; padding: 8px 13px; color: var(--muted); background: var(--surface); font-weight: 800; }
.filter-button.is-active { color: var(--ink); border-color: var(--ink); background: var(--yellow); }
.fab {
  position: fixed; z-index: 9; right: 18px; bottom: calc(86px + var(--safe-bottom)); width: 58px; height: 58px;
  border: 0; border-radius: 50%; color: var(--ink); background: var(--yellow); box-shadow: 0 10px 28px rgba(17, 19, 19, .25);
  font-size: 1.8rem; line-height: 1;
}

.search-box { position: relative; margin-bottom: 18px; }
.search-box input { min-height: 54px; padding-left: 47px; border-radius: 18px; font-size: 1.05rem; }
.search-box span { position: absolute; left: 17px; top: 15px; color: var(--muted); font-size: 1.25rem; }
.search-help { margin: -7px 2px 20px; color: var(--muted); font-size: .84rem; line-height: 1.45; }
.search-group { margin: 24px 0 10px; color: var(--muted); font-size: .75rem; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; }
.empty-state { padding: 35px 22px; border: 1px dashed #bbbdb9; border-radius: 20px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 7px; color: var(--ink); font-size: 1.08rem; }

.bottom-nav {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px 8px calc(8px + var(--safe-bottom)); border-top: 1px solid #303332; background: rgba(17, 19, 19, .98); backdrop-filter: blur(18px);
}
.nav-button { display: grid; place-items: center; gap: 3px; min-height: 56px; border: 0; border-radius: 13px; color: #aeb2b0; background: transparent; font-size: .875rem; font-weight: 800; }
.nav-icon { font-size: 1.35rem; line-height: 1; }
.nav-button.is-active { color: var(--yellow); background: #292c2b; }

.sheet-dialog { width: min(100%, 620px); max-height: 92svh; margin: auto 0 0; padding: 0; border: 0; border-radius: 26px 26px 0 0; background: var(--surface); color: var(--ink); }
.sheet-dialog::backdrop { background: rgba(5, 6, 6, .62); backdrop-filter: blur(3px); }
.sheet-form { display: grid; gap: 17px; max-height: 92svh; overflow-y: auto; padding: 10px 20px calc(24px + var(--safe-bottom)); }
.sheet-handle { width: 42px; height: 5px; margin: 0 auto 3px; border-radius: 99px; background: #d2d4d0; }
.sheet-heading { display: flex; align-items: start; justify-content: space-between; gap: 18px; }
.sheet-heading h2 { margin: 0; font-size: 1.45rem; letter-spacing: -.03em; }
.icon-button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: #fff; font-size: 1.5rem; line-height: 1; }
.form-grid { display: grid; gap: 12px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.choice-row { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: .95rem; }
.choice-row input { width: 22px; min-height: 22px; accent-color: var(--ink); }
.conditional-fields { display: grid; gap: 14px; padding: 15px; border-radius: 16px; background: var(--paper); }
.profile-card { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 18px; background: var(--paper); }
.profile-avatar { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; background: var(--yellow); font-weight: 900; }
.profile-card strong, .profile-card span { display: block; }
.profile-card span { margin-top: 4px; color: var(--muted); font-size: .83rem; overflow-wrap: anywhere; }
.settings-list { margin: 0; }
.settings-list div { display: flex; justify-content: space-between; gap: 18px; padding: 14px 2px; border-bottom: 1px solid var(--line); }
.settings-list dt { color: var(--muted); }
.settings-list dd { margin: 0; text-align: right; font-weight: 800; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: calc(98px + var(--safe-bottom)); transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 13px; color: #fff; background: var(--ink); box-shadow: var(--shadow); font-size: .88rem; font-weight: 750; }

@media (min-width: 700px) {
  .app-header { padding-left: max(22px, calc((100% - 760px) / 2)); padding-right: max(22px, calc((100% - 760px) / 2)); }
  .bottom-nav { left: 50%; right: auto; width: min(100%, 760px); transform: translateX(-50%); border: 1px solid #303332; border-bottom: 0; border-radius: 20px 20px 0 0; }
  .sheet-dialog { margin-left: auto; margin-right: auto; border-radius: 26px; }
}

@media (max-width: 370px) {
  .main-content { padding-left: 12px; padding-right: 12px; }
  .hero-actions { grid-template-columns: 1fr; }
  .summary-grid { gap: 8px; }
  .activity-card { grid-template-columns: 45px minmax(0, 1fr) auto; gap: 9px; padding: 11px; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .backup-actions { grid-template-columns: 1fr; }
}

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