:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #1d2330;
    --muted: #5f6b7a;
    --border: #dde2e8;
    --accent: #2453d4;
    --accent-text: #ffffff;
    --danger: #b42318;
    --ok: #127a43;
    --warn-bg: #fff6e0;
    --warn-border: #f0c25a;
    --code-bg: #eef1f5;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12151b;
        --surface: #1b2029;
        --text: #e6e9ee;
        --muted: #9aa5b4;
        --border: #2d3440;
        --accent: #6d8ff0;
        --accent-text: #0d1220;
        --danger: #f2877d;
        --ok: #5cc98e;
        --warn-bg: #2e2612;
        --warn-border: #8a6a1f;
        --code-bg: #232a35;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

header.top {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

header.top .brand { font-weight: 600; }
header.top nav { display: flex; gap: 16px; flex: 1; }
header.top nav a { text-decoration: none; color: var(--muted); }
header.top nav a.active { color: var(--text); font-weight: 600; }

main { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }
main.narrow { max-width: 420px; padding-top: 72px; }

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
}

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

label { display: block; font-weight: 600; margin: 12px 0 4px; }
label.inline { display: flex; gap: 8px; align-items: center; font-weight: 400; }

input[type=text], input[type=email], input[type=password], select, textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

textarea { min-height: 84px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

button, .button {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--accent);
    color: var(--accent-text);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

button.secondary, .button.secondary { background: transparent; color: var(--accent); }
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 400; }
button:disabled { opacity: .45; cursor: not-allowed; }

.actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }

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

.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; border: 1px solid var(--border); }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.off { color: var(--danger); border-color: var(--danger); }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; background: var(--code-bg); }

.errors { color: var(--danger); margin: 8px 0 0; padding-left: 18px; }

.warn {
    background: var(--warn-bg);
    border: 1px solid var(--warn-border);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 16px;
}

code, .secret {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    background: var(--code-bg);
    border-radius: 4px;
    padding: 1px 5px;
}

.secret { display: block; padding: 12px; word-break: break-all; font-size: 14px; user-select: all; }

.qr svg { background: #fff; padding: 8px; border-radius: 6px; }

nav[role=navigation] { margin-top: 12px; }

/* Outlet tabs (TN-580) */
nav.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 0 0 16px; white-space: nowrap; }
nav.tabs a { padding: 8px 12px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 6px; align-items: center; }
nav.tabs a:hover { color: var(--text); }
nav.tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

/* App tab (TN-580) */
.readiness-card .facts { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 4px 0 0; }
.readiness-card .facts span { display: inline-flex; align-items: center; gap: 6px; }
.status-pill { padding: 6px 14px; border-radius: 99px; font-weight: 600; font-size: 14px; background: var(--warn-bg); border: 1px solid var(--warn-border); white-space: nowrap; }
.status-pill.ok { background: transparent; border-color: var(--ok); color: var(--ok); }
.store-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-top: 16px; }
.store-tile { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.store-tile header { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.check { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.check:first-of-type { border-top: 0; }
.check .dot { flex: 0 0 20px; height: 20px; border-radius: 50%; border: 2px solid var(--warn-border); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; margin-top: 1px; }
.check.ok .dot { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.check > div { flex: 1; min-width: 0; }
.progress { height: 6px; border-radius: 99px; background: var(--code-bg); overflow: hidden; margin: 6px 0 2px; }
.progress span { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.progress.large { height: 8px; margin: 4px 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--code-bg); }
.chip.warn { background: var(--warn-bg); border: 1px solid var(--warn-border); }

.checklist .console-link { background: var(--code-bg); border-radius: 8px; padding: 10px 12px; margin: 4px 0 14px; }
.checklist .console-link label { margin-top: 0; }
.inline-field { display: flex; gap: 8px; }
.inline-field input { flex: 1; min-width: 0; }
.console-link p { margin: 6px 0 0; }

ol.step-list { list-style: none; padding: 0; margin: 0; }
ol.step-list > li + li { margin-top: 8px; }
details.step { border: 1px solid var(--border); border-radius: 8px; }
details.step[open] { border-color: var(--accent); }
details.step.done { opacity: .75; }
details.step > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
details.step > summary::-webkit-details-marker { display: none; }
.step-number { flex: 0 0 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: var(--muted); }
details.step[open] .step-number { border-color: var(--accent); color: var(--accent); }
details.step.done .step-number { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.step-title { flex: 1; font-weight: 600; }
details.step.done .step-title { text-decoration: line-through; color: var(--muted); }
.step-actions { display: flex; gap: 6px; align-items: center; }
.small-button { padding: 4px 10px; font-size: 13px; }
.step-body { padding: 0 12px 12px 48px; }
.step-body .where { margin: 0 0 8px; }
.step-body .note { margin: 8px 0 0; padding: 8px 10px; border-left: 3px solid var(--warn-border); background: var(--warn-bg); border-radius: 0 6px 6px 0; }
table.values { width: 100%; }
table.values th { width: 34%; font-weight: 400; color: var(--muted); font-size: 13px; padding: 6px 8px 6px 0; vertical-align: middle; border-bottom: 1px solid var(--border); }
table.values td { padding: 6px 0; border-bottom: 1px solid var(--border); word-break: break-word; }
table.values tr:last-child th, table.values tr:last-child td { border-bottom: 0; }
.icon-button { border: 1px solid var(--border); background: transparent; color: var(--muted); padding: 0 6px; border-radius: 6px; font-size: 13px; line-height: 22px; cursor: pointer; margin-left: 6px; }
.icon-button:hover { color: var(--text); border-color: var(--muted); }
.icon-button.copied { color: var(--ok); border-color: var(--ok); }

.link-app { margin-top: 12px; }
.link-app > summary { cursor: pointer; color: var(--accent); font-size: 14px; }
.link-app form { margin-top: 8px; }
.link-app p { margin: 6px 0 0; }

.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 16px; }
.subtabs a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 99px; color: var(--muted); text-decoration: none; font-size: 14px; background: var(--surface); }
.subtabs a:hover { color: var(--text); }
.subtabs a.active { color: var(--accent-text); background: var(--accent); border-color: var(--accent); }
.subtabs a.active .badge { border-color: currentColor; color: inherit; }
.subtabs.inner { margin: 0 0 12px; }
.subtabs.inner a { border-radius: 6px; font-size: 13px; padding: 4px 10px; }
.subtabs.inner a.active { background: var(--surface); color: var(--text); border-color: var(--accent); }
.graphics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.graphic-card { border: 1px solid var(--border); border-radius: 8px; padding: 12px; min-width: 0; }
.graphic-card h4 { margin: 0 0 10px; font-size: 13px; display: flex; gap: 6px; align-items: baseline; }
.graphic-card p { margin: 10px 0 0; }
.graphic-pair { display: flex; gap: 16px; }
.graphic-pair figure { margin: 0; text-align: center; }
.graphic-pair figcaption { margin-top: 4px; }
.app-icon { position: relative; width: 88px; height: 88px; border-radius: 22%; overflow: hidden; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); }
.app-icon img { width: 100%; height: 100%; object-fit: contain; }
.app-icon img.fallback { opacity: .35; }
.app-icon.system-dark { background: linear-gradient(180deg, #3a3a3c, #1c1c1e); }
.app-icon.tinted img { filter: grayscale(1) brightness(1.6) sepia(1) hue-rotate(190deg) saturate(2.5); }
.phone-frame { width: 72px; height: 144px; border-radius: 14px; border: 3px solid #2a2f3a; display: flex; align-items: center; justify-content: center; }
.phone-frame { position: relative; }
.phone-frame img { width: 40%; height: auto; object-fit: contain; }
.overlay-upload { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.overlay-upload label { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; color: #ffffff; text-shadow: 0 1px 3px rgba(0, 0, 0, .55); transition: opacity .15s; }
.overlay-upload.ink-dark label { color: #1d2330; text-shadow: none; }
.overlay-upload.ink-text label { color: var(--text); text-shadow: none; }
.overlay-upload .plus { font-size: 30px; font-weight: 300; line-height: 1; }
.overlay-upload .word { font-size: 10px; font-weight: 500; letter-spacing: .02em; }
.overlay-upload label:hover { opacity: .8; }
.below-upload { display: flex; justify-content: center; margin-top: 6px; }
.below-upload label { margin: 0; cursor: pointer; position: relative; }
.below-upload input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.overlay-upload input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.overlay-upload label:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.logo-tile { position: relative; width: 160px; height: 56px; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0 12px; }
.logo-tile.light { background: #ffffff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .1); }
.logo-tile.dark { background: #111318; box-shadow: 0 0 0 1px rgba(255, 255, 255, .12); }
.logo-tile img { max-height: 32px; max-width: 100%; object-fit: contain; }
.logo-strip { position: relative; height: 48px; border-radius: 6px; display: flex; align-items: center; padding: 0 12px; margin-bottom: 6px; }
.logo-strip.light { background: #ffffff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .1); }
.logo-strip.dark { background: #111318; }
.logo-strip img { max-height: 32px; max-width: 100%; object-fit: contain; }
.feature-frame { position: relative; aspect-ratio: 1024 / 500; border-radius: 6px; border: 1px dashed var(--border); background: var(--code-bg); overflow: hidden; }
.feature-frame img.feature { border: 0; border-radius: 0; }
img.feature { display: block; width: 100%; aspect-ratio: 1024 / 500; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin: 0 3px 0 2px; box-shadow: 0 0 0 1px rgba(127, 127, 127, .5); }
.store-page-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.store-section { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; min-width: 0; }
.store-section.wide { grid-column: 1 / -1; }
.store-section h3 { font-size: 14px; margin: 0 0 8px; display: flex; gap: 8px; align-items: center; }
.store-section table.values th { width: 40%; }
.store-page .value { white-space: pre-line; }
.thumbs { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.thumbs figure { margin: 0; width: 96px; text-align: center; }
.thumbs figure.graphic { width: 220px; }
.thumbs figure img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; border: 1px solid var(--border); border-radius: 22%; }
.thumbs figure.graphic img { aspect-ratio: 1024 / 500; border-radius: 8px; object-fit: cover; }
.thumbs figcaption { margin-top: 6px; }
.thumbs .empty { aspect-ratio: 1; border: 1px dashed var(--border); border-radius: 22%; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.thumbs figure.graphic .empty { aspect-ratio: 1024 / 500; border-radius: 8px; }
.thumbs.screenshots { align-items: flex-start; }
.thumbs.screenshots img { display: block; height: 220px; width: auto; border: 1px solid var(--border); border-radius: 10px; }

.row-actions { display: inline-flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.app-settings-form .card h2 { margin-bottom: 4px; }
.image-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 16px; }
.image-field { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.image-field .thumb { flex: 0 0 72px; height: 72px; border: 1px dashed var(--border); border-radius: 12px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--code-bg); }
.image-field .thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.image-field label { margin-top: 0; }
.image-field .hint { margin: 2px 0 6px; }
.image-field input[type=file] { font-size: 13px; max-width: 100%; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; margin: 0 0 16px; border-top: 1px solid var(--border); z-index: 2; }
#screenshots h3 { font-size: 14px; margin: 16px 0 8px; display: flex; gap: 8px; align-items: center; }
.shot { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.upload { margin-top: 10px; }

.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-form .full { grid-column: 1 / -1; }

@media (max-width: 640px) {
    .graphics-grid { grid-template-columns: 1fr; }
    .store-page-grid { grid-template-columns: 1fr; }
    .thumbs.screenshots img { height: 160px; }
    nav.tabs { overflow-x: auto; overflow-y: hidden; }
    nav.tabs a { margin-bottom: 0; }
    details.step > summary { flex-wrap: wrap; }
    .step-actions { width: 100%; padding-left: 36px; }
    .step-body { padding-left: 12px; }
    table.values th { width: 40%; }
    .grid-form { grid-template-columns: 1fr; }
}

/* Startup colors on the App tab (TN-599). */
.startup-colors { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 10px; font-size: 13px; }
.startup-colors label { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.startup-colors input[type="color"] { width: 34px; height: 26px; padding: 0 2px; border: 1px solid var(--border); border-radius: 6px; background: transparent; cursor: pointer; }
