/* RobDoc — site stylesheet */

:root {
    --ink: #18181B;
    --ink-2: #3F3F46;
    --muted: #71717A;
    --line: #E4E4E7;
    --line-strong: #D4D4D8;
    --surface: #FAFAFA;
    --paper: #FFFFFF;
    --accent: #B4541A;
    --accent-hover: #943F0F;
    --accent-soft: #FBF1EA;

    --ok: #2F6B3A;
    --ok-soft: #EEF5EF;
    --warn: #8A5A00;
    --warn-soft: #FBF5E6;
    --err: #9B2C2C;
    --err-soft: #FBEDED;

    --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
    --radius: 4px;
    --container: 1120px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.6;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 2.25rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }
code, pre, kbd { font-family: var(--font-mono); }
img { max-width: 100%; height: auto; display: block; }

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

.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 24px;
}

.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); }
.small { font-size: 0.85rem; }

/* Small uppercase mono label used above headings */
.eyebrow {
    display: block;
    margin-bottom: 12px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

/* ---------- Header / footer ---------- */

.site-header {
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}
.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    height: 60px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-weight: 600;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}
.brand:hover { color: var(--ink); text-decoration: none; }
.brand-mark {
    width: 10px;
    height: 10px;
    background: var(--accent);
}
.site-nav {
    display: flex;
    align-items: center;
    gap: 24px;
    font-size: 0.9rem;
}
.site-nav a, .site-nav .link-button { color: var(--ink-2); white-space: nowrap; }
.site-nav a:hover, .site-nav .link-button:hover { color: var(--ink); text-decoration: none; }
.site-nav a.active { color: var(--ink); font-weight: 500; }
.site-nav .user { color: var(--muted); }
.site-nav form { margin: 0; }

.link-button {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    cursor: pointer;
}

main { flex: 1; }

.site-footer {
    border-top: 1px solid var(--line);
    background: var(--paper);
    font-size: 0.8rem;
    color: var(--muted);
}
.site-footer .container {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 24px;
    padding-top: 20px;
    padding-bottom: 20px;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--paper); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: var(--ink); color: var(--ink); }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] {
    background: var(--line);
    border-color: var(--line);
    color: var(--muted);
    cursor: not-allowed;
}

/* ---------- Forms ---------- */

.field { margin-bottom: 20px; }
.field label, .label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ink-2);
}
.input, .select, .textarea {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--ink);
    font: inherit;
    font-size: 0.95rem;
}
.textarea { height: auto; padding: 10px 12px; }
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-help { margin-top: 6px; font-size: 0.8rem; color: var(--muted); }
.field-error, .errorlist {
    margin: 6px 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.8rem;
    color: var(--err);
}

/* ---------- Panels ---------- */

.panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}
.panel-header h2 { font-size: 0.95rem; }
.panel-body { padding: 20px; }

.notice {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--muted);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 0.875rem;
    color: var(--ink-2);
}
.notice-error { border-left-color: var(--err); background: var(--err-soft); color: var(--err); }

/* ---------- Status badges / tags ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border: 1px solid currentColor;
    border-radius: var(--radius);
    background: none;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.5;
}
button.badge { cursor: pointer; }
button.badge:hover { text-decoration: underline; text-underline-offset: 2px; }
.badge-ok { color: var(--ok); background: var(--ok-soft); }
.badge-warn { color: var(--warn); background: var(--warn-soft); }
.badge-err { color: var(--err); background: var(--err-soft); }
.badge-neutral { color: var(--muted); background: var(--surface); }

.tag {
    display: inline-block;
    padding: 0 6px;
    border: 1px solid var(--line-strong);
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    color: var(--ink-2);
    vertical-align: 2px;
}

/* ======================================================================
   Front page
   ====================================================================== */

.hero {
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}
.hero .container {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    gap: 64px;
    align-items: center;
    padding-top: 72px;
    padding-bottom: 72px;
}
.hero h1 { max-width: 20ch; margin-bottom: 20px; }
.hero .lead {
    max-width: 54ch;
    margin-bottom: 32px;
    font-size: 1.075rem;
    color: var(--ink-2);
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* The document cover shown as a sheet of paper */
.doc-sheet {
    position: relative;
    max-width: 340px;
    margin: 0 auto;
}
.doc-sheet-page { position: relative; }
.doc-sheet-page::before {
    content: "";
    position: absolute;
    inset: 0;
    transform: translate(12px, 12px);
    background: var(--surface);
    border: 1px solid var(--line);
}
.doc-sheet-page img {
    position: relative;
    width: 100%;
    border: 1px solid var(--line-strong);
    background: #fff;
}
.doc-sheet figcaption {
    position: relative;
    margin-top: 24px;
    font-size: 0.8rem;
    color: var(--muted);
    text-align: center;
}

.section { padding: 72px 0; border-bottom: 1px solid var(--line); }
.section:last-of-type { border-bottom: 0; }
.section-head { max-width: 640px; margin-bottom: 36px; }
.section-head h2 { margin-bottom: 10px; }
.section-head p { color: var(--ink-2); }

/* Supported systems table */
.spec-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--paper);
    border: 1px solid var(--line);
    font-size: 0.9rem;
}
.spec-table th, .spec-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}
.spec-table th {
    background: var(--surface);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}
.spec-table tr:last-child td { border-bottom: 0; }
.table-scroll { overflow-x: auto; }
.table-note { margin-top: 12px; font-size: 0.85rem; color: var(--muted); }

/* Program conversion: source vs. readable */
.code-compare {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    overflow: hidden;
}
.code-pane + .code-pane { border-left: 1px solid var(--line); }
.code-pane-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    font-size: 0.8rem;
    color: var(--muted);
}
.code-pane-head strong { color: var(--ink); font-weight: 500; }
.code-pane pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
    font-size: 0.78rem;
    line-height: 1.75;
    color: var(--ink-2);
    white-space: pre;
}
.code-pane.raw pre { color: var(--muted); }
.code-pane.readable pre { color: var(--ink); }
.code-pane .hl { color: var(--accent); }

/* Custom templates: text beside a token example */
.feature-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 48px;
    align-items: center;
}
.feature-split .section-head { margin-bottom: 0; }
.feature-split .section-head p + p { margin-top: 16px; }
.code-single { grid-template-columns: minmax(0, 1fr); }

/* Document contents list */
.contents {
    columns: 2;
    column-gap: 48px;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: chapter;
}
.contents li {
    display: grid;
    grid-template-columns: 36px 1fr;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
    counter-increment: chapter;
    break-inside: avoid;
}
.contents li::before {
    content: counter(chapter, decimal-leading-zero);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--muted);
    padding-top: 2px;
}
.contents strong { display: block; font-weight: 500; }
.contents span { font-size: 0.85rem; color: var(--muted); }

/* How it works */
.steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-top: 1px solid var(--ink);
}
.step { padding: 20px 24px 0 0; }
.step-num {
    display: block;
    margin-bottom: 12px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent);
}
.step h3 { margin-bottom: 6px; }
.step p { font-size: 0.9rem; color: var(--ink-2); max-width: 32ch; }

.cta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 56px;
    padding: 24px 28px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
}

/* ======================================================================
   Generator page
   ====================================================================== */

.page { padding: 40px 0 72px; }
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
}
.page-head h1 { font-size: 1.6rem; }
.page-head p { margin-top: 6px; color: var(--ink-2); }

.quota {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    font-size: 0.85rem;
    color: var(--muted);
}
.quota strong { font-family: var(--font-mono); font-size: 1rem; font-weight: 500; color: var(--ink); }
.quota.empty strong { color: var(--err); }

.generator-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}
.generator-main { display: grid; gap: 24px; }

/* Drop zone for the backup ZIP */
label.dropzone,
.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 140px;
    padding: 24px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
    margin: 0;
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--ink);
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone:focus-within { border-color: var(--accent); }
.dropzone input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}
.dropzone-title { font-weight: 500; }
.dropzone-title u { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.dropzone-hint { font-size: 0.8rem; color: var(--muted); }
.dropzone.has-file { border-style: solid; border-color: var(--ink-2); background: var(--paper); }
.dropzone-file {
    display: none;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    word-break: break-all;
}
.dropzone.has-file .dropzone-file { display: block; }
.dropzone.has-file .dropzone-hint::after { content: "Click or drop to replace"; }
.dropzone.has-file .dropzone-title,
.dropzone.has-file .dropzone-hint-default { display: none; }

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
    margin-top: 4px;
}

/* Progress */
.progress { margin-top: 20px; }
.progress[hidden] { display: none; }
.progress-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.8rem;
    color: var(--ink-2);
}
.progress-meta .mono { color: var(--muted); }
.progress-track {
    height: 4px;
    background: var(--line);
    border-radius: 2px;
    overflow: hidden;
}
.progress-fill {
    width: 0;
    height: 100%;
    background: var(--accent);
    transition: width 0.2s;
}
.progress.working .progress-fill {
    width: 30% !important;
    animation: progress-slide 1.2s ease-in-out infinite;
}
@keyframes progress-slide {
    from { transform: translateX(-100%); }
    to { transform: translateX(340%); }
}
.form-error { margin-top: 16px; }
.form-error[hidden] { display: none; }

/* Recent documents list */
.doc-list { margin: 0; padding: 0; list-style: none; }
.doc-item {
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}
.doc-item:last-child { border-bottom: 0; }
.doc-item-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    word-break: break-word;
}
.doc-item-meta { margin-top: 2px; font-size: 0.8rem; color: var(--muted); }
.doc-item-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
    font-size: 0.85rem;
}
.empty-state { padding: 28px 20px; font-size: 0.9rem; color: var(--muted); }

.rules { margin: 0 0 20px; padding: 0; list-style: none; font-size: 0.8rem; color: var(--muted); }
.rules li::before { content: "– "; }

/* Error dialog */
dialog.modal {
    width: min(560px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    color: var(--ink);
    background: var(--paper);
}
dialog.modal::backdrop { background: rgba(24, 24, 27, 0.45); }
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 0.95rem; }
.modal-close {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: var(--radius);
    background: none;
    color: var(--muted);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}
.modal-close:hover { background: var(--surface); color: var(--ink); }
.modal-body { padding: 20px; }
.modal-body pre {
    max-height: 60vh;
    margin: 0;
    padding: 14px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 0.78rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}
.modal-foot {
    display: flex;
    justify-content: flex-end;
    padding: 12px 20px;
    border-top: 1px solid var(--line);
    background: var(--surface);
}

/* ======================================================================
   Auth & simple pages
   ====================================================================== */

.auth { padding: 72px 0; }
.auth-card { max-width: 400px; margin: 0 auto; }
.auth-card .panel-body { padding: 28px; }
.auth-card h1 { font-size: 1.4rem; margin-bottom: 6px; }
.auth-card .intro { margin-bottom: 24px; font-size: 0.9rem; color: var(--muted); }
.auth-alt { margin-top: 16px; font-size: 0.875rem; text-align: center; color: var(--muted); }

.message-page { max-width: 560px; margin: 0 auto; }
.message-page h1 { font-size: 1.5rem; margin-bottom: 12px; }
.message-page p { color: var(--ink-2); margin-bottom: 24px; }

/* Template token reference */
.doc-page { max-width: 800px; }
.doc-page h2 { margin: 40px 0 14px; font-size: 1.1rem; }
.token {
    margin-bottom: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
}
.token summary {
    display: flex;
    align-items: baseline;
    gap: 16px;
    padding: 14px 18px;
    cursor: pointer;
    list-style: none;
}
.token summary::-webkit-details-marker { display: none; }
.token summary::after {
    content: "+";
    margin-left: auto;
    font-family: var(--font-mono);
    color: var(--muted);
}
.token[open] summary::after { content: "–"; }
.token[open] summary { border-bottom: 1px solid var(--line); }
.token-name { font-family: var(--font-mono); font-weight: 500; }
.token-desc { font-size: 0.875rem; color: var(--muted); }
.token-body { padding: 18px; display: grid; gap: 18px; }
.token-body h4 {
    margin-bottom: 8px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}
.token-body .tag + .tag { margin-left: 4px; }
.attr-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.attr-table td { padding: 6px 12px 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.attr-table tr:last-child td { border-bottom: 0; }
.attr-table td:first-child { font-family: var(--font-mono); color: var(--accent); white-space: nowrap; }
.attr-table td:nth-child(2) { font-family: var(--font-mono); color: var(--muted); white-space: nowrap; }
.attr-table td:first-child, .attr-table td:nth-child(2) { width: 1%; padding-right: 28px; }
.snippet {
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 0.8rem;
    line-height: 1.7;
    overflow-x: auto;
}

/* ======================================================================
   Responsive
   ====================================================================== */

@media (max-width: 900px) {
    h1 { font-size: 1.9rem; }
    .hero .container { grid-template-columns: 1fr; gap: 48px; padding-top: 48px; padding-bottom: 56px; }
    .doc-sheet { max-width: 280px; }
    .generator-grid { grid-template-columns: 1fr; }
    .feature-split { grid-template-columns: 1fr; gap: 32px; }
    .code-compare { grid-template-columns: 1fr; }
    .code-pane + .code-pane { border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 640px) {
    body { font-size: 14.5px; }
    .container { padding: 0 16px; }
    .section { padding: 52px 0; }
    .site-nav { gap: 16px; }
    .site-nav .user, .site-nav .nav-secondary { display: none; }
    .contents { columns: 1; }
    .steps { grid-template-columns: 1fr; }
    .step { padding: 20px 0; border-bottom: 1px solid var(--line); }
    .cta-row { padding: 20px; }
}
