@font-face {
    font-family: "Geist";
    src: url("/assets/fonts/geist-400.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Geist";
    src: url("/assets/fonts/geist-500.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Geist";
    src: url("/assets/fonts/geist-600.woff2") format("woff2");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Geist";
    src: url("/assets/fonts/geist-700.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --canvas: #f3f3f4;
    --workspace: #f6f6f7;
    --surface: #ffffff;
    --ink: #1a1a1e;
    --muted: #6a6a72;
    --line: #e4e4e7;
    --accent: #5b4dff;
    --accent-press: #493cd6;
    --accent-ink: #3c2fd4;
    --tint: #efedff;
    --good: #0d7a45;
    --good-bg: #e7f6ee;
    --warn: #8a5b00;
    --warn-bg: #fbf3df;
    --bad: #b42318;
    --bad-bg: #fdecec;
    --info: #1d4f8a;
    --info-bg: #e8f1fb;
    --shadow-focus: 0 0 0 3px rgba(91, 77, 255, 0.22);
    color-scheme: light;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
    margin: 0;
    min-height: 100%;
    color: var(--ink);
    background: var(--workspace);
    font-family: "Geist", ui-sans-serif, system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: -0.011em;
    overflow-x: clip;
}

a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-press); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.skip {
    position: absolute;
    left: 12px;
    top: -40px;
    background: var(--surface);
    padding: 8px 12px;
    border-radius: 8px;
    z-index: 50;
}

.skip:focus { top: 12px; }

.sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.mark { width: 28px; height: 28px; display: block; color: var(--accent); }

body.login {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
    background-color: #f6f6f7;
    background-image:
        linear-gradient(to right, rgba(26, 26, 30, 0.045) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(26, 26, 30, 0.045) 1px, transparent 1px);
    background-size: 56px 56px;
}

.login-panel {
    width: min(100%, 380px);
}

.login-mark { margin-bottom: 22px; }
.login-mark .mark { width: 36px; height: 36px; }

.login-panel h1 {
    margin: 0;
    font-size: 40px;
    line-height: 1.05;
    font-weight: 600;
    letter-spacing: -0.045em;
}

.login-panel .lede {
    margin: 10px 0 28px;
    max-width: 34ch;
    color: var(--muted);
}

.login-panel form { display: flex; flex-direction: column; }

.login-panel label {
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
}

.login-panel input {
    width: 100%;
    height: 48px;
    margin-bottom: 16px;
    padding: 0 14px;
    border: 1px solid #d9d9de;
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 16px;
}

.login-panel input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--shadow-focus);
}

.password-field { position: relative; }

.password-field input { padding-right: 52px; margin-bottom: 16px; }

.reveal {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.reveal:hover { color: var(--ink); background: var(--canvas); }

.reveal .when-shown { display: none; }

.reveal[aria-pressed="true"] .when-hidden { display: none; }

.reveal[aria-pressed="true"] .when-shown { display: grid; }

.form-error {
    margin: -4px 0 12px;
    color: var(--bad);
    font-size: 14px;
}

.button {
    appearance: none;
    height: 44px;
    margin-top: 4px;
    border: 0;
    border-radius: 10px;
    background: var(--accent);
    color: white;
    font: inherit;
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
}

.button:hover { background: var(--accent-press); }

.button.secondary {
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stack .button { width: auto; align-self: flex-start; min-width: 160px; padding: 0 16px; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.days {
    border: 0;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
}

.check { display: inline-flex; align-items: center; gap: 6px; }

.step-edit {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stack input,
.stack textarea,
.stack select,
.inline input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 16px;
}

.stack input,
.stack select { height: 44px; padding: 0 12px; }

.stack textarea { padding: 10px 12px; resize: vertical; }

.inline { display: flex; gap: 8px; align-items: center; margin: 8px 0; }

.inline input { width: 110px; height: 36px; }

@media (max-width: 720px) {
    .split { grid-template-columns: 1fr; }
}

.shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 224px minmax(0, 1fr);
}

.sidebar {
    display: flex;
    flex-direction: column;
    background: var(--canvas);
    border-right: 1px solid var(--line);
    padding: 18px 12px 14px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 8px 22px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 600;
    letter-spacing: -0.03em;
}

.brand:hover { color: var(--ink); }

.ico { width: 20px; height: 20px; display: block; flex: none; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 8px 10px;
    border-radius: 8px;
    color: #3f3f46;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

.sidebar nav a:hover { background: rgba(255, 255, 255, 0.7); color: var(--ink); }

.sidebar nav a[aria-current="page"] {
    background: var(--surface);
    color: var(--accent-ink);
    box-shadow: inset 0 0 0 1px var(--line);
}

.sidebar-foot {
    margin-top: auto;
    padding: 14px 8px 0;
    border-top: 1px solid var(--line);
}

.who strong,
.who span { display: block; }

.who strong { font-size: 14px; font-weight: 600; }

.who span {
    color: var(--muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quiet {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    margin-top: 8px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.quiet:hover { color: var(--ink); }

.workspace {
    min-width: 0;
    background: var(--workspace);
    container-type: inline-size;
    container-name: desk;
}

.mobile-bar { display: none; }

main {
    width: min(1080px, 100%);
    margin: 0 auto;
    padding: 28px clamp(16px, 3vw, 32px) calc(48px + env(safe-area-inset-bottom));
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

h1 {
    margin: 0;
    font-size: 22px;
    line-height: 1.2;
    font-weight: 600;
    letter-spacing: -0.03em;
}

.lede { margin: 4px 0 0; max-width: 62ch; color: var(--muted); font-size: 14px; }

.page-head .chip { margin-top: 4px; flex: none; }

.scope {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 18px;
    align-items: end;
    margin-bottom: 18px;
}

.scope form { display: flex; gap: 8px; align-items: end; }

.scope label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

.scope select,
.scope input {
    height: 36px;
    min-width: 180px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    padding: 0 10px;
}

.scope .button { height: 36px; margin: 0; padding: 0 14px; }

.head-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.head-actions .inline { margin: 0; }

.tabs {
    display: flex;
    gap: 2px;
    margin: 0 0 16px;
    overflow-x: auto;
    border-bottom: 1px solid var(--line);
}

.tabs a {
    flex: none;
    padding: 8px 12px 10px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    border-bottom: 2px solid transparent;
}

.tabs a[aria-current="page"] {
    color: var(--ink);
    border-bottom-color: var(--ink);
}

.create { margin: 0 0 14px; }

.head-actions .button { height: 36px; margin: 0; padding: 0 14px; }

.create summary {
    display: inline-flex;
    align-items: center;
    height: 36px;
    padding: 0 14px;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.create summary::-webkit-details-marker { display: none; }

.create[open] summary { margin-bottom: 12px; }

.create .sheet { margin-top: 0; }

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    margin-bottom: 14px;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
}

.metric {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 14px 16px 13px;
    background: var(--surface);
}

.num {
    font-size: 26px;
    line-height: 1.1;
    font-weight: 600;
    letter-spacing: -0.04em;
    font-variant-numeric: tabular-nums;
}

.lbl { font-size: 13px; font-weight: 500; }

.sub { color: var(--muted); font-size: 12px; }

.note { margin: 0 0 14px; color: var(--muted); font-size: 13px; }

.desk {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.sheet {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
}

.sheet-pad { padding: 6px 18px 8px; }

.sheet-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 0;
}

.sheet-head h2,
.letter h2,
.letter h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.sheet-head a { font-size: 13px; }

.sequence {
    list-style: none;
    margin: 0;
    padding: 8px 16px 14px;
}

.sheet-pad .sequence { padding: 8px 0 12px; }

.sequence li {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 12px;
}

.sequence li + li { margin-top: 14px; }

.rail { position: relative; }

.rail span {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--tint);
    color: var(--accent-ink);
    font-size: 13px;
    font-weight: 600;
}

.sequence li:not(:last-child) .rail::after {
    content: "";
    position: absolute;
    top: 32px;
    bottom: -14px;
    left: 13px;
    width: 1px;
    background: var(--line);
}

.when-line {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 2px 0 2px;
    color: var(--muted);
    font-size: 12px;
}

.letter h2,
.letter h3 { margin-top: 2px; overflow-wrap: anywhere; }

.letter { min-width: 0; }

.letter-body {
    margin: 10px 0 0;
    white-space: pre-wrap;
    font: inherit;
    font-size: 14.5px;
    line-height: 1.55;
}

.sequence.compact .letter h3 {
    font-weight: 500;
    font-size: 14px;
}

.search { position: relative; margin: 0 0 12px; }

.search input,
.facts {
    font: inherit;
}

.search-ico {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}

.search input {
    width: min(360px, 100%);
    height: 44px;
    padding: 0 12px 0 38px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 16px;
}

.search input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--shadow-focus);
}

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    text-align: left;
    white-space: nowrap;
}

td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

tr:last-child td { border-bottom: 0; }

tbody tr:hover { background: #fafafb; }

td a,
.facts dd { overflow-wrap: break-word; }

.when { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }

.clamp {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 420px;
}

.empty { margin: 0; padding: 22px 16px; color: var(--muted); }

.feed {
    list-style: none;
    margin: 0;
    padding: 2px 0 6px;
}

.feed li {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 12px 16px;
    border-top: 1px solid var(--line);
}

.feed .when { font-size: 12px; }
.feed .what { font-weight: 600; }
.feed a { overflow-wrap: anywhere; }

.chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 6px;
    background: var(--canvas);
    color: #3f3f46;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
}

.chip.good { background: var(--good-bg); color: var(--good); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--info-bg); color: var(--info); }

.facts { margin: 0; }

.facts div {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 12px;
    padding: 13px 16px;
    border-top: 1px solid var(--line);
}

.facts div:first-child { border-top: 0; }

.facts dt { color: var(--muted); font-size: 14px; }

.facts dd { margin: 0; }

.scrim {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(20, 20, 22, 0.28);
}

@media (max-width: 1079px) and (min-width: 760px) {
    .shell { grid-template-columns: 76px minmax(0, 1fr); }

    .sidebar { align-items: center; padding: 16px 10px 12px; }

    .brand { justify-content: center; margin: 0 0 18px; }

    .rail-hide,
    .nav-label,
    .brand-name,
    .who {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .sidebar nav { align-items: center; width: 100%; }

    .sidebar nav a {
        justify-content: center;
        width: 44px;
        height: 44px;
        padding: 0;
    }

    .sidebar-foot {
        width: 100%;
        display: flex;
        justify-content: center;
        padding-top: 12px;
    }

    .quiet { justify-content: center; width: 44px; height: 44px; margin-top: 0; }
}

@media (max-width: 759px) {
    .shell { display: block; }

    .sidebar {
        position: fixed;
        z-index: 30;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(280px, calc(100vw - 48px));
        padding-top: max(18px, env(safe-area-inset-top));
        padding-bottom: max(14px, env(safe-area-inset-bottom));
        padding-left: max(12px, env(safe-area-inset-left));
        transform: translateX(-105%);
        overflow: auto;
    }

    body.nav-open { overflow: hidden; }
    body.nav-open .sidebar { transform: none; }

    .sidebar nav a { min-height: 44px; }

    .mobile-bar {
        position: sticky;
        top: 0;
        z-index: 15;
        display: flex;
        align-items: center;
        gap: 10px;
        min-height: 56px;
        padding: env(safe-area-inset-top) 12px 0 max(12px, env(safe-area-inset-left));
        border-bottom: 1px solid var(--line);
        background: var(--canvas);
    }

    .menu {
        width: 44px;
        height: 44px;
        display: grid;
        place-items: center;
        padding: 0;
        border: 1px solid var(--line);
        border-radius: 10px;
        background: var(--surface);
        color: var(--ink);
        cursor: pointer;
    }

    .mobile-brand {
        color: var(--ink);
        font-weight: 600;
        letter-spacing: -0.03em;
        text-decoration: none;
    }

    .mobile-bar .chip { margin-left: auto; margin-right: max(0px, env(safe-area-inset-right)); }

    .page-head .chip { display: none; }

    main { padding-top: 18px; }
}

@container desk (min-width: 960px) {
    .desk { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); }
}

@container desk (max-width: 880px) {
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@container desk (max-width: 720px) {
    .page-head { flex-wrap: wrap; }
    .search input { width: 100%; }
    .facts div { grid-template-columns: 1fr; gap: 2px; }
    .sheet-pad { padding-left: 14px; padding-right: 14px; }

    table.log thead,
    table.people thead { display: none; }

    table.log tr,
    table.people tr {
        display: block;
        padding: 12px 14px 14px;
        border-bottom: 1px solid var(--line);
    }

    table.log tr:last-child,
    table.people tr:last-child { border-bottom: 0; }

    table.log td,
    table.people td {
        display: block;
        padding: 0;
        border: 0;
    }

    table.log td.when { margin-bottom: 2px; font-size: 12px; }
    table.log td.what { font-weight: 600; }
    table.log .clamp { max-width: none; margin-top: 4px; color: var(--muted); }

    table.people tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        column-gap: 10px;
        row-gap: 2px;
        align-items: center;
    }

    table.people td:nth-child(1) { font-weight: 600; }
    table.people td:nth-child(2) { grid-column: 1; }
    table.people td:nth-child(3) { grid-column: 2; grid-row: 1 / span 2; }
}

@media (max-width: 759px) {
    .login-panel h1 { font-size: 34px; }
}

@media (min-width: 760px) {
    .scrim { display: none !important; }
}

@media (prefers-reduced-motion: no-preference) {
    @media (max-width: 759px) {
        .sidebar { transition: transform 160ms ease; }
    }
}

@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; }
}
