/* ============================================================
   Залупок Admin — design system (unslop pass)
   Direction: dark ink monitoring console, single amber accent,
   quiet chrome, one live status dot as signature.
   ============================================================ */

:root {
    /* Ink ramp (night console world) */
    --bg-deep: #07080d;        /* sidebar */
    --bg: #0b0d14;             /* page */
    --surface: #11141c;        /* card */
    --surface-2: #1a1e28;      /* raised: active row, input */
    --hairline: rgba(238, 240, 245, 0.08);
    --hairline-strong: rgba(238, 240, 245, 0.14);
    --text: #eef0f5;
    --text-2: #a3a9b8;
    --text-3: #7a8296;

    /* Accent — used twice max per screen: primary action, active prompt */
    --accent: #f0a450;
    --accent-text: #f5b96b;
    --accent-dim: rgba(240, 164, 80, 0.10);

    /* Semantic, toned down */
    --positive: #4cc38a;
    --negative: #e5484d;
    --positive-dim: rgba(76, 195, 138, 0.14);

    /* Radii, nested */
    --r-card: 12px;
    --r-control: 8px;
    --r-tag: 5px;

    /* Type */
    --font: "Geist", "IBM Plex Sans", "Inter", system-ui, sans-serif;
    --mono: "Geist Mono", "JetBrains Mono", ui-monospace, monospace;

    --sidebar-w: 240px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { color-scheme: dark; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    letter-spacing: 0;
}

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

/* ---------- Layout ---------- */

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-deep);
    border-right: 1px solid var(--hairline);
    padding: 24px 12px 16px;
    gap: 4px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px 24px;
}

.brand-mark {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--positive);
    box-shadow: 0 0 0 3px var(--positive-dim);
    flex-shrink: 0;
    margin-left: 2px;
}

.brand-name {
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0;
}

.brand-sub {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 1px;
    letter-spacing: 0.01em;
}

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

.nav-label {
    font-size: 12px;
    color: var(--text-3);
    padding: 16px 12px 8px;
    letter-spacing: 0.01em;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 36px;
    padding: 0 12px;
    border-radius: var(--r-control);
    color: var(--text-2);
    font-weight: 500;
    font-size: 14px;
    transition: color 120ms, background 120ms;
}

.nav a:hover {
    background: var(--surface);
    color: var(--text);
}

.nav a.active {
    background: var(--surface-2);
    color: var(--text);
}

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

.nav a svg {
    width: 16px;
    height: 16px;
    stroke-width: 1.5;
    color: var(--text-3);
    flex-shrink: 0;
    transition: color 120ms;
}

.sidebar-footer {
    border-top: 1px solid var(--hairline);
    margin: 12px 4px 0;
    padding-top: 16px;
}

.sidebar-footer .meta {
    font-size: 12px;
    color: var(--text-3);
    padding: 0 8px;
    letter-spacing: 0.01em;
}

.main {
    padding: 32px 40px 64px;
    width: 100%;
    min-width: 0;
}

/* ---------- Page head ---------- */

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 32px;
}

.page-title h1 {
    font-size: 28px;
    font-weight: 500;
    letter-spacing: -0.01em;
    line-height: 1.15;
}

.page-title p {
    color: var(--text-2);
    font-size: 14px;
    margin-top: 6px;
    letter-spacing: 0;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-2);
    font-weight: 500;
    white-space: nowrap;
    padding-bottom: 4px;
}

.status::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--positive);
    box-shadow: 0 0 0 3px var(--positive-dim);
}

/* ---------- Sections & cards ---------- */

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

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

.section {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-card);
    margin-bottom: 24px;
    overflow: hidden;
}

.section-head {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 56px;
    padding: 0 20px;
    border-bottom: 1px solid var(--hairline);
}

.section-head svg {
    width: 16px;
    height: 16px;
    stroke-width: 1.5;
    color: var(--text-3);
    flex-shrink: 0;
}

.section-head h2 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.section-head .count {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
}

.section-body {
    padding: 20px;
}

/* Active prompt — the single moment. Amber hairline left, tinted surface. */
.section.active-mode .section-head {
    background: linear-gradient(180deg, rgba(240, 164, 80, 0.03), transparent 70%);
    border-left: 2px solid var(--accent);
}

.section.active-mode .section-head h2 {
    color: var(--accent-text);
}

.section.active-mode .section-head svg {
    color: var(--accent);
}

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

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

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

.field {
    margin-bottom: 20px;
}

.form-grid .field {
    margin-bottom: 0;
}

.field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    margin-bottom: 8px;
    letter-spacing: 0;
}

.field .hint {
    font-size: 12.5px;
    color: var(--text-3);
    margin-top: 6px;
    letter-spacing: 0.01em;
}

.field .hint code {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-2);
    background: var(--surface-2);
    border: 1px solid var(--hairline);
    border-radius: var(--r-tag);
    padding: 1px 6px;
}

input[type="text"],
input[type="password"],
input[type="url"],
textarea,
select {
    width: 100%;
    height: 40px;
    padding: 0 14px;
    background: var(--bg);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--r-control);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    transition: border-color 140ms, box-shadow 140ms;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="url"]:focus,
textarea:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-3);
}

textarea {
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    height: auto;
    padding: 10px 14px;
}

textarea.large {
    min-height: 200px;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border: none;
    border-radius: var(--r-control);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    line-height: 1;
    transition: background 140ms, color 140ms, border-color 140ms;
}

.btn:active {
    transform: scale(0.98);
}

.btn svg {
    width: 16px;
    height: 16px;
    stroke-width: 1.5;
}

/* Primary: off-white from the ramp, not the color. Accent lives small. */
.btn-primary {
    background: var(--text);
    color: #0b0d14;
}

.btn-primary:hover {
    background: #ffffff;
}

.btn-success {
    background: var(--surface-2);
    color: var(--positive);
    border: 1px solid rgba(76, 195, 138, 0.4);
}

.btn-success:hover {
    background: var(--positive-dim);
}

.btn-danger {
    background: transparent;
    color: var(--negative);
    border: 1px solid rgba(229, 72, 77, 0.35);
}

.btn-danger:hover {
    background: rgba(229, 72, 77, 0.1);
}

.btn-ghost {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--hairline);
}

.btn-ghost:hover {
    background: var(--surface-2);
    border-color: var(--hairline-strong);
}

.btn-sm {
    height: 32px;
    padding: 0 12px;
    font-size: 13px;
    border-radius: var(--r-control);
}

/* ---------- Prompt cards ---------- */

.prompt-card {
    background: var(--bg);
    border: 1px solid var(--hairline);
    border-left: 2px solid var(--hairline);
    border-radius: var(--r-control);
    padding: 16px;
    margin-bottom: 12px;
    transition: border-color 140ms;
}

/* The one live thing: the active prompt gets the amber accent line */
.prompt-card.active {
    border-left-color: var(--accent);
    background: linear-gradient(180deg, rgba(240, 164, 80, 0.02), var(--bg) 60%);
}

.prompt-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
}

.prompt-name {
    font-weight: 500;
    font-size: 14px;
    font-family: var(--mono);
    color: var(--text);
}

.prompt-is-active {
    font-size: 12px;
    color: var(--accent-text);
    font-family: var(--mono);
    letter-spacing: 0.01em;
}

.prompt-meta {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
}

.prompt-preview {
    font-family: var(--mono);
    font-size: 12.5px;
    color: var(--text-2);
    white-space: pre-wrap;
    max-height: 84px;
    overflow: hidden;
    line-height: 1.6;
    background: var(--bg-deep);
    border: 1px solid var(--hairline);
    border-radius: var(--r-tag);
    padding: 10px 12px;
    margin-bottom: 12px;
}

.prompt-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.edit-area {
    display: none;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--hairline);
}

.edit-area.open {
    display: block;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-3);
    font-size: 14px;
    line-height: 1.7;
}

/* ---------- Toast ---------- */

.toast-wrap {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.toast {
    background: var(--surface-2);
    border: 1px solid var(--hairline-strong);
    border-left: 2px solid var(--positive);
    color: var(--text);
    padding: 12px 16px;
    border-radius: var(--r-control);
    font-size: 13.5px;
    font-weight: 500;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    animation: toast-in 200ms cubic-bezier(0.22, 1, 0.36, 1), toast-out 300ms cubic-bezier(0.22, 1, 0.36, 1) 2.6s forwards;
}

.toast.error {
    border-left-color: var(--negative);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
    to { opacity: 0; transform: translateY(8px); }
}

/* ---------- Message viewer ---------- */

.viewer-body {
    min-height: 100vh;
    background: var(--bg);
    padding: 32px 16px;
    display: flex;
    justify-content: center;
}

.viewer {
    width: 100%;
    max-width: 760px;
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-card);
    overflow: hidden;
}

.viewer-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--hairline);
    background: var(--bg);
}

.viewer-name {
    font-weight: 500;
    font-size: 15px;
}

.viewer-meta {
    font-size: 12.5px;
    color: var(--text-3);
    letter-spacing: 0.01em;
}

/* live dot next to author name — signature detail */
.viewer-live {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--positive);
    box-shadow: 0 0 0 3px var(--positive-dim);
    flex-shrink: 0;
}

.viewer-body-content {
    padding: 24px 26px 28px;
    font-size: 15px;
    line-height: 1.65;
    overflow-wrap: break-word;
    letter-spacing: 0;
}

.viewer-body-content strong { font-weight: 600; color: var(--text); }
.viewer-body-content em { font-style: italic; }
.viewer-body-content del { text-decoration: line-through; }
.viewer-body-content code {
    background: var(--surface-2);
    border: 1px solid var(--hairline);
    padding: 1px 6px;
    border-radius: var(--r-tag);
    font-family: var(--mono);
    font-size: 13px;
    color: var(--accent-text);
}
.viewer-body-content pre {
    background: var(--bg-deep);
    border: 1px solid var(--hairline);
    padding: 14px 16px;
    border-radius: var(--r-control);
    overflow-x: auto;
    margin: 12px 0;
}
.viewer-body-content pre code {
    background: none;
    border: none;
    padding: 0;
    color: var(--text);
}
.viewer-body-content blockquote {
    border-left: 2px solid var(--hairline-strong);
    padding-left: 14px;
    color: var(--text-2);
    margin: 10px 0;
}
.viewer-body-content img {
    max-width: 100%;
    border-radius: var(--r-control);
}
.viewer-body-content h1,
.viewer-body-content h2,
.viewer-body-content h3 {
    margin: 18px 0 8px;
    line-height: 1.3;
    font-weight: 500;
}
.viewer-body-content a { color: var(--accent-text); }

.viewer-footer {
    padding: 12px 22px;
    border-top: 1px solid var(--hairline);
    background: var(--bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12.5px;
    color: var(--text-3);
    letter-spacing: 0.01em;
}

/* ---------- Error 404 ---------- */

.error-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    text-align: center;
    background: var(--bg);
}

.error-card {
    max-width: 420px;
}

.error-card h1 {
    font-size: 22px;
    font-weight: 500;
    margin-bottom: 8px;
}

.error-card p {
    color: var(--text-2);
    margin-bottom: 24px;
}

/* ---------- Responsive ---------- */

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

    .sidebar {
        position: static;
        height: auto;
        flex-direction: row;
        align-items: center;
        padding: 12px 16px;
        border-right: none;
        border-bottom: 1px solid var(--hairline);
        overflow-x: auto;
    }

    .brand {
        padding: 0 12px 0 0;
    }

    .brand-sub {
        display: none;
    }

    .nav {
        flex-direction: row;
        gap: 2px;
    }

    .nav-label {
        display: none;
    }

    .nav a {
        padding: 0 12px;
        height: 36px;
        white-space: nowrap;
    }

    .sidebar-footer {
        border-top: none;
        margin: 0;
        padding: 0;
        margin-left: auto;
    }

    .sidebar-footer .meta {
        display: none;
    }

    .main {
        padding: 24px 20px 48px;
    }

    .page-head {
        flex-direction: column;
        align-items: flex-start;
    }
}