/* Timeless - styles from the reference design (away_from_social.html), plus the login
   screen and account bits. One narrow pocket-notebook column. */
:root {
  --paper: #F1F4F6;
  --surface: #FFFFFF;
  --ink: #16202A;
  --muted: #586472;
  --line: #DAE0E6;
  --accent: #2246A3;
  --accent-soft: #E3E9F8;
  --on-accent: #FFFFFF;
  --done: #2B7655;
  --done-soft: #DDEFE5;
  --danger: #B3261E;
  --danger-soft: #F9E3E1;
  --display: 'Alegreya', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --body: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #11191D; --surface: #192328; --ink: #E6ECEF; --muted: #97A4AC; --line: #2A363C;
    --accent: #A4B9F4; --accent-soft: #212E4B; --on-accent: #0E1630;
    --done: #74C99E; --done-soft: #1B3328; --danger: #F2A39C; --danger-soft: #3A1F1D;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #11191D; --surface: #192328; --ink: #E6ECEF; --muted: #97A4AC; --line: #2A363C;
  --accent: #A4B9F4; --accent-soft: #212E4B; --on-accent: #0E1630;
  --done: #74C99E; --done-soft: #1B3328; --danger: #F2A39C; --danger-soft: #3A1F1D;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { background: var(--paper); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.55; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap {
  max-width: 680px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 24px 64px;
  display: flex; flex-direction: column; gap: 22px;
}

/* Header */
.top { display: flex; flex-direction: column; gap: 16px; }
.brand { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
h1 { font-family: var(--display); font-weight: 700; font-size: clamp(2rem, 7vw, 2.6rem); line-height: 1.05; letter-spacing: -0.01em; }
.today { color: var(--done); font-weight: 500; font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.tab { flex: 1 1 0; text-align: center; padding: 9px 6px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: 14px; line-height: 1.3; }
.tab:hover { color: var(--ink); }
.tab[aria-current="page"] { background: var(--ink); color: var(--paper); }
.status { padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); font-size: 14px; }

.view { display: flex; flex-direction: column; gap: 22px; }
.label { font-size: 12px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.hint { font-size: 14px; color: var(--muted); }
.empty { color: var(--muted); }
.empty a, .hint a { color: var(--accent); }

/* Buttons and chips */
.btn { padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 14px; line-height: 1.3; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { border-color: var(--accent); filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { color: var(--ink); border-color: var(--line); }
.btn-danger { color: var(--danger); background: transparent; }
.btn-danger.is-confirm { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 40px; height: 40px; padding: 0; font-size: 1.15rem; }
.btn-icon.btn-sm { width: 32px; height: 32px; font-size: 1rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 14px; line-height: 1.3; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip-n { font-size: 12px; font-variant-numeric: tabular-nums; opacity: 0.7; }
.chip-add { border-style: dashed; color: var(--muted); }
.chip-add:hover { color: var(--ink); }

/* Inputs */
.in { width: 100%; min-width: 0; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 15px; }
.in::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }
.in-num { width: 5rem; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.add { display: flex; gap: 8px; }
.add .in { flex: 1 1 auto; }
.add .in-num { flex: 0 0 5.5rem; }
.unit { color: var(--muted); font-size: 14px; }

/* Picker */
.picker { display: flex; flex-direction: column; gap: 14px; }
.group { display: flex; flex-direction: column; gap: 8px; }

/* Running timer */
.running { background: var(--surface); border: 1.5px solid var(--done); border-radius: 16px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.run-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.clock { font-family: var(--display); font-size: 2rem; line-height: 1; color: var(--done); font-variant-numeric: tabular-nums; }
.run-title { font-family: var(--display); font-weight: 700; font-size: 1.35rem; line-height: 1.25; overflow-wrap: anywhere; }
.run-meta { font-size: 13px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Banner */
.banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 14px 16px; border-radius: 14px; background: var(--done-soft); }
.banner p { flex: 1 1 260px; min-width: 0; }

/* Lists */
.pair { display: flex; flex-direction: column; gap: 12px; }
.pair-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
h2 { font-family: var(--display); font-weight: 700; font-size: 1.4rem; line-height: 1.2; }
h3 { font-family: var(--display); font-weight: 700; font-size: 1.15rem; line-height: 1.25; }
.count-note { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; }
.row + .row { border-top: 1px solid var(--line); }
.row-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { font-weight: 600; overflow-wrap: anywhere; }
.row-detail { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; white-space: pre-wrap; }
.row-meta { font-size: 12.5px; color: var(--muted); }
.row-tools { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.row.editing { background: var(--accent-soft); }
.edit-form { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.edit-form .row-tools { flex-wrap: wrap; }
.empty-box { padding: 16px; border: 1px dashed var(--line); border-radius: 14px; display: flex; flex-direction: column; gap: 12px; }

/* Week */
.wk-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wk-range { text-align: center; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wk-hero { display: flex; flex-direction: column; gap: 6px; padding-block: 4px; }
.wk-total { font-family: var(--display); font-weight: 700; font-size: clamp(2.4rem, 11vw, 3.4rem); line-height: 1; color: var(--done); font-variant-numeric: tabular-nums; }
.wk-total.is-zero { color: var(--muted); }
.wk-sub { color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 10px 0 0; }
.facts div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.trend { font-size: 14px; margin-top: 4px; }
.card { display: flex; flex-direction: column; gap: 12px; }
.daybars { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 10px 10px; }
.dcol { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.dval { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--ink); }
.dtrack { width: 100%; max-width: 34px; height: 120px; display: flex; align-items: flex-end; border-radius: 6px; background: repeating-linear-gradient(to top, var(--line) 0 1px, transparent 1px 30px); }
.dbar { width: 100%; background: var(--accent); border-radius: 6px 6px 2px 2px; }
.dname { font-size: 12.5px; font-weight: 600; }
.ddate { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dcol.is-today .dname { color: var(--done); }
.dcol.is-today .dbar { background: var(--done); }
.dcol.is-future .dval, .dcol.is-future .dname { color: var(--muted); }
.hbars { list-style: none; margin: 0; padding: 14px; display: flex; flex-direction: column; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.hb-top { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.hb-label { min-width: 0; overflow-wrap: anywhere; }
.hb-val { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hb-track { display: block; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 4px; }
.hb-bar { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.log-day { display: flex; flex-direction: column; gap: 8px; }
.log-day + .log-day { margin-top: 6px; }
.log-day-head { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; font-weight: 600; }
.log-day-head span:last-child { color: var(--done); font-variant-numeric: tabular-nums; }
.log-time { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 2px; width: 3rem; flex: 0 0 auto; }
.wk-list { list-style: none; margin: 0; padding: 6px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.wk-item { width: 100%; display: grid; grid-template-columns: 7.5rem minmax(0, 1fr) 3.5rem; align-items: center; gap: 10px; padding: 8px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; text-align: left; font-size: 14px; }
.wk-item:hover { background: var(--paper); }
.wk-item[aria-pressed="true"] { background: var(--accent-soft); }
.wk-item .hb-track { margin: 0; }
.wk-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* Setup */
.srow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; }
.srow + .srow { border-top: 1px solid var(--line); }
.srow .in-label { flex: 1 1 11rem; }
.srow .mins { display: flex; align-items: center; gap: 6px; }
.srow .row-tools { margin-left: auto; }
.data-note { font-size: 14px; color: var(--muted); max-width: 62ch; display: flex; flex-direction: column; gap: 6px; }

/* Sheet */
.backdrop { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; background: color-mix(in srgb, var(--ink) 45%, transparent); }
.sheet {
  width: 100%; max-width: 540px; max-height: 92%; overflow: auto; background: var(--surface);
  border-radius: 18px 18px 0 0; display: flex; flex-direction: column; gap: 16px;
  padding-left: max(18px, env(safe-area-inset-left, 0px));
  padding-right: max(18px, env(safe-area-inset-right, 0px));
  padding-block: 20px calc(20px + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 640px) {
  .backdrop { align-items: center; }
  .sheet { border-radius: 18px; padding-block: 24px; }
}
.sheet-head { display: flex; flex-direction: column; gap: 4px; }
.sheet-head h2 { overflow-wrap: anywhere; }
.sheet-meta { font-size: 13px; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > label { font-weight: 600; font-size: 14px; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper .in { width: 6rem; text-align: center; font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
textarea.in { resize: vertical; min-height: 5.5rem; line-height: 1.5; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sheet-actions .btn-danger { margin-left: auto; }

.toast {
  position: fixed; z-index: 30; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 10px;
  background: var(--ink); color: var(--paper); font-size: 14px; transition: opacity 160ms, transform 160ms;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
@media (max-width: 420px) {
  .facts { grid-template-columns: 1fr 1fr; }
  .facts div:last-child { grid-column: span 2; }
  .wk-item { grid-template-columns: 6.5rem minmax(0, 1fr) 3.2rem; }
}

/* Base (the reference had these on its own page shell) */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; }
img { max-width: 100%; }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 28px 22px; }
.login-card .field { gap: 6px; }
.login-card .btn { margin-top: 4px; }
.tagline { color: var(--muted); }
.form-error { color: var(--danger); background: var(--danger-soft); border-radius: 10px; padding: 8px 12px; font-size: 14px; }

/* Account (bottom of Thiết lập) */
.account { display: flex; flex-direction: column; gap: 10px; }
.account .field { gap: 6px; }
.account-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
