/* ==========================================================================
   1. VARIABLES & THEMING (LIGHT & DARK MODE)
   - Atur warna dasar, font, dan tema di sini.
   ========================================================================== */
:root {
    --bg: #f3f6f9;
    --surface: #ffffff;
    --ink: #0f1b2d;
    --muted: #5b6b80;
    --line: #d9e0e8;
    --accent: #0b7a96;
    --accent-ink: #ffffff;
    --red: #c4281c;
    --amber: #a85d00;
    --green: #237a3b;
    --head: #0f1b2d;
    --head-ink: #e9f0f7;
    --head-muted: #8fa3ba;
    --glow: #2fe0b8;
    --seg-off: #25364f;
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme:dark) {
    :root:not([data-theme="light"]) {
        --bg: #0a111d;
        --surface: #111b2b;
        --ink: #e6edf5;
        --muted: #8fa0b5;
        --line: #22314a;
        --accent: #4cc9e4;
        --accent-ink: #06202a;
        --red: #ff7b6e;
        --amber: #f0a04b;
        --green: #5fd48a;
        --head: #0d1626;
    }
}

:root[data-theme="dark"] {
    --bg: #0a111d;
    --surface: #111b2b;
    --ink: #e6edf5;
    --muted: #8fa0b5;
    --line: #22314a;
    --accent: #4cc9e4;
    --accent-ink: #06202a;
    --red: #ff7b6e;
    --amber: #f0a04b;
    --green: #5fd48a;
    --head: #0d1626;
}

/* ==========================================================================
   2. RESET BASE & TYPOGRAPHY
   ========================================================================== */
html {
    scroll-padding-top: env(safe-area-inset-top, 0px)
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
    line-height: 1.45
}

.mono {
    font-family: "IBM Plex Mono", ui-monospace, Consolas, monospace
}

/* ==========================================================================
   3. HEADER & PROGRESS BAR
   ========================================================================== */
header {
    background: var(--head);
    color: var(--head-ink);
    padding: 28px 20px 26px
}

.head-in {
    max-width: 720px;
    margin: 0 auto
}

.today {
    font-size: .8rem;
    color: var(--glow);
    margin: 0 0 6px
}

h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -.01em
}

.prog {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 20px
}

.segs {
    display: grid;
    grid-template-columns: repeat(20, 1fr);
    gap: 3px;
    flex: 1
}

.segs i {
    height: 14px;
    background: var(--seg-off);
    border-radius: 1px
}

.segs i.on {
    background: var(--glow)
}

.prog-txt {
    font-size: .9rem;
    color: var(--head-ink);
    white-space: nowrap
}

.sub {
    margin: 8px 0 0;
    color: var(--head-muted);
    font-size: .9rem
}

/* ==========================================================================
   4. FORM INPUT & TABS FILTER
   ========================================================================== */
main {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 20px 64px
}

form {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 18px;
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 28px
}

form .full {
    grid-column: 1/-1
}

label {
    display: grid;
    gap: 5px;
    font-size: .85rem;
    font-weight: 600
}

input[type=text],
input[type=date],
select {
    font: inherit;
    font-weight: 400;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--bg);
    color: var(--ink);
    width: 100%;
    min-width: 0
}

input:focus,
select:focus {
    border-color: var(--accent)
}

button {
    font: inherit;
    cursor: pointer
}

.add {
    background: var(--accent);
    color: var(--accent-ink);
    border: 0;
    border-radius: 4px;
    padding: 10px 20px;
    font-weight: 600
}

.add:hover {
    filter: brightness(1.1)
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px
}

.tabs {
    display: flex;
    gap: 22px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 12px
}

.tabs button {
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    padding: 8px 0;
    margin-bottom: -1px;
    color: var(--muted);
    font-weight: 500
}

.tabs button[aria-pressed="true"] {
    color: var(--ink);
    border-bottom-color: var(--accent);
    font-weight: 600
}

.tabs .n {
    font-size: .78rem;
    margin-left: 6px;
    color: var(--muted)
}

/* ==========================================================================
   5. LIST ITEM / TUGAS CARD
   ========================================================================== */
ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px
}

li {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 2px 14px;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--pc);
    border-radius: 4px;
    padding: 12px 14px
}

.cb {
    appearance: none;
    width: 20px;
    height: 20px;
    margin: 0;
    border: 2px solid var(--muted);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    grid-row: 1/3;
    display: grid;
    place-items: center
}

.cb:checked {
    background: var(--accent);
    border-color: var(--accent)
}

.cb:checked::after {
    content: "";
    width: 5px;
    height: 10px;
    border: solid var(--accent-ink);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) translate(-1px, -1px)
}

.title {
    font-weight: 600;
    overflow-wrap: anywhere
}

li.done .title {
    text-decoration: line-through;
    color: var(--muted);
    font-weight: 400
}

li.done {
    border-left-color: var(--line)
}

.meta {
    grid-column: 2;
    font-size: .82rem;
    color: var(--muted)
}

.meta b {
    font-weight: 600;
    color: var(--pc)
}

li.done .meta b {
    color: var(--muted)
}

.due {
    grid-column: 3;
    grid-row: 1/3;
    text-align: right;
    line-height: 1.3
}

.due b {
    display: block;
    font-weight: 600;
    font-size: .92rem
}

.due span {
    font-size: .78rem;
    color: var(--muted)
}

.due.late b,
.due.soon b {
    color: var(--red)
}

.del {
    grid-column: 4;
    grid-row: 1/3;
    background: none;
    border: 0;
    color: var(--muted);
    font-size: .85rem;
    text-decoration: underline;
    padding: 4px
}

.del:hover {
    color: var(--red)
}

.empty {
    display: block;
    border-left-width: 1px;
    color: var(--muted);
    padding: 24px 14px;
    border-style: dashed
}

/* ==========================================================================
   6. RESPONSIVE DESIGN & ACCESSIBILITY
   ========================================================================== */
@media(max-width:560px) {
    form {
        grid-template-columns: 1fr 1fr
    }

    .add {
        grid-column: 1/-1
    }
}

@media(max-width:480px) {
    li {
        grid-template-columns: auto 1fr auto
    }

    .due {
        grid-column: 2;
        grid-row: 3;
        text-align: left;
        display: flex;
        gap: 8px;
        align-items: baseline
    }

    .due b {
        display: inline
    }

    .del {
        grid-column: 3;
        grid-row: 1
    }
}

@media(prefers-reduced-motion:reduce) {
    * {
        transition: none !important
    }
}