/* ==========================================================
   Studio Copilot — Rhino & Illustrator work plans
   ========================================================== */

:root {
    --bg: #faf9f7;
    --bg-alt: #f2f0ec;
    --bg-card: #ffffff;
    --ink: #1a1a1a;
    --text-2: #6b6b6b;
    --text-3: #999;
    --accent: #c5a47e;
    --accent-dark: #8b7355;
    --accent-soft: rgba(197, 164, 126, 0.14);
    --danger: #b3402e;
    --ok: #4a7c59;
    --border: #e0ddd8;
    --border-strong: #c9c4bb;
    --shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.12);
    --serif: 'Playfair Display', Georgia, serif;
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
    --transition: 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --radius: 10px;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── Header ────────────────────────────────────────────── */
.header {
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--ink);
    color: var(--bg);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.brand-mark svg { width: 26px; height: 26px; }

.brand h1 {
    font-family: var(--serif);
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.2;
}

.brand p {
    font-size: 0.78rem;
    color: var(--text-2);
    letter-spacing: 0.02em;
}

/* ── Buttons ───────────────────────────────────────────── */
.btn {
    font-family: var(--sans);
    font-size: 0.88rem;
    font-weight: 500;
    padding: 10px 18px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--ink);
    color: var(--bg);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-ghost {
    background: transparent;
    color: var(--ink);
    border-color: var(--border-strong);
}

.btn-ghost:hover { border-color: var(--ink); background: var(--bg-card); }

.icon-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-2);
    padding: 4px 8px;
    border-radius: 6px;
    transition: var(--transition);
}

.icon-btn:hover { color: var(--ink); background: var(--bg-alt); }

.settings-btn { flex-shrink: 0; }

/* ── Layout ────────────────────────────────────────────── */
.main {
    max-width: 1440px;
    margin: 0 auto;
    padding: 32px 28px 60px;
    display: grid;
    grid-template-columns: minmax(360px, 460px) 1fr;
    gap: 28px;
    align-items: start;
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.panel-input { position: sticky; top: 92px; }

.panel-output { min-height: 70vh; }

.panel-title {
    font-family: var(--serif);
    font-size: 1.05rem;
    font-weight: 600;
    margin: 26px 0 12px;
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.panel-title:first-child { margin-top: 0; }

.panel-title-note {
    font-family: var(--sans);
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--text-3);
}

/* ── Input widgets ─────────────────────────────────────── */
textarea, input[type="text"], input[type="password"], select {
    width: 100%;
    font-family: var(--sans);
    font-size: 0.92rem;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 12px 14px;
    transition: var(--transition);
    outline: none;
}

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

textarea { resize: vertical; min-height: 110px; line-height: 1.55; }

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.chips button {
    font-family: var(--sans);
    font-size: 0.78rem;
    font-weight: 500;
    padding: 6px 13px;
    border-radius: 100px;
    border: 1px solid var(--border-strong);
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    transition: var(--transition);
}

.chips button:hover {
    border-color: var(--accent-dark);
    color: var(--accent-dark);
    background: var(--accent-soft);
}

/* Dropzone */
.dropzone {
    margin-top: 4px;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 26px 16px;
    text-align: center;
    cursor: pointer;
    color: var(--text-2);
    transition: var(--transition);
    background: var(--bg);
}

.dropzone:hover, .dropzone:focus-visible, .dropzone.dragover {
    border-color: var(--accent-dark);
    background: var(--accent-soft);
    color: var(--accent-dark);
    outline: none;
}

.dropzone p { font-size: 0.88rem; margin-top: 8px; }
.dropzone p strong { color: inherit; }
.dropzone-sub { font-size: 0.74rem !important; color: var(--text-3); }

.thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.thumb {
    position: relative;
    width: 74px;
    height: 74px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.thumb-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: rgba(26, 26, 26, 0.82);
    color: #fff;
    font-size: 0.72rem;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
}

/* Deliverables */
.deliverables {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
}

.deliverables label {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 0.85rem;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.deliverables label:hover { border-color: var(--accent-dark); }

.deliverables input[type="checkbox"] {
    accent-color: var(--accent-dark);
    width: 15px;
    height: 15px;
}

.deliverables label:has(input:checked) {
    background: var(--accent-soft);
    border-color: var(--accent-dark);
}

/* Fields */
.row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 22px;
}

.field { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.row-2 .field { margin-top: 0; }

.field > span {
    font-size: 0.76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-2);
}

.field > span em {
    font-style: normal;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-3);
}

/* Generate */
.btn-generate {
    width: 100%;
    margin-top: 24px;
    padding: 14px;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(250, 249, 247, 0.3);
    border-top-color: var(--bg);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.error-msg {
    margin-top: 12px;
    font-size: 0.84rem;
    color: var(--danger);
    background: rgba(179, 64, 46, 0.08);
    border: 1px solid rgba(179, 64, 46, 0.25);
    border-radius: 8px;
    padding: 10px 14px;
}

/* ── Output states ─────────────────────────────────────── */
.output-empty {
    height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-2);
    gap: 10px;
    padding: 20px;
}

.output-empty h3 { font-family: var(--serif); font-size: 1.3rem; color: var(--ink); }
.output-empty p { max-width: 420px; font-size: 0.9rem; }
.output-empty svg { color: var(--accent); margin-bottom: 6px; }

.output-loading {
    height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 26px;
    color: var(--text-2);
    font-size: 0.9rem;
}

.loading-grid {
    display: grid;
    grid-template-columns: repeat(3, 34px);
    gap: 7px;
}

.loading-grid span {
    width: 34px;
    height: 34px;
    border: 1.5px solid var(--border-strong);
    border-radius: 4px;
    animation: pulse 1.4s ease-in-out infinite;
}

.loading-grid span:nth-child(2n) { animation-delay: 0.15s; background: var(--accent-soft); }
.loading-grid span:nth-child(3n) { animation-delay: 0.3s; }
.loading-grid span:nth-child(5n) { animation-delay: 0.45s; }

@keyframes pulse {
    0%, 100% { opacity: 0.35; transform: scale(0.96); }
    50% { opacity: 1; transform: scale(1); }
}

.output-error {
    margin: 30px;
    padding: 18px 22px;
    border: 1px solid rgba(179, 64, 46, 0.3);
    background: rgba(179, 64, 46, 0.06);
    border-radius: var(--radius);
    color: var(--danger);
    font-size: 0.9rem;
    white-space: pre-wrap;
}

/* ── Rendered document ─────────────────────────────────── */
.output-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 26px;
}

.output-actions .btn { padding: 8px 14px; font-size: 0.8rem; }

.doc {
    font-size: 0.93rem;
    line-height: 1.7;
    animation: fadeUp 0.45s ease both;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

.doc h1 {
    font-family: var(--serif);
    font-size: 1.7rem;
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: 6px;
}

.doc h2 {
    font-family: var(--serif);
    font-size: 1.25rem;
    font-weight: 600;
    margin: 34px 0 12px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.doc h3 {
    font-family: var(--sans);
    font-size: 0.95rem;
    font-weight: 700;
    margin: 22px 0 8px;
}

.doc h4 { font-size: 0.88rem; margin: 16px 0 6px; }

.doc p { margin: 10px 0; color: var(--ink); }

.doc blockquote {
    margin: 14px 0;
    padding: 12px 18px;
    border-left: 3px solid var(--accent);
    background: var(--accent-soft);
    border-radius: 0 8px 8px 0;
    color: var(--text-2);
    font-size: 0.88rem;
}

.doc ul, .doc ol { margin: 10px 0 10px 24px; }

.doc li { margin: 6px 0; }

.doc li::marker { color: var(--accent-dark); }

/* Checkbox list */
.doc li.task { list-style: none; margin-left: -20px; display: flex; gap: 10px; align-items: flex-start; }
.doc li.task .box {
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    border: 1.5px solid var(--border-strong);
    border-radius: 4px;
    margin-top: 4px;
}
.doc li.task.done .box { background: var(--accent-dark); border-color: var(--accent-dark); }

/* Tables */
.doc .table-wrap { overflow-x: auto; margin: 14px 0; }

.doc table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.doc th {
    text-align: left;
    font-weight: 600;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    padding: 9px 12px;
    white-space: nowrap;
}

.doc td {
    border: 1px solid var(--border);
    padding: 9px 12px;
    vertical-align: top;
}

.doc td:first-child { white-space: nowrap; }

/* Inline code & blocks */
.doc code {
    font-family: var(--mono);
    font-size: 0.82em;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 1.5px 6px;
    color: var(--accent-dark);
    white-space: nowrap;
}

.doc pre {
    background: #1e1e1e;
    color: #e8e6e1;
    border-radius: 8px;
    padding: 16px 18px;
    overflow-x: auto;
    margin: 14px 0;
    font-size: 0.8rem;
    line-height: 1.6;
}

.doc pre code {
    background: none;
    border: none;
    color: inherit;
    padding: 0;
    white-space: pre;
}

.doc hr { border: none; border-top: 1px solid var(--border); margin: 26px 0; }

.doc strong { font-weight: 600; }

/* ── Settings drawer ───────────────────────────────────── */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(26, 26, 26, 0.4);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
    z-index: 90;
}

.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(440px, 92vw);
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    padding: 28px;
    overflow-y: auto;
    transform: translateX(100%);
    transition: var(--transition);
}

.drawer.open { transform: translateX(0); }

.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.drawer-head h2 { font-family: var(--serif); font-size: 1.3rem; }

.drawer-note {
    font-size: 0.84rem;
    color: var(--text-2);
    background: var(--bg-alt);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 20px;
}

.drawer-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 22px;
}

.drawer-warning {
    margin-top: 18px;
    font-size: 0.76rem;
    color: var(--text-3);
}

.conn-badge {
    font-size: 0.76rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 100px;
    background: var(--bg-alt);
    color: var(--text-2);
}

.conn-badge.on { background: rgba(74, 124, 89, 0.12); color: var(--ok); }

.key-row { display: flex; gap: 8px; }
.key-row input { flex: 1; }
.key-row .icon-btn { border: 1px solid var(--border-strong); border-radius: var(--radius); font-size: 0.95rem; }

/* ── Footer ────────────────────────────────────────────── */
.footer {
    border-top: 1px solid var(--border);
    padding: 20px 28px 28px;
    text-align: center;
}

.footer p { font-size: 0.74rem; color: var(--text-3); }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 980px) {
    .main { grid-template-columns: 1fr; padding: 20px 16px 40px; }
    .panel { padding: 20px; }
    .panel-input { position: static; }
    .header-inner { padding: 14px 16px; }
    .brand p { display: none; }
    .row-2 { grid-template-columns: 1fr; }
    .output-empty, .output-loading { height: 40vh; }
}

/* ── Print ─────────────────────────────────────────────── */
@media print {
    .no-print, .header, .panel-input, .footer, .drawer, .drawer-backdrop, .output-actions { display: none !important; }
    body { background: #fff; }
    .main { display: block; padding: 0; max-width: none; }
    .panel { border: none; box-shadow: none; padding: 0; }
    .doc h2 { break-after: avoid; }
    .doc table, .doc pre { break-inside: avoid; }
    .doc code { white-space: normal; }
}
