@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:wght@400;700&family=Lora:ital,wght@0,400;0,500;0,600;1,400;1,500&display=swap');

:root {
    --paper-dark: #111010;
    --paper-dark-soft: #130f0f;
    --ink-black: #0a0808;
    --ink-cream: #e8e0d0;
    --ink-red: #8b1a1a;
    --ink-blue: #1a3a5c;
    --ink-muted: rgba(232, 224, 208, 0.72);
}

* { box-sizing: border-box; }

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

body {
    position: relative;
    overflow-x: hidden;
    background: linear-gradient(180deg, var(--paper-dark) 0%, var(--paper-dark-soft) 100%);
    color: var(--ink-cream);
    font-family: 'Lora', 'PT Serif', Georgia, serif;
    font-size: 17px;
    line-height: 1.8;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.03;
    z-index: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='320' viewBox='0 0 320 320'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.78' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='320' height='320' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

body::after {
    content: '';
    position: fixed;
    inset: -6%;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(circle at 12% 20%, rgba(139, 26, 26, 0.08) 0 17%, transparent 54%),
        radial-gradient(circle at 85% 16%, rgba(26, 58, 92, 0.06) 0 18%, transparent 56%),
        radial-gradient(circle at 68% 82%, rgba(139, 26, 26, 0.05) 0 14%, transparent 52%);
}

.language-panel {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 11;
    display: grid;
    gap: 0.3rem;
    background: rgba(18, 14, 14, 0.92);
    border: 1px dashed rgba(232, 224, 208, 0.15);
    padding: 0.55rem 0.72rem;
    min-width: 175px;
}

.language-label {
    margin: 0;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.16rem;
    font: 700 0.67rem/1 'Libre Baskerville', Georgia, serif;
}

.language-select {
    appearance: none;
    border: 1px solid rgba(232, 224, 208, 0.28);
    background: var(--ink-black);
    color: var(--ink-cream);
    padding: 0.36rem 0.46rem;
    border-radius: 2px;
    font: 500 0.95rem 'Lora', 'PT Serif', Georgia, serif;
}

.editorial-shell {
    position: relative;
    z-index: 1;
    width: min(1180px, 92vw);
    margin: 0 auto;
    padding: 2.2rem 0 4.6rem;
}

.split-layout {
    display: grid;
    grid-template-columns: minmax(260px, 0.95fr) minmax(0, 1.65fr);
    gap: clamp(1.6rem, 3vw, 3.2rem);
    align-items: start;
}

.brand-column,
.workspace-column {
    background: rgba(14, 11, 11, 0.58);
    border: 1px dashed rgba(232, 224, 208, 0.15);
}

.brand-column {
    position: sticky;
    top: 1rem;
    display: grid;
    gap: 0.85rem;
    padding: 1.3rem 1.1rem;
}

.brand-column::after {
    content: '';
    width: 90px;
    height: 58px;
    opacity: 0.14;
    justify-self: end;
    background:
        radial-gradient(circle at 12% 42%, var(--ink-red) 0 8px, transparent 9px),
        radial-gradient(circle at 45% 18%, var(--ink-red) 0 4px, transparent 5px),
        radial-gradient(circle at 68% 64%, var(--ink-blue) 0 6px, transparent 7px),
        radial-gradient(circle at 86% 40%, var(--ink-red) 0 5px, transparent 6px),
        radial-gradient(circle at 34% 78%, var(--ink-blue) 0 3px, transparent 4px);
}

.section-label {
    margin: 0;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.28rem;
    font: 700 0.72rem/1 'Libre Baskerville', Georgia, serif;
}

h1 {
    margin: 0;
    max-width: 10.8ch;
    font-family: 'Libre Baskerville', 'Playfair Display', Georgia, serif;
    font-size: clamp(3.3rem, 8.4vw, 5.8rem);
    line-height: 0.96;
    letter-spacing: 0.01em;
    color: var(--ink-cream);
}

.dek {
    margin: 0;
    max-width: 32ch;
    color: rgba(232, 224, 208, 0.78);
    font-size: clamp(1rem, 1.34vw, 1.2rem);
}

.workspace-column { padding: 1.05rem; }

.field-block {
    display: grid;
    gap: 0.45rem;
    padding: 1rem 0;
    border-top: 1px dashed rgba(232, 224, 208, 0.15);
}

.field-block:first-child { border-top: none; }

.field-label {
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.19rem;
    font: 700 0.75rem/1 'Libre Baskerville', Georgia, serif;
}

input,
textarea {
    width: 100%;
    border: 1px solid rgba(232, 224, 208, 0.25);
    background: #120e0e;
    color: var(--ink-cream);
    padding: 0.8rem 0.92rem;
    border-radius: 2px;
    outline: none;
    font: 500 1rem 'Lora', 'PT Serif', Georgia, serif;
    line-height: 1.8;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

input::placeholder,
textarea::placeholder {
    color: rgba(232, 224, 208, 0.45);
}

input:focus,
textarea:focus,
.language-select:focus {
    border-color: rgba(139, 26, 26, 0.8);
    background: #171111;
}

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

.action-row {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.generate-btn,
.copy-btn {
    border: 1px solid #2b1616;
    background: #1a0f0f;
    color: var(--ink-cream);
    padding: 0.72rem 1.25rem;
    border-radius: 2px;
    text-transform: uppercase;
    letter-spacing: 0.12rem;
    font: 700 0.82rem/1 'Libre Baskerville', Georgia, serif;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.generate-btn:hover,
.copy-btn:hover {
    background: #281414;
    color: #efe8db;
}

.copy-btn {
    background: #14181e;
    border-color: rgba(26, 58, 92, 0.7);
}

.copy-btn:hover { background: #1a2532; }

.status {
    min-height: 1.65rem;
    color: rgba(232, 224, 208, 0.7);
    font-size: 0.95rem;
    margin-top: 0.7rem;
}

.error { color: #b93b3b; }

.output-block {
    position: relative;
    border-bottom: 1px dashed rgba(232, 224, 208, 0.15);
    margin-top: 0.2rem;
    padding-bottom: 1.4rem;
}

.output-block::after {
    content: '✦';
    position: absolute;
    bottom: -0.8rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(232, 224, 208, 0.5);
    background: rgba(18, 14, 14, 0.95);
    padding: 0 0.5rem;
}

img { filter: sepia(0.4) contrast(1.1); }

/* ─── Organization URL Rows ──────────────────────────────────────── */

.org-block {
    border-top: none;
    padding-top: 0;
}

.org-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.org-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 1px solid rgba(232, 224, 208, 0.25);
    border-radius: 2px;
    background: rgba(26, 58, 92, 0.3);
    color: var(--ink-cream);
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.org-add-btn:hover {
    background: rgba(26, 58, 92, 0.55);
    border-color: rgba(232, 224, 208, 0.4);
}

.org-url-list {
    display: grid;
    gap: 0.4rem;
    margin-top: 0.35rem;
}

.org-url-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    animation: orgRowIn 0.2s ease;
}

@keyframes orgRowIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.org-url-input {
    flex: 1;
    padding: 0.55rem 0.72rem;
    font-size: 0.95rem;
}

.org-remove-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 1px solid rgba(139, 26, 26, 0.4);
    border-radius: 2px;
    background: rgba(139, 26, 26, 0.15);
    color: var(--ink-cream);
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.org-remove-btn:hover {
    background: rgba(139, 26, 26, 0.4);
    border-color: rgba(139, 26, 26, 0.7);
}

/* ─── Format Toggle ──────────────────────────────────────────────── */

.format-block {
    border-top: none;
    padding-top: 0;
    padding-bottom: 0.5rem;
}

.format-toggle {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}

.format-option {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    color: var(--ink-muted);
    font: 500 0.92rem 'Lora', 'PT Serif', Georgia, serif;
    transition: color 0.2s ease;
}

.format-option:hover { color: var(--ink-cream); }

.format-option input[type="radio"] {
    appearance: none;
    width: 14px;
    height: 14px;
    border: 1px solid rgba(232, 224, 208, 0.35);
    border-radius: 50%;
    background: var(--ink-black);
    cursor: pointer;
    padding: 0;
    position: relative;
    transition: border-color 0.2s ease;
}

.format-option input[type="radio"]:checked {
    border-color: var(--ink-red);
}

.format-option input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px; right: 2px; bottom: 2px;
    border-radius: 50%;
    background: var(--ink-red);
}

.format-option input[type="radio"]:checked + span {
    color: var(--ink-cream);
}

/* ─── Match Summary Table ────────────────────────────────────────── */

.match-summary-container { margin-top: 1.2rem; }

.match-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    line-height: 1.5;
}

.match-table thead th {
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.12rem;
    font: 700 0.68rem/1 'Libre Baskerville', Georgia, serif;
    padding: 0.5rem 0.55rem;
    border-bottom: 1px dashed rgba(232, 224, 208, 0.2);
    text-align: left;
}

.match-table tbody td {
    padding: 0.4rem 0.55rem;
    border-bottom: 1px solid rgba(232, 224, 208, 0.06);
    vertical-align: top;
}

.match-table tbody tr:last-child td { border-bottom: none; }

.match-tech {
    font-family: 'Courier New', Courier, monospace;
    color: var(--ink-cream);
    font-weight: 600;
}

.match-cat {
    color: var(--ink-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06rem;
}

.match-repo a {
    color: var(--ink-cream);
    text-decoration: none;
    border-bottom: 1px dashed rgba(232, 224, 208, 0.25);
    transition: border-color 0.2s ease;
}

.match-repo a:hover { border-color: var(--ink-red); }

.match-score {
    font-family: 'Courier New', Courier, monospace;
    text-align: right;
    color: var(--ink-muted);
}

.match-conf {
    text-transform: uppercase;
    letter-spacing: 0.06rem;
    font-size: 0.75rem;
    font-weight: 700;
}

.match-high .match-conf { color: #4a9; }
.match-mid .match-conf  { color: #b96; }
.match-low .match-conf  { color: #b55; }

.match-high .match-score { color: #4a9; }
.match-mid .match-score  { color: #b96; }
.match-low .match-score  { color: #b55; }

@media (max-width: 980px) {
    .split-layout { grid-template-columns: 1fr; }
    .brand-column { position: static; }
}

@media (max-width: 680px) {
    .editorial-shell {
        width: min(1100px, 92vw);
        padding-top: 1.45rem;
    }
    .language-panel {
        right: 0.7rem;
        top: 0.7rem;
        min-width: 155px;
    }
    h1 { font-size: clamp(2.7rem, 12.5vw, 4.4rem); }
    .section-label, .field-label { letter-spacing: 0.14rem; }
    .match-table { font-size: 0.78rem; }
    .match-table thead th, .match-table tbody td { padding: 0.3rem 0.35rem; }
}
