/* ============================================================================
   code-share-view.css — the Delphos Code share-link viewer.

   ── Why it is separate from delphos-code.css ──
   The recipient is not a Delphos user. They have no theme preference stored, no
   accent choice, and no signed-in session, so this view cannot depend on the
   runtime tokens ui-polish.js writes for a logged-in user. Every value here is a
   literal in the app's warm-graphite family, with the app's tokens used only as
   an OPTIONAL override — so it looks right for a stranger on a cold load and
   still tracks the theme when an owner opens their own link.

   ── Layout ──
     .csv-top    project identity · mode badge · Preview/Code tabs   (52px)
     .csv-body   file list ║ preview-or-editor
     .csv-foot   the honest statement of what this link can and cannot do
   ========================================================================== */

/* The host page is the full Delphos SPA. A recipient must see none of it. */
body.delphos-share-view { overflow: hidden !important; }
body.delphos-share-view > *:not(.csv) { display: none !important; }

.csv {
    --csv-bg: var(--chat-area-background, #201f1d);
    --csv-raised: var(--light-dark-background, #242321);
    --csv-control: var(--secondary-color, #2a2927);
    --csv-hover: var(--secondary-hover-color, #353330);
    --csv-line: var(--border-color, rgba(245, 238, 230, .1));
    --csv-text: var(--text-color, #eeeae5);
    --csv-muted: var(--subheading-color, #aaa39b);
    --csv-faint: var(--placeholder-color, #938d86);
    --csv-accent: var(--accent, #b7795c);
    --csv-accent-strong: var(--accent-strong, #975d46);
    --csv-accent-contrast: var(--accent-contrast, #fff);
    --csv-soft: var(--accent-soft, rgba(183, 121, 92, .14));
    --csv-ring: var(--accent-ring, rgba(183, 121, 92, .4));
    --csv-warn: #d29922;
    --csv-bad: #f85149;
    --csv-good: #3fb950;
    --csv-mono: ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
    --csv-ease: var(--ui-ease, cubic-bezier(.22, .61, .36, 1));

    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    background: var(--csv-bg);
    color: var(--csv-text);
    font-family: var(--font, system-ui, -apple-system, 'Segoe UI', sans-serif);
    font-size: 13.5px;
    line-height: 1.55;
}
.csv *, .csv *::before, .csv *::after { box-sizing: border-box; min-width: 0; }
.csv [hidden] { display: none !important; }
.csv button { font-family: inherit; font-size: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
.csv :focus-visible { outline: 2px solid var(--csv-ring); outline-offset: 2px; border-radius: 5px; }
.csv .material-symbols-rounded {
    font-family: 'Material Symbols Rounded', 'Material Icons';
    font-weight: normal; font-style: normal; letter-spacing: normal;
    text-transform: none; font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased; user-select: none; flex: none;
}

/* ── top bar ─────────────────────────────────────────────────────────────── */
.csv-top {
    flex: none;
    display: flex; align-items: center; gap: 10px;
    height: 52px; padding: 0 14px;
    background: var(--csv-raised);
    border-bottom: 1px solid var(--csv-line);
}
.csv-brand { font-size: 14px; font-weight: 500; color: var(--csv-muted); white-space: nowrap; }
.csv-brand b { color: var(--csv-text); font-weight: 650; }
.csv-divider { width: 1px; height: 18px; background: var(--csv-line); flex: none; }
.csv-title {
    font-size: 14px; font-weight: 640; letter-spacing: -.01em;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34ch;
}
.csv-spacer { flex: 1 1 auto; }

.csv-chip {
    flex: none; padding: 2px 8px; border-radius: 999px;
    font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    color: var(--csv-accent); background: var(--csv-soft);
}

/* The mode badge is the most important thing in this bar: a recipient must be
   able to tell at a glance whether they can change anything. */
.csv-mode {
    flex: none;
    display: inline-flex; align-items: center; gap: 5px;
    height: 24px; padding: 0 9px; border-radius: 999px;
    font-size: 11.5px; font-weight: 650;
    color: var(--csv-muted); background: rgba(245, 238, 230, .06);
}
.csv-mode .material-symbols-rounded { font-size: 15px; }
.csv-mode.edit { color: var(--csv-warn); background: rgba(210, 153, 34, .14); }

.csv-segs {
    display: inline-flex; align-items: center; gap: 2px; flex: none;
    padding: 3px; border-radius: 999px;
    background: var(--csv-control); border: 1px solid var(--csv-line);
}
.csv-seg {
    height: 26px; padding: 0 13px; border-radius: 999px;
    font-size: 12px; font-weight: 600; color: var(--csv-muted);
    transition: color .13s var(--csv-ease), background-color .13s var(--csv-ease);
}
.csv-seg:hover { color: var(--csv-text); }
.csv-seg.is-on { color: var(--csv-accent); background: var(--csv-soft); }

.csv-iconbtn {
    flex: none; width: 30px; height: 30px;
    display: grid; place-items: center; border-radius: 8px;
    color: var(--csv-muted);
    transition: color .13s var(--csv-ease), background-color .13s var(--csv-ease);
}
.csv-iconbtn:hover { color: var(--csv-text); background: var(--csv-hover); }
.csv-iconbtn .material-symbols-rounded { font-size: 19px; }

/* ── body ────────────────────────────────────────────────────────────────── */
.csv-body { flex: 1; display: flex; min-height: 0; }

.csv-files {
    flex: none; width: 264px;
    display: flex; flex-direction: column;
    padding: 8px;
    overflow: auto;
    background: var(--csv-raised);
    border-right: 1px solid var(--csv-line);
}
.csv-files-head {
    padding: 6px 8px 10px;
    font-size: 10.5px; font-weight: 700;
    letter-spacing: .08em; text-transform: uppercase;
    color: var(--csv-faint);
}
.csv-file {
    display: flex; align-items: center; gap: 8px;
    width: 100%; min-height: 30px; padding: 4px 8px;
    border-radius: 7px;
    font-size: 12.5px; color: var(--csv-muted); text-align: left;
    transition: color .13s var(--csv-ease), background-color .13s var(--csv-ease);
}
.csv-file:hover:not(:disabled) { background: var(--csv-hover); color: var(--csv-text); }
.csv-file.is-on { background: var(--csv-soft); color: var(--csv-accent); }
.csv-file .material-symbols-rounded { font-size: 16px; color: var(--csv-faint); }
.csv-file.is-on .material-symbols-rounded { color: var(--csv-accent); }
/* Binary files are listed but not openable — hiding them would misrepresent the
   project, so they are shown and visibly inert instead. */
.csv-file.is-binary { opacity: .55; cursor: default; }
.csv-file-path {
    flex: 1; font-family: var(--csv-mono); font-size: 11.5px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left;
}
.csv-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--csv-warn); }

.csv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.csv-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.csv-pane iframe { flex: 1; width: 100%; border: 0; background: #fff; }

.csv-code-bar {
    flex: none;
    display: flex; align-items: center; gap: 10px;
    height: 40px; padding: 0 12px;
    background: var(--csv-raised);
    border-bottom: 1px solid var(--csv-line);
}
.csv-code-path {
    font-family: var(--csv-mono); font-size: 11.5px; color: var(--csv-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.csv-saved { font-size: 11.5px; color: var(--csv-good); }
.csv-saved.is-bad { color: var(--csv-bad); }

.csv-editor {
    flex: 1; width: 100%;
    padding: 14px 16px;
    background: var(--csv-bg); color: var(--csv-text);
    border: 0; outline: none; resize: none;
    font-family: var(--csv-mono); font-size: 13px; line-height: 1.65;
    tab-size: 2;
}
.csv-editor[readonly] { color: var(--csv-muted); }

/* ── footer ──────────────────────────────────────────────────────────────
   The limits statement. Kept permanently visible rather than behind an info
   icon: it is what makes opening a stranger's link a reasonable thing to do. */
.csv-foot {
    flex: none;
    display: flex; align-items: center; gap: 8px;
    padding: 8px 14px;
    font-size: 11.5px; color: var(--csv-faint);
    background: var(--csv-raised);
    border-top: 1px solid var(--csv-line);
}
.csv-foot .material-symbols-rounded { font-size: 15px; color: var(--csv-good); }

/* ── notices (loading, expired, revoked, passcode) ───────────────────────── */
.csv-notice { flex: 1; display: grid; place-items: center; padding: 28px; }
.csv-notice-card {
    width: min(430px, 100%);
    display: flex; flex-direction: column; align-items: center;
    padding: 30px 28px;
    text-align: center;
    background: var(--csv-raised);
    border: 1px solid var(--csv-line);
    border-radius: 16px;
    box-shadow: var(--ui-shadow-lg, 0 24px 70px rgba(0, 0, 0, .5));
    animation: csv-pop 280ms var(--csv-ease);
}
@keyframes csv-pop {
    from { opacity: 0; transform: translateY(12px) scale(.97); }
    to { opacity: 1; transform: none; }
}
.csv-notice-ico {
    width: 46px; height: 46px; margin-bottom: 16px;
    display: grid; place-items: center;
    font-size: 24px; color: var(--csv-accent);
    background: var(--csv-soft); border-radius: 13px;
}
.csv-notice-card h1 { margin: 0 0 8px; font-size: 19px; font-weight: 650; letter-spacing: -.015em; }
.csv-notice-card p { margin: 0; font-size: 13px; color: var(--csv-muted); line-height: 1.6; }
.csv-notice-card p.csv-error { margin-top: 10px; color: var(--csv-bad); font-weight: 600; }

.csv-input {
    width: 100%; height: 40px; margin-top: 18px; padding: 0 12px;
    color: var(--csv-text); background: var(--csv-control);
    border: 1px solid var(--csv-line); border-radius: 9px;
    font: inherit; font-size: 14px; text-align: center; letter-spacing: .08em;
    outline: none;
    transition: border-color .13s var(--csv-ease), box-shadow .13s var(--csv-ease);
}
.csv-input:focus { border-color: var(--csv-ring); box-shadow: 0 0 0 3px var(--csv-soft); }

.csv-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 38px; margin-top: 16px; padding: 0 18px;
    font: inherit; font-size: 13px; font-weight: 600;
    color: var(--csv-text);
    background: var(--csv-control);
    border: 1px solid var(--csv-line); border-radius: 10px;
    transition: background-color .13s var(--csv-ease);
}
.csv-btn:hover:not(:disabled) { background: var(--csv-hover); }
.csv-btn.primary { color: var(--csv-accent-contrast); background: var(--csv-accent); border-color: transparent; }
.csv-btn.primary:hover:not(:disabled) { background: var(--csv-accent-strong); }
.csv-btn:disabled { opacity: .5; cursor: not-allowed; }
.csv-btn .material-symbols-rounded { font-size: 17px; }
/* In the code bar the button sits on a 40px row, so it shrinks to fit rather
   than stretching the bar. */
.csv-code-bar .csv-btn { height: 28px; margin: 0; padding: 0 11px; }

.csv-spin {
    width: 13px; height: 13px; flex: none;
    border: 2px solid currentColor; border-right-color: transparent;
    border-radius: 50%;
    animation: csv-spin .7s linear infinite;
}
@keyframes csv-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .csv, .csv * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── narrow windows ──────────────────────────────────────────────────────
   The file list becomes a short horizontal strip so the preview keeps the
   height, which is the scarce dimension on a phone. */
@media (max-width: 780px) {
    .csv-body { flex-direction: column; }
    .csv-files { width: 100%; max-height: 148px; border-right: 0; border-bottom: 1px solid var(--csv-line); }
    .csv-title { max-width: 16ch; }
    .csv-brand { display: none; }
    .csv-divider { display: none; }
}
