/*
 * SenctariaLauncher Manager -- panel stylesheet.
 *
 * Dark only, dependency free. Every colour goes through a token so a rebrand is
 * a few lines at the top rather than a search across the file.
 */

:root {
    --bg: #0b0c0f;
    --bg-soft: #101218;
    --surface: #14161c;
    --surface-2: #1a1d25;
    --surface-3: #22262f;
    --line: #262a34;
    --line-soft: #1e222a;

    --text: #eceef2;
    --text-dim: #b3b9c6;
    --muted: #7c8496;
    --faint: #5b6272;

    /* Brand crimson. Errors use a lighter, warmer red so the two never blur. */
    --accent: #e02434;
    --accent-hi: #ff3d4b;
    --accent-dim: #86121c;
    --accent-ink: #ffffff;
    --accent-wash: rgba(224, 36, 52, .12);
    --accent-edge: rgba(224, 36, 52, .38);

    --ok: #34d058;
    --ok-wash: rgba(52, 208, 88, .10);
    --warn: #e8a838;
    --warn-wash: rgba(232, 168, 56, .10);
    --err: #ff5c63;
    --err-wash: rgba(255, 92, 99, .10);
    --info: #6aa6ff;
    --info-wash: rgba(106, 166, 255, .10);

    --r-sm: 7px;
    --r: 10px;
    --r-lg: 14px;
    --r-full: 999px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, .3);
    --shadow: 0 20px 48px rgba(0, 0, 0, .55);

    /* Latin glyphs come from the first family that has them, Thai from the
     * first Thai family. Browsers fall back per glyph, so one stack covers
     * both scripts without the UI switching typeface mid sentence. */
    --sans: "Inter", -apple-system, "Segoe UI Variable Text", "Segoe UI", system-ui,
        "Noto Sans Thai", "IBM Plex Sans Thai", "Sarabun", Tahoma, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;

    --sidebar-w: 244px;
}

* { box-sizing: border-box; }

/* Overlays are toggled with the `hidden` attribute and several of them set
 * `display` themselves, which beats the browser default for [hidden]. */
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 14.5px;
    /* Thai stacks tone marks above and vowels below the line, so it needs more
     * leading than the same size of Latin text. */
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--accent-hi); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-weight: 650; letter-spacing: -.011em; }

svg {
    width: 1em;
    height: 1em;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

::selection { background: var(--accent-edge); }

/* Scrollbars, so the panel does not switch to the OS light theme mid page. */
* { scrollbar-color: var(--surface-3) transparent; scrollbar-width: thin; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: var(--r-full); border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #333846; background-clip: content-box; }

/* ------------------------------------------------------------------- boot */

.boot {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 100%;
    color: var(--muted);
    font-size: 14px;
}

.spinner {
    width: 15px;
    height: 15px;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
    flex: none;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Nothing is torn down while a view loads, so this bar is the only signal that
 * a request is in flight. */
body.loading::after {
    content: '';
    position: fixed;
    inset-block-start: 0;
    inset-inline: 0;
    height: 2px;
    z-index: 90;
    background: linear-gradient(90deg, transparent, var(--accent-hi), transparent);
    background-size: 38% 100%;
    background-repeat: no-repeat;
    animation: sweep .9s linear infinite;
}

@keyframes sweep {
    from { background-position: -38% 0; }
    to { background-position: 138% 0; }
}

/* ------------------------------------------------------------------ brand */

/* Typeset wordmark -- see logo() in ui.js for why the artwork is not used here.
 * A crimson tile carries the brand colour; the name sits beside it in the UI's
 * own typeface, so nothing has to be lit or plated to stay readable. */
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-mark {
    display: grid;
    place-items: center;
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: var(--r);
    background: linear-gradient(155deg, var(--accent-hi), var(--accent-dim));
    color: var(--accent-ink);
    font-size: 17px;
    font-weight: 800;
}

.logo-word {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .15em;
    line-height: 1.25;
    text-transform: uppercase;
    color: var(--text);
}

.logo-word em {
    display: block;
    font-style: normal;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .2em;
    color: var(--muted);
}

/* ------------------------------------------------------------------ login */

.login-wrap {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    background:
        radial-gradient(1100px 480px at 50% -12%, rgba(224, 36, 52, .15), transparent 68%),
        var(--bg);
}

.login-card {
    width: min(400px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 32px 30px 28px;
    box-shadow: var(--shadow);
}

/* Left-aligned like the heading below it, now that the card is not centred. */
.login-card .logo { margin-bottom: 4px; }

.login-card h1 { font-size: 19px; margin: 20px 0 4px; }
.login-card .lede { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }
.login-card button[type=submit] { width: 100%; justify-content: center; padding: 10px; margin-top: 4px; }
.login-error { color: var(--err); font-size: 13.5px; margin: 12px 0 0; min-height: 1.2em; }

/* ------------------------------------------------------------------ shell */

.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.side {
    background: var(--bg-soft);
    border-inline-end: 1px solid var(--line);
    padding: 20px 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.side > .logo { margin: 0 10px 24px; }

.side nav { display: flex; flex-direction: column; gap: 1px; }

.nav-group {
    font-size: 10.5px;
    letter-spacing: .13em;
    text-transform: uppercase;
    color: var(--faint);
    font-weight: 700;
    padding: 18px 12px 7px;
}

.side nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 12px;
    border-radius: var(--r-sm);
    color: var(--text-dim);
    font-size: 14px;
    border: 1px solid transparent;
    transition: background .12s ease, color .12s ease;
}

.side nav a svg { font-size: 16.5px; color: var(--muted); flex: none; }
.side nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.side nav a:hover svg { color: var(--text-dim); }

.side nav a.active {
    background: linear-gradient(90deg, var(--accent-wash), rgba(224, 36, 52, .03));
    border-color: var(--accent-edge);
    color: #fff;
    font-weight: 600;
}

.side nav a.active svg { color: var(--accent-hi); }

.side .spacer { flex: 1; }

.who { border-top: 1px solid var(--line); padding: 14px 10px 0; font-size: 13px; }
.who .name { color: var(--text); font-weight: 600; font-size: 14px; }
.who .role { color: var(--muted); margin-bottom: 10px; font-size: 12.5px; }

.main { padding: 30px 36px 96px; max-width: 1180px; }

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line-soft);
}

.page-head h1 { margin: 0; font-size: 23px; }
.page-head .sub { margin: 5px 0 0; color: var(--muted); font-size: 13.5px; max-width: 64ch; line-height: 1.7; }
.page-head .sub + .sub { margin-top: 3px; }
.page-head .sub a { color: var(--text-dim); }

.crumb {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 12.5px;
    margin-bottom: 8px;
}

.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--text-dim); }

/* ----------------------------------------------------------------- blocks */

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

.card > h2 {
    margin: 0 0 4px;
    font-size: 15.5px;
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.card > h2 .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }

/* The one-line plain-language explanation that sits under a card title or a
 * field. Requirement: someone who has never seen code should be able to read a
 * setting and know what it changes. */
.card > h2 + .explain { margin: 0 0 18px; }

.explain {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin: 4px 0 0;
    max-width: 66ch;
    line-height: 1.72;
}

.explain strong { color: var(--text-dim); font-weight: 600; }
.explain code, .explain .mono { color: var(--text-dim); }

.card.danger-zone { border-color: rgba(255, 92, 99, .28); background: linear-gradient(180deg, rgba(255, 92, 99, .04), transparent 60%), var(--surface); }

.section-gap { height: 8px; }

/* ------------------------------------------------------------------ stats */

.stats {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    margin-bottom: 16px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 16px 18px;
}

.stat .n { font-size: 28px; font-weight: 700; line-height: 1.2; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; margin-top: 2px; }
.stat .v { font-size: 14px; word-break: break-word; margin-top: 4px; }
.stat.accent .n { color: var(--accent-hi); }
.stat.ok .n { color: var(--ok); }
.stat.warn .n { color: var(--warn); }

/* ------------------------------------------------------------------ forms */

label.field { display: block; margin-bottom: 16px; font-size: 12.5px; color: var(--text-dim); }
label.field > span { display: block; margin-bottom: 6px; font-weight: 600; letter-spacing: .01em; }
label.field .explain { margin-top: 6px; font-weight: 400; }

input[type=text], input[type=password], input[type=date], input[type=number],
input[type=search], input[type=url], input[type=file], select, textarea {
    width: 100%;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 9px 11px;
    font: inherit;
    font-size: 14px;
    transition: border-color .12s ease, box-shadow .12s ease;
}

input::placeholder { color: #4d5361; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-wash);
}

input:disabled, select:disabled, textarea:disabled { opacity: .45; cursor: not-allowed; }

textarea { min-height: 84px; resize: vertical; }

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237c8496' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 15px;
    padding-inline-end: 32px;
}

input[type=file] { padding: 7px 9px; color: var(--text-dim); cursor: pointer; }

input[type=file]::file-selector-button {
    font: inherit;
    font-size: 13px;
    margin-inline-end: 10px;
    padding: 5px 12px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--surface-3);
    color: var(--text);
    cursor: pointer;
}

.row { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }
.row.two { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 10px;
    cursor: pointer;
    line-height: 1.5;
}

.check input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; margin-top: 3px; }
.check .muted { color: var(--muted); }
.check .explain { margin-top: 1px; }
.check > span { min-width: 0; }

.check-card {
    display: block;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 11px 13px;
    margin-bottom: 8px;
    background: var(--surface-2);
}

.check-card:hover { border-color: var(--surface-3); }
.check-card .check { margin-bottom: 0; }

.subhead {
    font-size: 11.5px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .1em;
    font-weight: 700;
    margin: 24px 0 14px;
    padding-top: 18px;
    border-top: 1px solid var(--line-soft);
}

.subhead:first-child { margin-top: 0; padding-top: 0; border-top: none; }

/* --------------------------------------------------------------- buttons */

button, .btn {
    font: inherit;
    font-size: 13.5px;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    padding: 8px 15px;
    cursor: pointer;
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: background .12s ease, border-color .12s ease, opacity .12s ease;
    white-space: nowrap;
}

button:hover:not(:disabled), .btn:hover:not(:disabled) { background: var(--accent-hi); text-decoration: none; }
button:disabled, .btn:disabled { opacity: .42; cursor: not-allowed; }
button svg, .btn svg { font-size: 15px; }

button.ghost, .btn.ghost { background: var(--surface-2); color: var(--text); border-color: var(--line); font-weight: 500; }
button.ghost:hover:not(:disabled), .btn.ghost:hover { background: var(--surface-3); border-color: #363c48; color: var(--text); }

button.quiet { background: transparent; color: var(--text-dim); border-color: transparent; font-weight: 500; }
button.quiet:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

button.danger { background: transparent; color: var(--err); border-color: rgba(255, 92, 99, .35); font-weight: 500; }
button.danger:hover:not(:disabled) { background: var(--err-wash); border-color: rgba(255, 92, 99, .55); }

button.big { padding: 11px 22px; font-size: 15px; }
button.small { padding: 4px 10px; font-size: 12.5px; }

.icon-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    padding: 6px;
    display: grid;
    place-items: center;
    border-radius: var(--r-sm);
}

.icon-btn svg { font-size: 17px; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions.end { justify-content: flex-end; }
.actions.spread { justify-content: space-between; }
.card > .actions:last-child { margin-top: 16px; }

/* Segmented control -- picking one of a short, fixed set. */
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 3px; gap: 3px; flex-wrap: wrap; }

.seg button {
    background: transparent;
    color: var(--text-dim);
    border: none;
    font-weight: 500;
    font-size: 13px;
    padding: 5px 13px;
    border-radius: 5px;
}

.seg button:hover:not(.on) { background: var(--surface-2); color: var(--text); }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ------------------------------------------------------------- drop zone */

.dropzone {
    border: 1.5px dashed var(--line);
    border-radius: var(--r);
    padding: 30px 22px;
    text-align: center;
    background: var(--surface-2);
    cursor: pointer;
    transition: border-color .14s ease, background .14s ease;
}

.dropzone:hover { border-color: var(--accent-edge); background: var(--surface-3); }
.dropzone.over { border-color: var(--accent); background: var(--accent-wash); }
.dropzone.busy { pointer-events: none; opacity: .7; }

.dropzone .dz-icon { font-size: 30px; color: var(--muted); display: block; margin: 0 auto 10px; }
.dropzone.over .dz-icon { color: var(--accent-hi); }
.dropzone .dz-title { font-size: 15px; font-weight: 600; color: var(--text); }
.dropzone .dz-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }

.progress { height: 5px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; margin-top: 14px; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .18s ease; }

/* ----------------------------------------------------------------- lists */

.toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin: 16px 0 12px;
}

.toolbar .search { flex: 1 1 220px; min-width: 180px; position: relative; }
.toolbar .search input { padding-inline-start: 32px; }

.toolbar .search svg {
    position: absolute;
    inset-block-start: 50%;
    inset-inline-start: 10px;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 15px;
    pointer-events: none;
}

.count-note { color: var(--muted); font-size: 12.5px; margin-inline-start: auto; }

.table-wrap { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }

/* A long list scrolls inside its own frame instead of pushing the rest of the
 * page down. Two hundred mods must not bury the update button. */
.list-scroll {
    max-height: min(56vh, 620px);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--bg);
}

/* Sticky headers need separated borders; collapsed ones scroll away with the
 * cells they belong to. */
.list-scroll table { border-collapse: separate; border-spacing: 0; }

.list-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
}

.list-scroll td { border-bottom: 1px solid var(--line-soft); }
.list-scroll tbody tr:last-child td { border-bottom: none; }
.list-scroll tbody tr.picked { background: var(--accent-wash); }
.list-scroll tbody tr.picked:hover { background: rgba(224, 36, 52, .16); }
.list-scroll input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }

/* Bulk actions sit above the list so they stay reachable while it scrolls. */
.bulkbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    padding: 10px 14px;
    border: 1px solid var(--accent-edge);
    border-radius: var(--r-sm);
    background: var(--accent-wash);
    font-size: 13.5px;
}

.bulkbar svg { color: var(--accent-hi); font-size: 17px; flex: none; }
.bulkbar .spacer { flex: 1; }

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

th, td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; line-height: 1.65; }

thead th {
    color: var(--muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    padding-block: 7px;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; }
td.tight, th.tight { width: 1%; white-space: nowrap; }
td .row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.mono { font-family: var(--mono); font-size: .93em; }
.muted { color: var(--muted); }
.dim { color: var(--text-dim); }
.strong { color: var(--text); font-weight: 600; }
.break { word-break: break-all; }
.nowrap { white-space: nowrap; }

.flush { margin: 0; }
.flush-b { margin-bottom: 0; }
.mt { margin-top: 14px; }
.mt-s { margin-top: 8px; }
.inline-select { width: auto; display: inline-block; min-width: 130px; padding-block: 4px; font-size: 12.5px; }

.empty {
    color: var(--muted);
    padding: 34px 16px;
    text-align: center;
    border: 1px dashed var(--line);
    border-radius: var(--r);
    font-size: 13.5px;
}

.empty strong { display: block; color: var(--text-dim); font-size: 14.5px; margin-bottom: 4px; font-weight: 600; }

/* --------------------------------------------------------------- details */

/* Capability that should be available without being in the way. Closed by
 * default, and styled so it reads as a control rather than as a heading. */
details.adv, details.adv-card { }

summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: baseline;
    gap: 9px;
    color: var(--text-dim);
    font-size: 13.5px;
    user-select: none;
}

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

summary::before {
    content: '';
    width: 0;
    height: 0;
    border-inline-start: 5px solid currentColor;
    border-block: 4px solid transparent;
    flex: none;
    transform: translateY(-1px);
    transition: transform .14s ease;
}

details[open] > summary::before { transform: rotate(90deg) translateX(-1px); }
summary:hover { color: var(--text); }
summary .hint { color: var(--muted); font-size: 12.5px; font-weight: 400; }

details.adv { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
details.adv-card > summary { font-size: 15px; }
details.adv-card[open] > summary { margin-bottom: 4px; }

/* ------------------------------------------------------------------ bits */

.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 10px;
    border-radius: var(--r-full);
    font-size: 11.5px;
    font-weight: 600;
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--text-dim);
    white-space: nowrap;
    line-height: 1.7;
}

.pill.ok   { color: var(--ok);   border-color: rgba(52, 208, 88, .32);  background: var(--ok-wash); }
.pill.warn { color: var(--warn); border-color: rgba(232, 168, 56, .32); background: var(--warn-wash); }
.pill.err  { color: var(--err);  border-color: rgba(255, 92, 99, .32);  background: var(--err-wash); }
.pill.info { color: var(--info); border-color: rgba(106, 166, 255, .32); background: var(--info-wash); }
.pill.dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 5px;
    font-size: 11.5px;
    font-weight: 600;
    background: var(--surface-3);
    color: var(--text-dim);
}

.tag.required { background: var(--accent-wash); color: var(--accent-hi); }
.tag.optionalon { background: var(--ok-wash); color: var(--ok); }
.tag.optionaloff { background: var(--surface-3); color: var(--muted); }

.banner {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    border: 1px solid var(--line);
    border-inline-start: 3px solid var(--muted);
    border-radius: var(--r);
    padding: 13px 16px;
    margin-bottom: 16px;
    background: var(--surface);
    font-size: 13.5px;
    color: var(--text-dim);
    line-height: 1.72;
}

.banner svg { font-size: 18px; flex: none; margin-top: 3px; color: var(--muted); }
.banner strong { color: var(--text); }
.banner.warn { border-inline-start-color: var(--warn); }
.banner.warn svg { color: var(--warn); }
.banner.err { border-inline-start-color: var(--err); }
.banner.err svg { color: var(--err); }
.banner.ok { border-inline-start-color: var(--ok); }
.banner.ok svg { color: var(--ok); }
.banner.info { border-inline-start-color: var(--info); }
.banner.info svg { color: var(--info); }

.copyline {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 7px 8px 7px 12px;
}

.copyline span { flex: 1; min-width: 0; overflow: auto; white-space: nowrap; font-family: var(--mono); font-size: 12.5px; color: var(--text-dim); }

.issue { border-inline-start: 3px solid var(--line); padding: 10px 0 10px 14px; margin-bottom: 12px; }
.issue.error { border-color: var(--err); }
.issue.warn { border-color: var(--warn); }
.issue.info { border-color: var(--info); }
.issue b { display: block; margin-bottom: 2px; font-size: 14px; }
.issue .detail { color: var(--text-dim); font-size: 13.2px; }
.issue .hint { font-size: 13.2px; color: var(--muted); margin-top: 3px; }
.issue .hint::before { content: 'Fix: '; color: var(--text-dim); font-weight: 600; }
.issue .where { font-size: 11.5px; color: var(--faint); margin-top: 4px; font-family: var(--mono); }

/* ---------------------------------------------------------------- drawer */

.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .58); z-index: 30; }

.drawer {
    position: fixed;
    inset-block: 0;
    inset-inline-end: 0;
    width: min(660px, 100%);
    background: var(--surface);
    border-inline-start: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    z-index: 40;
}

.drawer-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 14px 20px;
    border-bottom: 1px solid var(--line);
}

.drawer-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.log {
    flex: 1;
    overflow: auto;
    margin: 0;
    padding: 14px 20px;
    font-family: var(--mono);
    font-size: 12.2px;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--bg);
    color: var(--text-dim);
}

.log .l-error { color: var(--err); }
.log .l-warn { color: var(--warn); }
.log .l-debug { color: var(--faint); }

.drawer-result { border-top: 1px solid var(--line); padding: 16px 20px; max-height: 48vh; overflow: auto; }
.drawer-result:empty { display: none; }
.drawer-result .card { background: var(--surface-2); }
.drawer-result > p:first-child { margin-top: 0; }

/* ----------------------------------------------------------------- modal */

.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(0, 0, 0, .62);
}

.modal-card {
    width: min(540px, 100%);
    max-height: 84vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
    animation: pop .14s ease-out;
}

@keyframes pop { from { opacity: 0; transform: scale(.98); } }

.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 14px 16px 22px; border-bottom: 1px solid var(--line); }
.modal-head strong { font-size: 15.5px; }
.modal-body { padding: 20px 22px; overflow: auto; }
.modal-body label.field:last-child { margin-bottom: 0; }
.modal-body > p:first-child { margin-top: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); }

/* ---------------------------------------------------------------- toasts */

.toasts {
    position: fixed;
    inset-block-end: 20px;
    inset-inline-start: 20px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    z-index: 60;
    max-width: calc(100vw - 40px);
}

.toast {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-inline-start-width: 3px;
    border-radius: 9px;
    padding: 11px 16px;
    max-width: 440px;
    font-size: 13.5px;
    box-shadow: var(--shadow-sm);
    animation: rise .16s ease-out;
}

.toast.ok { border-inline-start-color: var(--ok); }
.toast.err { border-inline-start-color: var(--err); }
.toast.info { border-inline-start-color: var(--info); }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ------------------------------------------------------------ responsive */

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

    .side {
        position: static;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
        padding: 12px 16px;
    }

    .side > .logo { margin: 0; }
    .side nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
    .side nav a { padding: 6px 11px; font-size: 13px; }
    .side .spacer, .nav-group { display: none; }
    .who { border-top: none; padding: 0; margin-inline-start: auto; display: flex; align-items: center; gap: 12px; }
    .who .role { margin-bottom: 0; }
    .main { padding: 20px 16px 72px; }
    .page-head h1 { font-size: 20px; }
    .card { padding: 16px; }
}
