:root {
    --bg: #0f172a;
    --bg2: #111c33;
    --card: rgba(255, 255, 255, .06);
    --line: rgba(255, 255, 255, .14);
    --ink: #f1f5f9;
    --muted: #a5b4c8;
    --accent: #34d399;
    --accent-ink: #052e1f;
    --danger: #fda4af;
    --warn: #fcd34d;
    color-scheme: dark;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #f4f6fb;
        --bg2: #e9eef8;
        --card: #ffffff;
        --line: #d6dded;
        --ink: #14213d;
        --muted: #55637d;
        --accent: #047857;
        --accent-ink: #ffffff;
        --danger: #be123c;
        --warn: #a16207;
        color-scheme: light;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    padding: clamp(1rem, 4vw, 2.5rem) 1rem 5rem;
    display: flex;
    justify-content: center;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: linear-gradient(180deg, var(--bg), var(--bg2)) fixed;
    touch-action: manipulation;
}

.page { width: min(640px, 100%); }
.app { width: min(560px, 100%); margin: 0 auto; }

header { text-align: center; margin-bottom: 1.2rem; }
h1 { margin: 0; font-size: 1.9rem; letter-spacing: -.02em; }
.sub { margin: .35rem 0 .7rem; color: var(--muted); font-size: 1rem; font-weight: 400; line-height: 1.45; }
.pill { display: inline-block; margin: 0; padding: .2rem .7rem; border-radius: 999px; font-size: .8rem; border: 1px solid var(--line); color: var(--muted); }
.pill.ok { color: var(--accent); border-color: var(--accent); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input[type="text"], input[type="search"], input[type="date"], select {
    width: 100%;
    min-width: 0;
    height: 46px;
    padding: 0 .85rem;
    font-size: 1rem;              /* 16px stops iPhone from zooming in on focus */
    line-height: 1.2;
    border-radius: 12px;
    border: 1px solid var(--line);
    background-color: var(--card);
    -webkit-appearance: none;     /* every browser draws these differently; make them identical */
    appearance: none;
}
select {
    padding-right: 2.2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .85rem center;
}
input[type="date"] { display: flex; align-items: center; text-align: left; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; min-height: 1.2em; margin: 0; }
input[type="date"]::-webkit-datetime-edit { padding: 0; flex: 1; line-height: 1.2; }
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
input::placeholder { color: var(--muted); }

.warning { padding: .7rem .9rem; border-radius: 12px; border: 1px solid var(--warn); color: var(--warn); font-size: .92rem; }

.add { display: grid; gap: .6rem; margin-bottom: 1rem; }
.add-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: .6rem; align-items: end; }
.add-row > * { min-width: 0; }
.field { display: grid; gap: .3rem; min-width: 0; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.field input, .field select { text-transform: none; letter-spacing: 0; font-size: .95rem; color: var(--ink); }

button.primary { height: 46px; padding: 0 1.3rem; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; }
button.primary:hover { filter: brightness(1.08); }

.toolbar { display: flex; gap: .6rem; align-items: center; margin-bottom: .8rem; }
.toolbar input { max-width: 190px; margin-left: auto; height: 40px; padding: 0 .8rem; }
.chips { display: flex; gap: .35rem; }
.chips button { padding: .4rem .85rem; border-radius: 999px; border: 1px solid var(--line); background: transparent; cursor: pointer; font-size: .9rem; }
.chips button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

.list { margin: 0; padding: 0; list-style: none; display: grid; gap: .5rem; }
.task {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: .7rem;
    align-items: center;
    padding: .7rem .8rem;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--card);
    border-left: 4px solid var(--line);
}
.task.p2 { border-left-color: var(--danger); }
.task.p0 { border-left-color: var(--muted); }
.task.dragging { opacity: .45; }
.task input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); cursor: pointer; }
.task .body { min-width: 0; }
.task .text { overflow-wrap: anywhere; }
.task.done .text { text-decoration: line-through; color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .2rem; font-size: .78rem; }
.tag { padding: .05rem .5rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.tag.overdue { color: var(--danger); border-color: var(--danger); }
.tag.today { color: var(--warn); border-color: var(--warn); }
.tag.high { color: var(--danger); border-color: var(--danger); }
.task.done .tag { opacity: .6; }
.edit-input { width: 100%; height: 40px; padding: 0 .6rem; }

.actions { display: flex; gap: .15rem; }
.actions button { width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 1rem; }
.actions button:hover { background: var(--line); color: var(--ink); }
.actions button:disabled { opacity: .3; cursor: default; background: transparent; }

.empty { margin: 1.5rem 0; text-align: center; color: var(--muted); }

.summary { display: flex; justify-content: space-between; align-items: center; margin: 1rem .2rem .6rem; color: var(--muted); font-size: .92rem; }
button.link { border: 0; background: none; color: var(--accent); cursor: pointer; text-decoration: underline; padding: .2rem; }
button.link:disabled { color: var(--muted); text-decoration: none; cursor: default; opacity: .6; }

.backup { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; margin-top: .6rem; }
.backup button { padding: .5rem 1rem; border-radius: 10px; border: 1px solid var(--line); background: transparent; cursor: pointer; font-size: .9rem; }
.backup button:hover { background: var(--card); }

.toast {
    position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
    display: flex; gap: .8rem; align-items: center;
    padding: .7rem 1rem; border-radius: 12px;
    background: var(--ink); color: var(--bg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
    max-width: calc(100% - 2rem);
}
.toast[hidden] { display: none; }
.toast button.link { color: var(--bg); font-weight: 700; }

.info { margin-top: 3.5rem; padding-top: 2rem; border-top: 1px solid var(--line); }
.info h2 { margin: 0 0 1rem; font-size: 1.25rem; letter-spacing: -.01em; }
.info h2:not(:first-child) { margin-top: 2.2rem; }
.uses { margin: 0; padding: 0; list-style: none; display: grid; gap: .7rem; }
.uses li { padding: .9rem 1rem; border-radius: 14px; background: var(--card); border: 1px solid var(--line); color: var(--muted); line-height: 1.5; }
.uses strong { display: block; color: var(--ink); margin-bottom: .15rem; }
.faq details { border-bottom: 1px solid var(--line); padding: .9rem 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { margin: .6rem 0 0; color: var(--muted); line-height: 1.6; }

footer { margin-top: 2rem; text-align: center; font-size: .82rem; }
footer a { color: var(--muted); }

@media (max-width: 440px) {
    .add-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .add-row .primary { grid-column: 1 / -1; }
    .toolbar { flex-wrap: wrap; }
    .toolbar input { max-width: none; margin-left: 0; flex: 1 1 100%; }
    .actions button { width: 30px; }
}

.summary-actions { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: flex-end; }

/* back to the list of all apps */
.back { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; margin: 0 0 .5rem; padding: 0 1rem 0 .8rem; border: 1px solid var(--line, rgba(127,127,127,.4)); border-radius: 999px; color: var(--muted, var(--mut, inherit)); font-size: .92rem; font-weight: 600; text-decoration: none; background: transparent; }
.back:hover { color: var(--ink, inherit); border-color: currentColor; }
.back:focus-visible { outline: 3px solid var(--accent, var(--acc, #fff)); outline-offset: 2px; }
@media print { .back { display: none; } }

/* light / dark switch (theme.js sets data-theme); without it the device setting decides */
:root[data-theme="light"] {
        --bg: #f4f6fb;
        --bg2: #e9eef8;
        --card: #ffffff;
        --line: #d6dded;
        --ink: #14213d;
        --muted: #55637d;
        --accent: #047857;
        --accent-ink: #ffffff;
        --danger: #be123c;
        --warn: #a16207;
        color-scheme: light;
    }
:root[data-theme="dark"] {
    --bg: #0f172a;
    --bg2: #111c33;
    --card: rgba(255, 255, 255, .06);
    --line: rgba(255, 255, 255, .14);
    --ink: #f1f5f9;
    --muted: #a5b4c8;
    --accent: #34d399;
    --accent-ink: #052e1f;
    --danger: #fda4af;
    --warn: #fcd34d;
    color-scheme: dark;
}

/* laptops and desktops: two columns instead of one phone-sized column */
@media (min-width: 900px) {
    .page { width: min(1120px, 100%); display: grid; grid-template-columns: minmax(0, 1fr) 340px; column-gap: 2.5rem; align-items: start; }
    .page > * { grid-column: 1 / -1; }
    .page > .app { grid-column: 1; width: 100%; margin: 0; }
    .page > .info { grid-column: 2; margin-top: 0; padding-top: 0; border-top: 0; }
    .info h2 { font-size: 1.1rem; }
    header h1 { font-size: 2.3rem; }
    .list { min-height: 12rem; }
}
