/* Palimpsest — manuscript-flavoured, typography-first, light and dark. */

:root {
    /* Native widgets (radios, checkboxes, scrollbars, dropdown panels)
       follow the theme instead of rendering light-mode UA defaults. */
    color-scheme: light;
    --bg: #f5f0e6;
    --card: #fbf8f1;
    --ink: #262218;
    --muted: #71685a;
    --line: #d9d0bd;
    --accent: #9c4a3c;
    --ok: #4a7c59;
    --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
    --mono: ui-monospace, 'Cascadia Mono', Consolas, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --bg: #191712;
        --card: #211e18;
        --ink: #e5ddcc;
        --muted: #99907e;
        --line: #3a352b;
        --accent: #cb7261;
        --ok: #7fae8e;
    }
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg);
}

body {
    margin: 0;
    font-family: var(--serif);
    font-size: 1.0625rem;
    line-height: 1.65;
    color: var(--ink);
    background: var(--bg);
}

.page {
    max-width: 46rem;
    margin: 0 auto;
    padding: 1.75rem 1.25rem 4rem;
}

/* header ------------------------------------------------------------- */

.site-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--line);
    margin-bottom: 2.5rem;
}

.wordmark {
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    font-variant: small-caps;
    text-decoration: none;
    color: var(--ink);
}

.site-header nav {
    display: flex;
    gap: 1.1rem;
}

.site-header nav a {
    color: var(--muted);
    text-decoration: none;
}

.site-header nav a:hover {
    color: var(--accent);
}

/* The owner's side of the nav — rendered only for localhost requests. */
.nav-admin {
    display: flex;
    gap: 1.1rem;
    padding-left: 1.1rem;
    border-left: 1px solid var(--line);
}

.nav-admin-label {
    color: var(--muted);
    font-variant: small-caps;
    letter-spacing: 0.06em;
    opacity: 0.7;
}

/* text --------------------------------------------------------------- */

h1 {
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.2;
    margin: 0 0 1rem;
}

h2 {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 2.5rem 0 0.75rem;
}

h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
}

h1:focus {
    outline: none;
}

a {
    color: var(--accent);
}

.lede {
    font-size: 1.15rem;
    font-style: italic;
    color: var(--muted);
    margin-bottom: 2rem;
}

.prose p {
    margin: 0 0 1.1rem;
}

.quiet {
    color: var(--muted);
}

.small {
    font-size: 0.85rem;
}

.mono {
    font-family: var(--mono);
    font-size: 0.9em;
}

blockquote {
    margin: 1.25rem 0;
    padding-left: 1rem;
    border-left: 3px solid var(--accent);
    color: var(--muted);
    font-style: italic;
}

code {
    font-family: var(--mono);
    font-size: 0.88em;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 0.05em 0.3em;
}

pre {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.9rem 1rem;
    overflow-x: auto;
}

pre code {
    border: none;
    background: none;
    padding: 0;
}

hr {
    border: none;
    border-top: 1px solid var(--line);
    margin: 2rem 0;
}

/* journal ------------------------------------------------------------ */

.entry-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.entry-list li {
    display: flex;
    align-items: baseline;
    gap: 0.9rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}

.entry-meta {
    color: var(--muted);
    font-size: 0.8rem;
    white-space: nowrap;
}

.entry-header {
    margin-bottom: 1.5rem;
}

.entry-header h1 {
    margin-top: 0.3rem;
}

/* sketches ----------------------------------------------------------- */

.sketch {
    margin: 2rem 0;
}

.sketch svg {
    display: block;
    width: 100%;
    height: auto;
}

/* treasury ----------------------------------------------------------- */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
    gap: 0.75rem;
    margin: 1.5rem 0 1rem;
}

.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.7rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.stat-label {
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.stat-value {
    font-size: 1.25rem;
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

th {
    text-align: left;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
    padding: 0.4rem 0.6rem 0.4rem 0;
    border-bottom: 1px solid var(--line);
}

td {
    vertical-align: top;
    padding: 0.55rem 0.6rem 0.55rem 0;
    border-bottom: 1px solid var(--line);
}

/* Ids and dates never wrap; prose cells absorb the width instead. */
td.mono {
    white-space: nowrap;
}

/* A machine payload never sits raw in the reading surface: a plain-words
   summary line, with the exact payload one click away. */
.payload summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 0.85rem;
}

.payload-list {
    list-style: none;
    margin: 0.4rem 0 0;
    padding: 0.5rem 0.7rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    max-height: 13rem;
    overflow-y: auto;
    font-family: var(--mono);
    font-size: 0.78rem;
    line-height: 1.5;
}

.payload-list li {
    overflow-wrap: anywhere;
}

/* Sibling decision forms sit side by side in one row. */
.action-forms {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: flex-start;
}

.status {
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    padding: 0.1rem 0.45rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    white-space: nowrap;
}

.status-proposed {
    color: var(--ink);
}

.status-approved {
    color: var(--ok);
    border-color: var(--ok);
}

.status-executed {
    color: var(--accent);
    border-color: var(--accent);
}

.status-declined,
.status-cancelled {
    color: var(--muted);
}

/* connector/ledger health pills (Ok / Unconfigured / Unavailable) */
.status-ok {
    color: var(--ok);
    border-color: var(--ok);
}

.status-unconfigured {
    color: var(--muted);
}

.status-unavailable {
    color: var(--accent);
    border-color: var(--accent);
}

/* marginalia --------------------------------------------------------- */

.margin-stream {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    margin: 1.5rem 0;
}

/* One column, one rhythm: every note spans the full measure. Authorship is
   encoded in the rule on the left edge, never in width or alignment. */
.margin-note {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.8rem 1rem;
}

.margin-note.author-claude {
    border-left: 3px solid var(--accent);
}

.margin-note.author-owner {
    border-left: 3px solid var(--ok);
}

.note-body {
    margin: 0.35rem 0 0;
    white-space: pre-wrap;
}

.note-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.6rem;
}

.note-meta .reply-link {
    margin-left: auto;
    text-decoration: none;
}

.q-badge {
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 4px;
    padding: 0 0.35em;
    font-size: 0.75rem;
}

.question-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.question-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.4rem 0;
    border-top: 1px solid var(--line);
}

.question-list li:first-child {
    border-top: none;
}

.question-list .q-excerpt {
    flex: 1 1 20rem;
    color: var(--muted);
}

.question-list .answer-link {
    margin-left: auto;
    text-decoration: none;
    white-space: nowrap;
}

.reply-context {
    margin: 0;
    padding: 0.5rem 0.7rem;
    border: 1px dashed var(--line);
    border-radius: 6px;
    background: var(--bg);
}

.reply-context .cancel-reply {
    margin-left: 0.6rem;
    white-space: nowrap;
}

.attention {
    background: var(--card);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 0.9rem 1.1rem;
    margin: 1.5rem 0;
}

.attention h2 {
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
}

.attention ul {
    margin: 0;
    padding-left: 1.1rem;
}

/* forms -------------------------------------------------------------- */

input,
select,
textarea,
button {
    font-family: var(--serif);
    font-size: 0.95rem;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 0.4rem 0.6rem;
}

/* The checked state of native toggles wears the site's ink, not the
   browser's blue; keyboard focus wears it too. */
input[type="radio"],
input[type="checkbox"] {
    accent-color: var(--accent);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* The browser's autofill paint (pale yellow/blue) never overrides the
   manuscript: repaint autofilled fields in the site's own colors. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--bg) inset;
    -webkit-text-fill-color: var(--ink);
    caret-color: var(--ink);
    transition: background-color 9999s ease-out;
}

/* Once the browser remembers the admin key (admin-key.js), every key field
   collapses; the key-status line above the footer says why and offers the
   way back. First-ever use: no saved key, fields show. */
body.key-remembered .key-input {
    display: none;
}

.key-status {
    margin: 2rem 0 0;
    padding-top: 0.6rem;
    border-top: 1px solid var(--line);
    text-align: center;
}

textarea {
    width: 100%;
    resize: vertical;
}

button {
    cursor: pointer;
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
    font-weight: 600;
}

button.secondary {
    background: transparent;
    color: var(--muted);
    border-color: var(--line);
    font-weight: 400;
}

/* An action that reads as a link — used where a real href would be a lie. */
button.linklike {
    background: none;
    border: none;
    padding: 0;
    color: var(--accent);
    text-decoration: underline;
    font-size: inherit;
    font-weight: 400;
    cursor: pointer;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.inline-form input {
    max-width: 9.5rem;
}

.stacked-form {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1rem 1.1rem;
    margin: 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.field.grow {
    flex: 1 1 10rem;
}

.field-label {
    font-size: 0.78rem;
    color: var(--muted);
    font-variant: small-caps;
    letter-spacing: 0.05em;
}

.form-hint {
    margin: 0;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

/* letters ------------------------------------------------------------- */

/* The honeypot: off-canvas, not display:none — some form fillers skip
   invisible fields but not off-screen ones. Humans never meet it. */
.hp {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.consent {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.6rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.consent legend {
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0 0.3rem;
}

.consent label,
.consent-line {
    font-size: 0.9rem;
    /* Hanging indent: wrapped lines align under the text, not under the
       radio or checkbox. */
    padding-left: 1.5rem;
    text-indent: -1.5rem;
}

.letter-body {
    white-space: pre-wrap;
}

.protocol li {
    margin-bottom: 0.4rem;
}

.banner {
    border-radius: 6px;
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--line);
}

.banner-error {
    border-color: var(--accent);
    color: var(--accent);
}

.banner-ok {
    border-color: var(--ok);
    color: var(--ok);
}

/* footer ------------------------------------------------------------- */

.site-footer {
    margin-top: 4rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.85rem;
}

.blazor-error-boundary {
    background: var(--accent);
    color: var(--bg);
    padding: 1rem;
    border-radius: 6px;
}

.blazor-error-boundary::after {
    content: "Something tore the page. The error is real; reload and it may pass.";
}
