@font-face { font-family: Poppins; src: url('/fonts/poppins-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Poppins; src: url('/fonts/poppins-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: Poppins; src: url('/fonts/poppins-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }

:root {
  --ink: #252822; --muted: #767a70; --line: #e6e3dc; --paper: #fff;
  --canvas: #f6f4ef; --accent: #39453a; --accent-soft: #e8eee7;
  --danger: #9d3b37; --high: #b74942; --medium: #a77820; --low: #477456;
  font-family: Poppins, system-ui, sans-serif; color: var(--ink); background: var(--canvas);
}
* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { font-size: 14px; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.button { min-height: 42px; border: 1px solid transparent; border-radius: 9px; padding: 9px 15px; font-weight: 500; cursor: pointer; }
.button:disabled { opacity: .55; cursor: wait; }
.button-primary { color: #fff; background: var(--accent); }
.button-secondary { border-color: var(--line); background: #f4f3ef; }
.button-quiet { margin-right: auto; background: transparent; }
.button-danger { color: var(--danger); }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; font-size: 20px; }
.icon-button:hover { background: #efede8; }
label { display: block; margin: 16px 0 7px; color: #555a50; font-size: 12px; font-weight: 500; }
label span { color: #9a9d95; font-weight: 400; }
input, textarea, select { width: 100%; border: 1px solid #d8d5ce; border-radius: 9px; padding: 11px 12px; color: var(--ink); background: #fff; outline: none; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { border-color: #879287; box-shadow: 0 0 0 3px rgba(75,91,76,.11); }

.login-page { display: grid; min-height: 100dvh; place-items: center; padding: 24px; background: #ebe8e0; }
.login-card { width: min(760px, 100%); overflow: hidden; border: 1px solid rgba(49,51,46,.1); border-radius: 18px; background: var(--paper); box-shadow: 0 24px 70px rgba(54,50,42,.12); }
.login-banner { display: block; width: 100%; height: 230px; object-fit: cover; }
.login-content { position: relative; padding: 38px 44px 44px; }
.login-avatar { position: absolute; top: -34px; right: 42px; width: 68px; height: 68px; border: 4px solid #fff; border-radius: 50%; object-fit: cover; }
.login-content h1 { margin: 0; font-size: 30px; letter-spacing: -.04em; }
.login-copy { margin: 8px 0 24px; color: var(--muted); }
.password-row { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
.form-error { min-height: 20px; margin: 10px 0 0; color: var(--danger); font-size: 12px; }

.app-page { background: var(--canvas); }
.app-header { position: sticky; top: 0; z-index: 20; display: flex; height: 68px; align-items: center; justify-content: space-between; padding: 0 max(24px, calc((100vw - 1180px)/2)); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.brand span { letter-spacing: -.02em; }
.header-actions { display: flex; align-items: center; gap: 14px; }
.sync-state { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.sync-state i { width: 7px; height: 7px; border-radius: 50%; background: #b8a444; }
.sync-state.online i { background: #4f8b5d; }
.sync-state.offline i { background: var(--danger); }
.app-shell { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 45px 0 90px; }
.welcome-row { display: flex; align-items: end; justify-content: space-between; margin-bottom: 26px; }
.welcome-row h1 { margin: 0; font-size: clamp(26px, 4vw, 38px); letter-spacing: -.05em; }
.add-top span { margin-right: 4px; }
.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 150px)); gap: 10px; margin-bottom: 35px; }
.summary button { display: flex; align-items: baseline; gap: 8px; border: 1px solid var(--line); border-radius: 9px; padding: 11px 13px; background: rgba(255,255,255,.66); cursor: pointer; text-align: left; }
.summary strong { font-size: 19px; }
.summary span { color: var(--muted); font-size: 11px; }
.group { margin-bottom: 32px; scroll-margin-top: 90px; }
.group-header { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; padding: 0 4px; }
.group-header button { display: flex; align-items: center; gap: 9px; flex: 1; border: 0; padding: 0; background: transparent; cursor: pointer; text-align: left; }
.open-sort { display: flex; align-items: center; gap: 7px; margin: 0 0 0 12px; color: var(--muted); font-size: 10px; font-weight: 400; white-space: nowrap; }
.open-sort select { width: auto; min-height: 32px; margin: 0; padding: 5px 27px 5px 8px; border-radius: 7px; font-size: 11px; }
.group-chevron { color: #9a9e95; transition: transform .15s; }
.group.collapsed .group-chevron { transform: rotate(-90deg); }
.group-title { font-size: 13px; font-weight: 600; }
.group-count { color: var(--muted); font-size: 11px; }
.group-rule { height: 1px; flex: 1; background: var(--line); }
.todo-list { display: grid; gap: 7px; }
.group.collapsed .todo-list { display: none; }
.category-heading { display: flex; align-items: center; gap: 7px; margin: 9px 2px 1px; color: #686d64; font-size: 11px; font-weight: 600; }
.category-heading:first-child { margin-top: 1px; }
.category-heading span { display: grid; min-width: 18px; height: 18px; place-items: center; border-radius: 999px; color: var(--muted); background: #ecebe7; font-size: 9px; }
.todo-card { display: grid; grid-template-columns: 26px minmax(220px, 1fr) 130px 120px 130px 72px; min-height: 60px; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px 9px 14px; background: var(--paper); box-shadow: 0 1px 1px rgba(35,39,32,.02); }
.todo-card:hover { border-color: #d5d1c8; box-shadow: 0 3px 12px rgba(35,39,32,.05); }
.complete-button { display: grid; width: 22px; height: 22px; place-items: center; border: 1.5px solid #b8bbb3; border-radius: 7px; background: #fff; cursor: pointer; font-size: 13px; }
.status-closed .complete-button { border-color: var(--accent); color: white; background: var(--accent); }
.todo-title { min-width: 0; }
.todo-title button { overflow: hidden; max-width: 100%; border: 0; padding: 2px 0; background: transparent; cursor: pointer; font-weight: 500; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.status-closed .todo-title button, .status-never-doing .todo-title button { color: #8c9087; text-decoration: line-through; }
.todo-meta { display: flex; gap: 8px; margin-top: 4px; color: var(--muted); font-size: 10px; }
.todo-category { color: #555b52; font-weight: 500; }
.priority { justify-self: start; border-radius: 999px; padding: 5px 9px; font-size: 10px; font-weight: 600; }
.priority-none { color: #74776f; background: #efefec; }
.priority-low { color: #376547; background: #e6f1e8; }
.priority-medium { color: #866018; background: #f6eedb; }
.priority-high { color: #963c36; background: #f7e4e2; }
.deadline { color: var(--muted); font-size: 11px; }
.deadline.due { color: #8e681d; font-weight: 500; }
.deadline.overdue { color: var(--danger); font-weight: 600; }
.status-chip { justify-self: start; border-radius: 6px; padding: 5px 8px; color: #596057; background: #eeefeb; font-size: 10px; }
.card-actions { display: flex; align-items: center; justify-content: flex-end; }
.card-more, .card-delete { width: 34px; height: 34px; border: 0; border-radius: 8px; color: #777b72; background: transparent; cursor: pointer; }
.card-more:hover { background: #f1f0ec; }
.card-delete { color: #a66a66; font-size: 20px; }
.card-delete:hover { color: var(--danger); background: #fbefed; }
.card-delete:disabled { opacity: .45; cursor: wait; }
.empty-group { border: 1px dashed #d9d6cf; border-radius: 10px; padding: 18px; color: var(--muted); font-size: 12px; text-align: center; }
.mobile-add { display: none; }

.scrim { position: fixed; z-index: 30; inset: 0; visibility: hidden; background: rgba(25,27,24,.25); opacity: 0; transition: .18s; }
.scrim.open { visibility: visible; opacity: 1; }
.drawer { position: fixed; z-index: 40; top: 0; right: 0; width: min(470px, 100%); height: 100dvh; overflow-y: auto; padding: 28px 30px 50px; border-left: 1px solid var(--line); background: #fff; box-shadow: -15px 0 45px rgba(35,39,32,.1); transform: translateX(104%); transition: transform .22s ease; }
.drawer.open { transform: translateX(0); }
.drawer-handle { display: none; }
.drawer-header { display: flex; align-items: center; justify-content: space-between; }
.drawer-header .eyebrow { margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.category-input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.category-input-row select { margin: 0; }
.category-input-row .button { min-height: 43px; white-space: nowrap; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.notes-section { margin-top: 36px; padding-top: 25px; border-top: 1px solid var(--line); }
.section-heading { display: flex; align-items: center; gap: 8px; }
.section-heading h2 { margin: 0; font-size: 15px; }
.section-heading span { display: grid; min-width: 20px; height: 20px; place-items: center; border-radius: 50%; color: var(--muted); background: #efefec; font-size: 10px; }
#note-form { display: grid; gap: 8px; margin: 12px 0 20px; }
#note-form textarea { margin: 0; }
#note-form button { justify-self: end; }
.notes-list { display: grid; gap: 10px; }
.note { border: 1px solid var(--line); border-radius: 9px; padding: 12px; background: #faf9f6; }
.note p { margin: 0; white-space: pre-wrap; word-break: break-word; line-height: 1.55; }
.note footer { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; color: var(--muted); font-size: 10px; }
.note-actions button { border: 0; padding: 3px 5px; color: var(--muted); background: transparent; cursor: pointer; font-size: 10px; }
.toast { position: fixed; z-index: 60; right: 22px; bottom: 22px; visibility: hidden; border-radius: 9px; padding: 11px 15px; color: #fff; background: #31362f; opacity: 0; transform: translateY(8px); transition: .18s; font-size: 12px; }
.toast.show { visibility: visible; opacity: 1; transform: none; }

@media (max-width: 820px) {
  .todo-card { grid-template-columns: 26px minmax(180px, 1fr) 100px 100px 72px; }
  .status-chip { display: none; }
}
@media (max-width: 620px) {
  .app-header { height: calc(60px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 16px 0; }
  .brand img { width: 32px; height: 32px; }
  .sync-state span { display: none; }
  .app-shell { width: 100%; padding: 25px 14px calc(95px + env(safe-area-inset-bottom)); }
  .welcome-row { align-items: start; margin-bottom: 18px; }
  .welcome-row h1 { font-size: 27px; }
  .add-top { display: none; }
  .summary { grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 28px; }
  .summary button { display: grid; gap: 0; padding: 9px 10px; }
  .summary strong { font-size: 18px; }
  .group { margin-bottom: 25px; scroll-margin-top: 75px; }
  .open-sort { margin-left: 4px; }
  .todo-card { position: relative; grid-template-columns: 28px minmax(0, 1fr) 68px; gap: 8px; min-height: 82px; padding: 12px 9px 11px 12px; }
  .todo-title { grid-column: 2; }
  .todo-title button { white-space: normal; line-height: 1.4; }
  .priority { grid-column: 2; grid-row: 2; }
  .deadline { grid-column: 2; grid-row: 2; justify-self: end; }
  .status-chip { display: none; }
  .card-actions { grid-column: 3; grid-row: 1; align-self: start; }
  .category-input-row { grid-template-columns: 1fr; }
  .mobile-add { position: fixed; z-index: 25; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); display: grid; width: 58px; height: 58px; place-items: center; border: 0; border-radius: 50%; color: #fff; background: var(--accent); box-shadow: 0 8px 24px rgba(36,43,36,.25); font-size: 25px; }
  .drawer { top: auto; bottom: 0; width: 100%; height: min(86dvh, 760px); padding: 20px 17px calc(28px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); border-left: 0; border-radius: 16px 16px 0 0; transform: translateY(104%); }
  .drawer.open { transform: none; }
  .drawer-handle { display: block; width: 42px; height: 4px; margin: -9px auto 13px; border-radius: 4px; background: #d5d3cc; }
  .toast { right: 14px; bottom: calc(88px + env(safe-area-inset-bottom)); left: 14px; text-align: center; }
  .login-page { padding: 14px; }
  .login-banner { height: 170px; }
  .login-content { padding: 32px 22px 28px; }
  .login-avatar { top: -29px; right: 20px; width: 58px; height: 58px; }
  .password-row { grid-template-columns: 1fr; }
}
