/* bootstrap-icons CSS was previously loaded here via @import. Moved to a
   <link rel="stylesheet" integrity="..."> tag in layout.html so SRI can
   actually apply — @import statements ignore the integrity attribute. */

:root {
    --base-fonts: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Arial, sans-serif;
    /* Design tokens */
    --color-primary:      #c73737;
    --color-secondary:    #2980b9;
    --color-bg: #f6f5f3;
    --color-text:         #232323;
    --color-text-muted:   #606060;
    --color-text-inverse: #ffffff;
    --color-surface:      #ffffff;
    --color-border:       #e4e4e4;
    --color-danger:       #b32525;
    /* Legacy (keep for compatibility) */
    --dark1: #232323;
    --dark2: #606060;
    --dark3: #787878;
    --light4: #eaeaea;
    --light5: #dadada;
    --red: #c73737;
    --default-link: #232323;
    --default-link-hover: #c73737;
    --link-hover-color: #c73737;
    --radius: 14px;
}

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

body, html {
    min-height: 100vh;
    scrollbar-gutter: stable;
}

body {
    font-family: var(--base-fonts), sans-serif;
    font-weight: 400;
    font-style: normal;
    font-size: 1.125rem; /* 18px */
    color: var(--color-text);
    /*background-color: var(--color-bg);*/
    background: linear-gradient(
180deg in oklch,
  oklch(0.99 0 0) 0%,
  oklch(0.97 0.01 237) 100%
    );
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Nav is position: fixed (see nav.css — floating pill → pinned bar).
   The layout's top-level <main> gets top padding to clear it at all
   scroll positions. `body > main` scopes this to the outer element
   only — nested <main> elements inside pages (tool-shell, qrs-main,
   text-index) must not inherit the 96px. */
body > main {
    padding-top: 96px;
}

footer {
    margin-top: auto;
}

/* Stacking context: main + footer sit above the fixed .stage background */
main, footer {
    position: relative;
    z-index: 1;
}

@layer base {
    a:link, a:visited {
        color: var(--default-link);
        text-decoration: none;
    }

    a:hover {
        color: var(--default-link-hover);
    }
}

p:last-child {
    padding-bottom: unset;
    margin-bottom: unset;
}

h1, h2, h3, h4, h5 {
    font-family: var(--base-fonts) sans-serif;
    font-weight: 800;
    font-style: normal;
    color: var(--dark1);
}

h4 {
    color: var(--dark2);
}

/* ── CUBE: Composition ─────────────────────────────────────────────────── */

.center-page {
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 64px 24px;
}

.content-narrow {
    max-width: 768px;
    margin: 0 auto;
    padding: 64px 24px;
}

.content-sm {
    max-width: 672px;
    margin: 0 auto;
    padding: 112px 24px;
}

.content-md {
    max-width: 896px;
    margin: 0 auto;
    padding: 112px 24px;
}

.content-wide {
    max-width: 1024px;
    margin: 0 auto;
    padding: 112px 24px;
}

.content-xwide {
    max-width: 1280px;
    margin: 0 auto;
    padding: 112px 24px;
}

.flow > * + * {
    margin-top: 24px;
}

/* ── CUBE: Utility ─────────────────────────────────────────────────────── */

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--color-text-muted); }
.text-subtle { color: var(--dark3); }
.text-sm     { font-size: 14px; }
.text-xs     { font-size: 12px; }
.text-lg     { font-size: 18px; }
.w-full      { width: 100%; }
.font-bold   { font-weight: 700; }

.mt-2  { margin-top: 8px; }
.mt-4  { margin-top: 16px; }
.mt-6  { margin-top: 24px; }
.mt-8  { margin-top: 32px; }
.mt-10 { margin-top: 40px; }
.mb-2  { margin-bottom: 8px; }
.mb-4  { margin-bottom: 16px; }
.mb-8  { margin-bottom: 32px; }
.mb-10 { margin-bottom: 40px; }
.pt-2  { padding-top: 8px; }

.uppercase      { text-transform: uppercase; }
.tracking-wide  { letter-spacing: 0.1em; }

/* ── CUBE: Block — Card ────────────────────────────────────────────────── */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 32px;
}

/* ── CUBE: Block — Prose ───────────────────────────────────────────────── */

.prose h2, .prose h3, .prose h4, .prose h5 {
    margin-top: 1.8em;
    margin-bottom: 0.6em;
}

.prose p {
    line-height: 1.7;
    margin-bottom: 1em;
    color: var(--color-text-muted);
}

.prose a {
    color: var(--color-primary);
    text-decoration: underline;
}

.prose a:hover {
    opacity: 0.8;
}

/* ── CUBE: Block — Tool write-up ───────────────────────────────────────── */

.tool-writeup {
    margin-top: 50px;
    padding-top: 50px;
    border-top: 1px solid var(--color-border);
}

.tool-writeup p {
    line-height: 1.7;
    color: var(--color-text-muted);
    margin-bottom: 1em;
}

.tool-writeup p:first-of-type {
    font-size: 1.0625rem;
    color: var(--color-text);
}

.tool-writeup h2 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin: 2.5em 0 1em;
}

.tool-writeup ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 20px;
}

.tool-writeup li {
    padding-left: 20px;
    position: relative;
    color: var(--color-text-muted);
    line-height: 1.6;
}

.tool-writeup li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.65em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-primary);
}

.tool-writeup li strong {
    display: block;
    margin-bottom: 4px;
    color: var(--color-text);
    font-weight: 700;
}

/* ── CUBE: Block — Form field ──────────────────────────────────────────── */

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 16px 20px;
    border-radius: var(--radius);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    font-family: inherit;
    font-size: 16px;
    outline: none;
    transition: border-color 0.15s;
}

select.form-input {
    padding-right: 48px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b6b68' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 18px center;
}

.form-input:focus {
    border-color: var(--color-text-muted);
}

.form-error {
    color: var(--color-primary);
    font-size: 14px;
    margin-top: 6px;
}

/* ── CUBE: Block — Button ──────────────────────────────────────────────── */

.btn {
    display: inline-block;
    font-family: inherit;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.15s, color 0.15s;
    text-align: center;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-text-inverse);
}
.btn-primary:hover {
    background: #a82f2f;
    color: var(--color-text-inverse);
}

.btn-secondary {
    background: var(--color-text);
    color: var(--color-text-inverse);
}
.btn-secondary:hover {
    background: #404040;
    color: var(--color-text-inverse);
}

.btn-ghost {
    border: 1px solid var(--color-text);
    color: var(--color-text);
    background: none;
}
.btn-ghost:hover {
    background: var(--color-text);
    color: var(--color-text-inverse);
}

.btn-danger {
    background: #dc2626;
    color: var(--color-text-inverse);
}
.btn-danger:hover {
    background: #b91c1c;
    color: var(--color-text-inverse);
}

.btn-lg {
    padding: 16px 24px;
}

/* ── CUBE: Block — Alert ───────────────────────────────────────────────── */

.alert-error {
    margin-bottom: 16px;
    border-radius: 8px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    padding: 12px 16px;
    font-size: 14px;
    color: #d94e5a;
}

.alert-error p { color: inherit; }

.alert-error ul {
    list-style: none;
    padding: 0;
    margin: 4px 0 0;
}

/* ── CUBE: Block — Error page ──────────────────────────────────────────── */

.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 96px 24px;
}

.error-page img {
    max-width: 300px;
    margin-bottom: 32px;
}

.error-page h1 {
    font-size: 96px;
    font-weight: 800;
}

.error-page h2 {
    font-size: 24px;
    font-weight: 700;
    margin-top: 8px;
    margin-bottom: 16px;
}

.error-page p {
    color: var(--color-text-muted);
    max-width: 448px;
}

.error-page a {
    color: var(--color-primary);
}

.error-page a:hover {
    text-decoration: underline;
}

/* ── CUBE: Block — Badge ───────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-radius: 9999px;
}

.badge-active {
    background: #dcfce7;
    color: #15803d;
}

.badge-inactive {
    background: #fef2f2;
    color: var(--color-primary);
}

/* ── CUBE: Block — Page header ─────────────────────────────────────────── */

.page-sub {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 12px;
}

.page-title {
    font-size: 48px;
    font-weight: 900;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.page-desc {
    font-size: 18px;
    color: var(--color-text-muted);
}

/* ── CUBE: Block — List card ───────────────────────────────────────────── */

.list-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
}

.list-row + .list-row {
    border-top: 1px solid #f0f0f0;
}

.list-empty {
    padding: 32px 24px;
    text-align: center;
    color: var(--color-text-muted);
}

/* ── CUBE: Block — Danger zone ─────────────────────────────────────────── */

.danger-zone {
    background: var(--color-surface);
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 32px;
    margin-top: 24px;
}

.danger-zone .page-sub {
    color: var(--color-primary);
}

/* ── CUBE: Utility — Links ─────────────────────────────────────────────── */

.link-back {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-muted);
}

.link-back:hover {
    text-decoration: underline;
    color: var(--color-text-muted);
}

.link-accent {
    color: var(--color-primary);
    font-weight: 600;
}

.link-accent:hover {
    text-decoration: underline;
    color: var(--color-primary);
}

/* ── CUBE: Utility — Layout helpers ────────────────────────────────────── */

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.flex-row {
    display: flex;
    align-items: center;
}

.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.font-mono { font-family: 'DM Mono', 'Fira Code', monospace; }
.shrink-0 { flex-shrink: 0; }
.min-w-0 { min-width: 0; }
.flex-1 { flex: 1; }

@media (max-width: 639px) {
    .sm-hidden { display: none; }
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

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

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
