/* Phone first. This gets opened standing in a kitchen, not sitting at a desk —
   so: big tap targets, one column, nothing that needs a hover to discover. */

:root {
    --bg:        #f7f6f3;
    --card:      #ffffff;
    --ink:       #1c1b19;
    --muted:     #6b6862;
    --faint:     #a5a29b;
    --line:      #e4e1db;
    --accent:    #2f6f4f;
    --accent-in: #ffffff;
    --late:      #b3452b;
    --late-bg:   #fbecE7;
    --warn:      #8a6a1f;
    --radius:    12px;
    --pad:       16px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:      #17181a;
        --card:    #202225;
        --ink:     #e9e7e3;
        --muted:   #9b9791;
        --faint:   #6d6a65;
        --line:    #32353a;
        --accent:  #6bbf94;
        --accent-in: #10261c;
        --late:    #e8836a;
        --late-bg: #38221c;
        --warn:    #d8b45c;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0 0 80px;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 720px; margin: 0 auto; padding: 0 var(--pad); }

/* ---------------------------------------------------------------- header */

header.top {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    padding: 14px 0 0;
    position: sticky;
    top: 0;
    z-index: 20;
}
header.top h1 {
    margin: 0 0 2px;
    font-size: 21px;
    font-weight: 650;
    letter-spacing: -0.01em;
}
header.top .sub { color: var(--muted); font-size: 13px; margin-bottom: 10px; }

nav.tabs { display: flex; gap: 2px; overflow-x: auto; }
nav.tabs a {
    padding: 9px 13px;
    font-size: 14px;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}
nav.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
nav.tabs a:hover { text-decoration: none; color: var(--ink); }

.badge {
    display: inline-block;
    min-width: 18px;
    padding: 1px 5px;
    margin-left: 4px;
    border-radius: 9px;
    background: var(--accent);
    color: var(--accent-in);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    line-height: 16px;
}
.badge.hot { background: var(--late); color: #fff; }

/* --------------------------------------------------------------- sections */

section { margin: 22px 0; }
section > h2 {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--faint);
    display: flex;
    align-items: baseline;
    gap: 8px;
}
section > h2 .n { color: var(--faint); font-weight: 500; letter-spacing: 0; }
section.alarm > h2 { color: var(--late); }

/* No overflow:hidden here — it would clip the row-action popover. Corners are
   rounded on the first/last child instead, so a tinted overdue row still sits
   flush inside the card. */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.card > :first-child,
.card > :first-child > :first-child {
    border-top-left-radius: calc(var(--radius) - 1px);
    border-top-right-radius: calc(var(--radius) - 1px);
}
.card > :last-child,
.card > :last-child > :last-child {
    border-bottom-left-radius: calc(var(--radius) - 1px);
    border-bottom-right-radius: calc(var(--radius) - 1px);
}

.empty {
    padding: 18px;
    color: var(--faint);
    font-size: 14px;
    text-align: center;
}

/* ----------------------------------------------------------------- items */

.item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: none; }
.item.late { background: var(--late-bg); }

/* The tick box is a whole form so it works with no JS at all. */
.tick button {
    width: 26px;
    height: 26px;
    margin-top: 1px;
    border: 1.5px solid var(--faint);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    padding: 0;
    color: transparent;
    font-size: 15px;
    line-height: 1;
    transition: background .12s, border-color .12s;
}
.tick button:hover { border-color: var(--accent); background: var(--accent); color: var(--accent-in); }
.tick button.undo { border-color: var(--accent); background: var(--accent); color: var(--accent-in); }

.item .body { flex: 1; min-width: 0; }
.item .title { display: block; color: var(--ink); font-weight: 500; }
.item.done .title { color: var(--muted); text-decoration: line-through; }
.item .meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 3px;
    font-size: 12.5px;
    color: var(--muted);
}
.item .meta .late-txt { color: var(--late); font-weight: 600; }
.item .meta .warn { color: var(--warn); font-weight: 600; }
.item .notes { margin-top: 4px; font-size: 13px; color: var(--muted); }

.chip {
    display: inline-block;
    padding: 1px 7px;
    border: 1px solid var(--line);
    border-radius: 20px;
    font-size: 11.5px;
    color: var(--muted);
    background: var(--bg);
}

/* Row actions live in a native <details> popover — no JS, closes on second tap. */
.more { position: relative; flex: 0 0 auto; }
.more > summary {
    list-style: none;
    cursor: pointer;
    color: var(--faint);
    padding: 2px 8px;
    font-size: 19px;
    line-height: 1.2;
    user-select: none;
    border-radius: 6px;
}
.more > summary::-webkit-details-marker { display: none; }
.more[open] > summary { color: var(--ink); background: var(--bg); }
.drawer {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 10;
    width: max-content;
    max-width: 78vw;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 10px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
}
.drawer-label {
    font-size: 11px;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--faint);
}
.drawer form { display: flex; gap: 6px; }
.drawer form > button { flex: 1; }
.drawer .btn { text-align: center; }

/* --------------------------------------------------------------- events */

.event {
    display: flex;
    gap: 12px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    align-items: baseline;
}
.event:last-child { border-bottom: none; }
.event .when {
    flex: 0 0 74px;
    font-variant-numeric: tabular-nums;
    font-size: 13.5px;
    color: var(--muted);
    font-weight: 600;
}
.event .what { flex: 1; min-width: 0; }
.event .where { font-size: 12.5px; color: var(--faint); }

/* --------------------------------------------------------------- controls */

button, .btn {
    font: inherit;
    font-size: 13.5px;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card);
    color: var(--ink);
    cursor: pointer;
}
button:hover, .btn:hover { border-color: var(--faint); text-decoration: none; }
button:disabled, button:disabled:hover {
    opacity: .45;
    cursor: not-allowed;
    border-color: var(--line);
}
button.primary, .btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-in);
    font-weight: 600;
}
button.danger { color: var(--late); }
button.link {
    border: none; background: none; padding: 4px 2px; color: var(--accent);
}

input[type=text], input[type=date], input[type=time], input[type=number],
input[type=password], textarea, select {
    font: inherit;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card);
    color: var(--ink);
}
input:focus, textarea:focus, select:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: var(--accent);
}
textarea { min-height: 70px; resize: vertical; }
label { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 120px; }
.row.tight > * { flex: 0 0 auto; min-width: 0; }

/* The add box: one line, always at the top, always the same place. */
.add {
    display: flex;
    gap: 8px;
    margin: 18px 0 4px;
}
.add input[type=text] { flex: 1; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 0; }
.quick button { font-size: 12.5px; padding: 5px 10px; border-radius: 20px; }
.quick button.sel { background: var(--accent); border-color: var(--accent); color: var(--accent-in); }

details.fold > summary {
    cursor: pointer;
    font-size: 13.5px;
    color: var(--muted);
    padding: 8px 0;
    user-select: none;
}
details.fold[open] > summary { color: var(--ink); font-weight: 600; }

.flash {
    margin: 14px 0 0;
    padding: 11px 14px;
    background: var(--card);
    border: 1px solid var(--accent);
    border-left-width: 3px;
    border-radius: 8px;
    font-size: 14px;
}

.note { font-size: 13px; color: var(--muted); }
.pad { padding: 14px; }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }

/* Suggestions read as proposals, not tasks — a dashed edge says "not yet real". */
.sugg {
    border-bottom: 1px solid var(--line);
    padding: 14px;
}
.sugg:last-child { border-bottom: none; }
.sugg .why {
    margin: 6px 0 10px;
    padding-left: 10px;
    border-left: 2px dashed var(--faint);
    font-size: 13px;
    color: var(--muted);
}
.sugg .src { font-size: 12px; color: var(--faint); }

table.log { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.log td { padding: 8px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.log td.at { color: var(--faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
table.log td.kind { color: var(--muted); }

@media (min-width: 620px) {
    .drawer { padding-left: 52px; }
}
