/* Bullet Planner — dotted paper, ballpoint blue, highlighter yellow.
   No build step: this file is served as-is. */

:root {
    --paper: #f4f6f1;
    --surface: #fbfcf9;
    --desk: #dde3da;
    --ink: #1b2233;
    --ink-2: #4b5468;
    --ink-3: #78819a;
    --dot: #c3cabf;
    --line: #d8ddd2;
    --pen: #2846c9;
    --pen-soft: #e2e8fb;
    --mark: #ffe14d;
    --danger: #b3261e;

    --hand: "Bradley Hand", "Segoe Print", "Noteworthy", "Marker Felt", "Chalkboard SE", cursive;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    --tab-h: 62px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --paper: #151922;
        --surface: #1c212c;
        --desk: #0c0f15;
        --ink: #e8ebf3;
        --ink-2: #b5bccd;
        --ink-3: #8089a0;
        --dot: #2b3242;
        --line: #2a3141;
        --pen: #92a9ff;
        --pen-soft: #212b52;
        --mark: #e8c93a;
        --danger: #ff8f86;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --paper: #151922;
    --surface: #1c212c;
    --desk: #0c0f15;
    --ink: #e8ebf3;
    --ink-2: #b5bccd;
    --ink-3: #8089a0;
    --dot: #2b3242;
    --line: #2a3141;
    --pen: #92a9ff;
    --pen-soft: #212b52;
    --mark: #e8c93a;
    --danger: #ff8f86;
    color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--sans);
    font-size: 1rem;
    line-height: 1.45;
    color: var(--ink);
    background: var(--paper);
    -webkit-tap-highlight-color: transparent;
}
h1, h2, p { margin: 0; }
a { color: var(--pen); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .35; }
:focus-visible { outline: 2px solid var(--pen); outline-offset: 2px; }
[x-cloak], [hidden] { display: none !important; }
.sr-only, .sr-input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); opacity: 0; pointer-events: none; }
.hand { font-family: var(--hand); font-weight: 700; letter-spacing: .01em; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.g { font-family: var(--hand); font-weight: 700; color: var(--pen); }
.ok { color: var(--pen); font-size: .9rem; }
.err { display: block; color: var(--danger); font-style: normal; font-size: .875rem; margin-top: 4px; }

/* Livewire page-transition bar */
#nprogress .bar { background: var(--pen) !important; height: 3px !important; }

/* ---------- shell ---------- */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.rail { display: none; }

.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between;
    padding: calc(6px + var(--safe-top)) 10px 6px 16px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}
.topbar-actions { display: flex; gap: 2px; }

.brand { display: inline-flex; align-items: baseline; gap: 8px; text-decoration: none; color: var(--ink); }
.brand-glyphs { font-family: var(--hand); font-weight: 700; font-size: 1.35rem; letter-spacing: .08em; color: var(--pen); }
.brand-name { font-family: var(--hand); font-weight: 700; font-size: 1.35rem; }
.brand.static { margin-bottom: 20px; }

.sheet {
    flex: 1;
    padding: 18px 16px calc(var(--tab-h) + var(--safe-bottom) + 24px);
    background-color: var(--paper);
    background-image: radial-gradient(circle at 1px 1px, var(--dot) 1.1px, transparent 1.5px);
    background-size: 24px 24px;
}

.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--tab-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--paper);
    border-top: 1px solid var(--line);
}
.tabbar .nav-link {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font-size: .72rem; color: var(--ink-3); text-decoration: none;
}
.tabbar .nav-link.is-active { color: var(--pen); font-weight: 600; }
.tabbar .nav-link.is-active svg { stroke-width: 2.3; }

.page { display: flex; flex-direction: column; gap: 14px; max-width: 720px; margin: 0 auto; min-height: 100%; }

.offline-bar {
    display: none; position: sticky; top: 0; z-index: 50;
    padding: calc(6px + var(--safe-top)) 12px 6px; text-align: center; font-size: .85rem;
    background: var(--mark); color: #1b2233;
}
html.is-offline .offline-bar { display: block; }

/* ---------- page heads ---------- */
.page-head {
    display: flex; align-items: flex-end; gap: 4px;
    padding-bottom: 10px; border-bottom: 2px solid var(--ink);
}
.page-title { flex: 1; min-width: 0; }
.page-title h1 { font-family: var(--hand); font-weight: 700; font-size: 2.35rem; line-height: 1.05; }
.page-title .sub { color: var(--ink-2); font-size: .95rem; margin-top: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.h2 { font-size: 1.45rem; line-height: 1.2; }
.h2 small { font-family: var(--sans); font-weight: 400; font-size: .9rem; color: var(--ink-2); margin-left: 4px; }
.h2 a { color: inherit; text-decoration: none; }
.back { display: inline-flex; align-items: center; gap: 2px; align-self: flex-start; color: var(--ink-2); text-decoration: none; font-size: .9rem; }

.badge { background: var(--pen-soft); color: var(--pen); border-radius: 999px; padding: 1px 10px; font-size: .8rem; font-weight: 600; }

/* ---------- buttons and chips ---------- */
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; border: 0; border-radius: 50%;
    background: transparent; color: var(--ink); text-decoration: none;
}
.icon-btn:hover { background: var(--pen-soft); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 44px; padding: 0 18px;
    border: 1.5px solid var(--ink); border-radius: 12px;
    background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 600;
}
.btn.primary { background: var(--pen); border-color: var(--pen); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #10162e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #10162e; } }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.btn.block { width: 100%; }
.btn.danger, .danger { color: var(--danger); }
.btn.danger { border-color: var(--danger); }

.tools, .chips, .row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row.spread { justify-content: space-between; }
.row input[type="text"] { flex: 1; min-width: 0; }
.picker { position: relative; }
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    min-height: 40px; padding: 0 14px;
    border: 1.5px solid var(--line); border-radius: 999px;
    background: var(--surface); color: var(--ink); font-size: .9rem; text-decoration: none;
}
.chip.is-on { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.seg { display: inline-flex; margin-left: auto; border: 1.5px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.seg button { min-height: 38px; padding: 0 14px; border: 0; background: transparent; font-size: .9rem; }
.seg button.is-on { background: var(--ink); color: var(--paper); }

/* ---------- forms ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .95rem; }
.field small { font-weight: 400; color: var(--ink-2); }
input[type="text"], input[type="password"], input[type="search"], input[type="date"], input[type="month"], select {
    width: 100%; min-height: 46px; padding: 0 12px;
    border: 1.5px solid var(--ink-3); border-radius: 10px;
    background: var(--surface); font-size: 1rem; /* 16px stops iOS zooming on focus */
}
.check { display: flex; align-items: center; gap: 10px; font-size: .95rem; }
.check input { width: 20px; height: 20px; accent-color: var(--pen); }
.panel { padding: 16px; border: 1.5px solid var(--ink); border-radius: 14px; background: var(--surface); }
.search-input { border-color: var(--ink); border-radius: 14px; }

.auth { display: flex; flex-direction: column; gap: 16px; }
.auth h1 { font-size: 2.1rem; line-height: 1.1; }

/* ---------- entries (the bullets) ---------- */
.entries { list-style: none; margin: 0; padding: 0; }
.entry { border-bottom: 1px solid var(--line); }
.entry-line { display: grid; grid-template-columns: 1.7rem 2rem minmax(0, 1fr) 44px; align-items: start; }

.sigs { display: flex; justify-content: flex-end; align-items: center; height: 44px; gap: 1px; }
.sig { font-family: var(--hand); font-weight: 700; font-size: 1.35rem; line-height: 1; }
.sig-priority { background: var(--mark); color: #1b2233; border-radius: 4px; padding: 0 3px 2px; }
.sig-inspiration { color: var(--pen); }

.bullet {
    height: 44px; width: 2rem; padding: 0; border: 0; background: transparent;
    font-family: var(--hand); font-weight: 700; font-size: 1.7rem; line-height: 1; color: var(--ink);
}
.entry-body { padding: 10px 0; min-width: 0; }
.entry-text { font-size: 1.05rem; line-height: 1.4; overflow-wrap: anywhere; }
.time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--pen); margin-inline-end: .55em; }
.place { display: inline-block; margin-top: 2px; font-size: .8rem; color: var(--ink-3); text-decoration: none; }
a.place:hover { color: var(--pen); text-decoration: underline; }
.more { width: 44px; height: 44px; border: 0; background: transparent; color: var(--ink-3); border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.more[aria-expanded="true"] { color: var(--pen); background: var(--pen-soft); }

.status-done .bullet { color: var(--pen); }
.status-done .entry-text { color: var(--ink-3); }
.status-migrated .entry-text, .status-scheduled .entry-text { color: var(--ink-3); }
.status-migrated .bullet, .status-scheduled .bullet { color: var(--ink-3); }
.status-cancelled .entry-text { color: var(--ink-3); text-decoration: line-through; }
.status-cancelled .bullet { color: var(--ink-3); }

.entry-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 12px 3.7rem; }
.entry-actions button, .entry-actions .pick {
    display: inline-flex; align-items: center; gap: 6px;
    min-height: 38px; padding: 0 12px;
    border: 1.5px solid var(--line); border-radius: 999px;
    background: var(--surface); font-size: .85rem;
}
.entry-actions .pick input { width: auto; min-height: 30px; padding: 0 6px; border-radius: 8px; font-size: .85rem; }
.entry-actions .danger { border-color: var(--danger); }

.edit-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.edit-form input { flex: 1 1 12rem; }

.stale-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 0; }
.stale-line .entry-body { flex: 1 1 100%; padding: 0; }

.empty { padding: 26px 8px; text-align: center; color: var(--ink-2); line-height: 1.7; }
.empty .g { font-size: 1.6rem; margin: 0 6px; }

/* collapsible callouts (migration, monthly tasks) */
.fold { border: 1.5px solid var(--ink); border-radius: 12px; background: var(--surface); overflow: hidden; }
.fold-head { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 0 12px; border: 0; background: transparent; text-align: left; font-weight: 600; }
.fold-head .g { font-size: 1.4rem; }
.fold-head span:nth-child(2) { flex: 1; }
.fold-caret { transition: transform .15s; }
.fold-head[aria-expanded="true"] .fold-caret { transform: rotate(90deg); }
.fold-body { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.fold-body .entries { width: 100%; }

.progress { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--pen); border-radius: 99px; transition: width .25s; }

/* ---------- quick add ---------- */
.quickadd {
    position: sticky; z-index: 10;
    bottom: calc(var(--tab-h) + var(--safe-bottom) + 10px);
    margin-top: auto;
    display: flex; align-items: center; gap: 6px; padding: 6px;
    border: 1.5px solid var(--ink); border-radius: 16px; background: var(--surface);
}
.quickadd > input[type="text"] { flex: 1; min-width: 0; border: 0; background: transparent; min-height: 44px; padding: 0 6px; }
.quickadd > input[type="text"]:focus-visible { outline: none; }
.quickadd:focus-within { outline: 2px solid var(--pen); outline-offset: 2px; }
.type-pick { display: flex; background: var(--paper); border-radius: 12px; padding: 2px; }
.type-pick label { position: relative; }
.type-pick input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.type-pick span { display: grid; place-items: center; width: 36px; height: 40px; border-radius: 10px; font-family: var(--hand); font-weight: 700; font-size: 1.5rem; color: var(--ink-2); }
.type-pick input:checked + span { background: var(--ink); color: var(--paper); }
.type-pick input:focus-visible + span { outline: 2px solid var(--pen); outline-offset: 1px; }
.add-btn { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--pen); color: #fff; }
:root[data-theme="dark"] .add-btn { color: #10162e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .add-btn { color: #10162e; } }
.add-btn.small { width: 40px; height: 40px; }

.inline-add { display: flex; gap: 6px; align-items: center; padding-top: 10px; }

.key { font-size: .9rem; color: var(--ink-2); }
.key summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; font-weight: 600; }
.key-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 4px 16px; padding: 6px 0; }
.key-grid .g { font-size: 1.2rem; margin-right: 2px; }
.how { font-size: .9rem; color: var(--ink-2); }
.how summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; }
.how p { margin-top: 6px; }
.danger-zone { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ---------- monthly log ---------- */
.cal-list { list-style: none; margin: 0; padding: 0; }
.cal-row { display: grid; grid-template-columns: 3.2rem 1fr; border-bottom: 1px solid var(--line); min-height: 46px; }
.cal-row.is-today { background: var(--pen-soft); }
.cal-date { display: flex; align-items: baseline; gap: 5px; padding: 10px 0 0 6px; text-decoration: none; color: var(--ink); }
.cal-date .n { font-family: var(--hand); font-weight: 700; font-size: 1.3rem; min-width: 1.4rem; text-align: right; }
.cal-date .w { font-size: .75rem; color: var(--ink-3); }
.cal-body { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 8px 8px 8px 0; font-size: .95rem; }
.cal-event { display: inline-flex; gap: 6px; align-items: baseline; }
.cal-event b { color: var(--pen); font-variant-numeric: tabular-nums; }
.cal-count { color: var(--ink-2); font-size: .85rem; }

.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-label { text-align: center; font-size: .8rem; color: var(--ink-3); padding: 2px 0; }
.cal-cell { display: flex; flex-direction: column; gap: 4px; min-height: 76px; padding: 6px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); text-decoration: none; }
.cal-cell.is-today { border-color: var(--pen); background: var(--pen-soft); }
.cal-cell .n { font-family: var(--hand); font-weight: 700; font-size: 1.15rem; line-height: 1; }
.cal-cell .marks { display: flex; flex-wrap: wrap; gap: 2px 8px; font-size: .75rem; color: var(--ink-2); }

/* ---------- future log ---------- */
.future-grid { display: grid; gap: 22px; }
.month-card { border-top: 2px solid var(--ink); padding-top: 8px; }

/* ---------- collections ---------- */
.coll-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.coll {
    display: flex; flex-direction: column; gap: 4px; min-height: 108px; padding: 14px 12px 12px 16px;
    border: 1.5px solid var(--ink); border-left: 9px solid var(--pen); border-radius: 6px 14px 14px 6px;
    background: var(--surface); color: var(--ink); text-decoration: none;
}
.coll-icon { font-size: 1.6rem; line-height: 1; }
.coll-name { font-family: var(--hand); font-weight: 700; font-size: 1.2rem; line-height: 1.15; overflow-wrap: anywhere; }
.coll-count { margin-top: auto; font-size: .8rem; color: var(--ink-2); }
.icon-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-pick label { position: relative; }
.icon-pick input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.icon-pick span { display: grid; place-items: center; width: 44px; height: 44px; border: 1.5px solid var(--line); border-radius: 12px; font-size: 1.4rem; background: var(--paper); }
.icon-pick input:checked + span { border-color: var(--pen); background: var(--pen-soft); }
.icon-pick input:focus-visible + span { outline: 2px solid var(--pen); outline-offset: 1px; }

/* ---------- habits ---------- */
.habit-chip {
    display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 14px 0 8px;
    border: 1.5px solid var(--ink); border-radius: 14px; background: var(--surface);
}
.habit-chip small { color: var(--ink-2); font-size: .75rem; }
.habit-x { display: grid; place-items: center; width: 30px; height: 30px; border: 1.5px solid var(--ink-3); border-radius: 50%; font-family: var(--hand); font-weight: 700; font-size: 1.3rem; line-height: 1; color: var(--pen); }
.habit-chip.is-done { background: var(--pen-soft); border-color: var(--pen); }
.habit-chip.is-done .habit-x { border-color: var(--pen); }

.grid-scroll { overflow-x: auto; margin: 0 -16px; padding: 0 16px 6px; }
.habit-grid { border-collapse: separate; border-spacing: 0; }
.habit-grid th, .habit-grid td { padding: 2px 1px; text-align: center; font-weight: 400; }
.habit-grid thead th { font-size: .7rem; color: var(--ink-3); }
.habit-grid th .dl, .habit-grid th .dn { display: block; line-height: 1.2; }
.habit-grid th.is-today { color: var(--pen); font-weight: 700; }
.sticky-col { position: sticky; left: 0; z-index: 2; min-width: 138px; max-width: 138px; padding-right: 8px !important; text-align: left !important; background: var(--paper); box-shadow: 1px 0 0 var(--line); }
.habit-grid tbody .sticky-col { font-size: .9rem; font-weight: 600; }
.habit-name { display: inline-block; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.remove { border: 0; background: transparent; color: var(--danger); width: 28px; height: 28px; vertical-align: middle; border-radius: 50%; }
.dot { width: 32px; height: 32px; border: 1.5px solid var(--dot); border-radius: 50%; background: transparent; font-family: var(--hand); font-weight: 700; font-size: 1.15rem; line-height: 1; color: var(--pen); padding: 0; }
.dot.on { border-color: var(--pen); }
td.is-today .dot:not(.on) { border-color: var(--ink-3); }

/* ---------- install banner ---------- */
.install {
    position: fixed; z-index: 40; left: 12px; right: 12px;
    bottom: calc(var(--tab-h) + var(--safe-bottom) + 12px);
    display: flex; align-items: center; gap: 8px; padding: 8px 6px 8px 14px;
    border: 1.5px solid var(--ink); border-radius: 14px; background: var(--surface);
    box-shadow: 0 6px 24px rgb(0 0 0 / .18); font-size: .9rem;
}
.install p { flex: 1; }

/* ---------- guest / offline ---------- */
body.guest .sheet.auth-sheet { max-width: 440px; margin: 0 auto; width: 100%; padding-top: calc(36px + var(--safe-top)); padding-bottom: 40px; display: flex; flex-direction: column; gap: 14px; background-color: transparent; }
body.guest { background-color: var(--paper); background-image: radial-gradient(circle at 1px 1px, var(--dot) 1.1px, transparent 1.5px); background-size: 24px 24px; }

/* ---------- desktop / tablet ---------- */
@media (min-width: 900px) {
    body { background: var(--desk); }
    .shell { flex-direction: row; }
    .tabbar, .topbar { display: none; }
    .rail {
        display: flex; flex-direction: column; gap: 24px;
        position: sticky; top: 0; height: 100dvh; width: 224px; flex: none; padding: 26px 14px 20px;
    }
    .rail-nav, .rail-foot { display: flex; flex-direction: column; gap: 2px; }
    .rail-foot { margin-top: auto; }
    .rail .brand { padding: 0 10px; }
    .rail .nav-link { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 12px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
    .rail .nav-link:hover { background: var(--paper); }
    .rail .nav-link.is-active { background: var(--paper); color: var(--pen); font-weight: 700; }

    .main-col { padding: 22px 24px 22px 0; }
    .sheet { flex: none; width: 100%; max-width: 820px; margin: 0 auto; padding: 34px 44px 44px; border-radius: 16px; box-shadow: 0 1px 2px rgb(0 0 0 / .08), 0 14px 40px rgb(0 0 0 / .10); }
    .page { min-height: calc(100dvh - 44px - 78px); }
    .quickadd { bottom: 14px; }
    .install { left: auto; right: 24px; bottom: 24px; max-width: 380px; }
    .future-grid { grid-template-columns: 1fr 1fr; gap: 26px 34px; }
    .grid-scroll { margin: 0; padding: 0 0 6px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}
