:root {
  --bg: #f7f7f5; --panel: #ffffff; --side: #efefec; --line: #e2e2dd; --text: #1d1e20; --muted: #6c6d70;
  --accent: #2f5d50; --accent-2: #e6efe9; --user: #2f5d50; --user-text: #ffffff; --bubble: #ffffff;
  --code: #f1f1ee; --danger: #b3261e; --hover: rgba(0,0,0,.05); --shadow: 0 6px 24px rgba(0,0,0,.12);
  --radius: 14px; --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16171a; --panel: #1e1f23; --side: #121316; --line: #2c2d32; --text: #e9e9e7; --muted: #9a9b9f;
    --accent: #7fc4ac; --accent-2: #20302b; --user: #2c4a41; --user-text: #eef6f2; --bubble: #1e1f23;
    --code: #26272c; --danger: #ff8a80; --hover: rgba(255,255,255,.06); --shadow: 0 6px 24px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16171a; --panel: #1e1f23; --side: #121316; --line: #2c2d32; --text: #e9e9e7; --muted: #9a9b9f;
  --accent: #7fc4ac; --accent-2: #20302b; --user: #2c4a41; --user-text: #eef6f2; --bubble: #1e1f23;
  --code: #26272c; --danger: #ff8a80; --hover: rgba(255,255,255,.06); --shadow: 0 6px 24px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
input, textarea, select { font: inherit; color: var(--text); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.err { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 14px; }

.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 8px 14px; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); font-weight: 600; }
.btn.danger { color: var(--danger); }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; background: none; border-radius: 9px; cursor: pointer; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.link-btn { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 4px; }
.link-btn:hover { color: var(--text); }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; display: grid; gap: 12px; text-align: center; background: var(--panel); padding: 32px 24px; border-radius: 18px; border: 1px solid var(--line); }
.login-card img { margin: 0 auto; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; }
.login-card input { padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }

/* layout */
.app { display: flex; height: 100dvh; }
.side { width: 290px; flex: none; background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; gap: 2px; padding: 12px 10px 6px 14px; padding-top: max(12px, env(safe-area-inset-top)); }
.brand { flex: 1; display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.brand-desk { color: var(--accent); }
.side-search { padding: 4px 10px 8px; }
.side-search input { width: 100%; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); }
.list { flex: 1; overflow-y: auto; padding: 0 6px 10px; }
.side-foot { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; padding-bottom: max(8px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.toggle { display: flex; gap: 6px; align-items: center; cursor: pointer; }

.group { margin-top: 10px; }
.group-head { display: flex; align-items: center; gap: 2px; padding: 2px 4px 2px 8px; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.group-head .name { flex: 1; cursor: pointer; display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; user-select: none; }
.group-head .chev { width: 14px; height: 14px; transition: transform .15s; flex: none; }
.group.closed .chev { transform: rotate(-90deg); }
.group.closed .items { display: none; }
.group-head .icon-btn { width: 28px; height: 28px; }
.group-head .icon-btn svg { width: 16px; height: 16px; }
.badge { font-size: 10.5px; font-weight: 600; text-transform: none; letter-spacing: 0; padding: 1px 6px; border-radius: 99px; background: var(--accent-2); color: var(--accent); }
.item { display: flex; align-items: center; gap: 8px; padding: 7px 8px 7px 10px; border-radius: 9px; cursor: pointer; min-height: 40px; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.item:hover { background: var(--hover); }
.item.active { background: var(--panel); box-shadow: 0 0 0 1px var(--line); }
.item .t { flex: 1; min-width: 0; }
.item .t b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .t small { display: block; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.item .spin { width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
.item.archived { opacity: .55; }
.item .pin { width: 13px; height: 13px; color: var(--muted); flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.main-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); background: var(--bg); }
.title-wrap { flex: 1; min-width: 0; }
.chat-title { margin: 0; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-meta { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.chat-meta:empty { display: none; }

.msgs { flex: 1; overflow-y: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain; }
.msg { max-width: min(760px, 100%); width: fit-content; }
.msg.user { align-self: flex-end; max-width: min(620px, 88%); }
.msg.user .bubble { background: var(--user); color: var(--user-text); border-radius: 16px 16px 4px 16px; padding: 9px 13px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user .bubble:empty { display: none; }
.msg.assistant { align-self: flex-start; width: 100%; }
.msg.assistant .bubble { padding: 2px 2px; overflow-wrap: anywhere; }
.msg .time { font-size: 11px; color: var(--muted); margin-top: 3px; }
.msg.user .time { text-align: right; }
.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }
.bubble p { margin: .5em 0; }
.bubble a { color: var(--accent); }
.msg.user .bubble a { color: inherit; }
.bubble pre { background: var(--code); padding: 10px 12px; border-radius: 10px; overflow-x: auto; font: 13px/1.45 var(--mono); position: relative; }
.bubble code { font-family: var(--mono); font-size: .9em; background: var(--code); padding: 1px 5px; border-radius: 5px; }
.bubble pre code { background: none; padding: 0; }
.bubble table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; font-size: 14px; }
.bubble th, .bubble td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; }
.bubble blockquote { margin: .5em 0; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.bubble img { max-width: 100%; border-radius: 10px; }
.copy-btn { position: absolute; top: 6px; right: 6px; font-size: 11px; padding: 2px 7px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer; opacity: 0; }
.bubble pre:hover .copy-btn, .copy-btn:focus { opacity: 1; }
@media (hover: none) { .copy-btn { opacity: 1; } }
.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.msg.user .files { justify-content: flex-end; }
.files img, .files video { max-width: min(360px, 100%); max-height: 360px; border-radius: 12px; display: block; background: var(--code); }
.files audio { width: min(320px, 100%); }
.file-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); text-decoration: none; font-size: 14px; max-width: 100%; }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.typing { align-self: flex-start; display: flex; gap: 4px; padding: 8px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.empty { flex: 1; display: grid; place-content: center; text-align: center; padding: 24px; gap: 8px; max-width: 420px; margin: 0 auto; }
.empty h3 { margin: 0; }
.empty p { margin: 0 0 8px; }

.composer { padding: 8px 12px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.composer-row { display: flex; align-items: flex-end; gap: 4px; max-width: 820px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 5px; }
.composer textarea { flex: 1; border: 0; outline: 0; resize: none; background: none; padding: 8px 6px; max-height: 40vh; line-height: 1.4; font-size: 16px; }
.send-btn { width: 36px; height: 36px; border-radius: 12px; border: 0; background: var(--accent); color: var(--bg); display: grid; place-items: center; cursor: pointer; flex: none; }
.send-btn.stop { background: var(--danger); }
.send-btn:disabled { opacity: .4; cursor: default; }
#btn-mic.rec { color: var(--danger); background: var(--hover); }
.attach-list { display: flex; gap: 6px; flex-wrap: wrap; max-width: 820px; margin: 0 auto 6px; }
.attach-list:empty { display: none; }
.attach { display: inline-flex; gap: 6px; align-items: center; padding: 4px 6px 4px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 99px; font-size: 13px; max-width: 220px; }
.attach span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 4px; font-size: 15px; }

.menu { position: fixed; z-index: 30; min-width: 190px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 5px; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

.dlg { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); padding: 20px; width: min(480px, calc(100vw - 32px)); box-shadow: var(--shadow); }
.dlg::backdrop { background: rgba(0,0,0,.35); }
.dlg h3 { margin: 0 0 14px; }
.dlg label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; }
.dlg .hint { font-size: 12.5px; color: var(--muted); font-weight: 400; margin: 4px 0 0; }
.dlg input[type=text], .dlg select, .dlg textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); }
.dlg textarea { min-height: 110px; resize: vertical; }
.dlg .row { display: flex; gap: 8px; align-items: center; }
.dlg .row select { flex: 1; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.skill-box { max-height: 180px; overflow-y: auto; border: 1px solid var(--line); border-radius: 9px; padding: 6px 8px; background: var(--bg); }
.skill-box label { display: flex; gap: 8px; align-items: center; font-weight: 400; margin: 3px 0; font-size: 14px; }

/* image viewer */
.viewer { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.92); display: flex; flex-direction: column; touch-action: pan-y pinch-zoom; }
.viewer-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); color: #fff; }
.viewer-bar .name { flex: 1; min-width: 0; font-size: 14px; opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-btn { display: inline-flex; align-items: center; gap: 6px; height: 40px; min-width: 40px; justify-content: center; padding: 0 12px; border: 0; border-radius: 99px; background: rgba(255,255,255,.16); color: #fff; font-size: 14px; cursor: pointer; }
.viewer-btn svg { width: 20px; height: 20px; }
.viewer-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px 8px max(16px, env(safe-area-inset-bottom)); overflow: auto; }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; transition: transform .15s; user-select: none; -webkit-user-select: none; }

/* message actions */
.msg .time { display: flex; gap: 10px; align-items: center; }
.msg.user .time { justify-content: flex-end; }
.msg-act { border: 0; background: none; color: var(--muted); font-size: 11.5px; padding: 0; cursor: pointer; }
.msg-act:hover { color: var(--text); }
.files img { cursor: zoom-in; }
.media-box { display: flex; flex-direction: column; gap: 6px; max-width: min(360px, 100%); }
.msg.user .media-box { align-items: flex-end; }
.media-share { align-self: flex-start; font-size: 13px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 99px; background: var(--panel); color: var(--text); }
.msg.user .media-share { align-self: flex-end; }
.send-btn.sending { opacity: .6; cursor: progress; }
.send-btn.sending svg { animation: spin .9s linear infinite; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 14px; border-radius: 10px; font-size: 14px; z-index: 40; max-width: calc(100vw - 32px); }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 19; }
.only-mobile { display: none; }

@media (max-width: 760px), (pointer: coarse) {
  /* iOS zooms the page when a focused field is under 16px */
  input, textarea, select { font-size: 16px !important; }
}
.app { height: var(--app-h, 100dvh); }

.foot-actions { display: flex; gap: 6px; }
.badge-secret { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.msg .author { font-size: 12px; color: var(--muted); margin: 0 4px 2px; text-align: right; }
.user-row { padding: 8px 0; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
.user-row .row { flex-wrap: wrap; }
.dlg .row { flex-wrap: wrap; }
.dlg .row select { flex: 1 1 120px; min-width: 110px; }
.dlg .row .btn { flex: none; }
.user-row select { flex: 1 1 110px; }
.dlg input.num { width: 84px; flex: none; }
.dlg .row input[type=email] { flex: 1 1 160px; width: auto; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); }
.dlg input[type=email], .dlg input[type=number] { padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); width: 100%; }
.small { font-size: 12.5px; }
.msg-act.extra { display: none; }
.msg.act-open .msg-act.extra, .msg:focus-within .msg-act.extra { display: inline; }
@media (hover: hover) { .msg:hover .msg-act.extra { display: inline; } }
/* Edit / resend only on the latest user message (older ones: copy + delete) */
.msg.user:not(.latest) .msg-act.resend { display: none !important; }
.older-btn { align-self: center; border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 99px; padding: 5px 14px; font-size: 13px; cursor: pointer; }
.older-btn:hover { color: var(--text); }
.search-filter { padding: 0 4px 6px; }
.search-filter select { width: 100%; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); font-size: 13px; }
mark { background: var(--accent-2); color: var(--text); border-radius: 3px; padding: 0 1px; }
.rec-bar { display: flex; align-items: center; gap: 10px; max-width: 820px; margin: 0 auto 6px; padding: 6px 8px 6px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); font-size: 14px; }
.rec-bar .rec-time { font-variant-numeric: tabular-nums; flex: 1; color: var(--muted); }
.rec-bar .btn { padding: 5px 12px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1.2s infinite; }
.attach-audio { height: 32px; max-width: 200px; }
.attach:has(audio) { max-width: 280px; }
.audit-row { padding: 6px 0; }
.audit-row.warn b { color: var(--danger); }
.item:focus-visible, .group-head .name:focus-visible, .menu button:focus-visible, .msg-act:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (prefers-reduced-motion: reduce) { .rec-dot, .typing i, .item .spin { animation: none; } }
.preset-list { display: grid; gap: 8px; }
.preset-card { display: grid; gap: 2px; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); cursor: pointer; }
.preset-card:hover, .preset-card:focus-visible { border-color: var(--accent); }
.preset-card b { font-weight: 600; }
.preset-card span, .preset-card small { font-size: 13px; }
.warn { color: var(--danger); }
.settings { display: grid; gap: 18px; }
.set-sec h4 { margin: 0 0 8px; font-size: 15px; }
.set-sec h5 { margin: 14px 0 6px; font-size: 13px; color: var(--muted); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 4px 0; }
.set-row > span { min-width: 0; }
.sess-list { display: grid; border-top: 1px solid var(--line); }
.sess-list .set-row { border-bottom: 1px solid var(--line); padding: 8px 0; }
.danger-text { color: var(--danger); }
.model-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-top: 8px; background: var(--bg); }
.model-card .hint { margin: 6px 0 0; }
.totp-key { display: block; font-size: 15px; letter-spacing: .06em; padding: 8px 10px; margin: 6px 0; word-break: break-all; }
pre.recovery { background: var(--code); padding: 10px 12px; border-radius: 10px; font: 14px/1.6 var(--mono); }
.dlg input[type=date], .dlg input[type=file] { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); }
.badge-btn { border: 0; cursor: pointer; font: inherit; font-size: 10.5px; font-weight: 600; }
.badge-btn:hover, .badge-btn:focus-visible { outline: 1px solid var(--accent); }
.chat-meta .badge-btn { font-size: 12px; padding: 2px 8px; }

@media (max-width: 760px) {
  .only-mobile { display: inline-grid; }
  /* Dialogs sit at the top of the VISIBLE area (above the iOS keyboard), not mid-screen. */
  .dlg { margin: calc(var(--vv-top, 0px) + 10px) auto auto; max-height: calc(var(--vv-h, 100dvh) - 20px); overflow-y: auto; padding: 16px; }
  .dlg textarea { min-height: 80px; }
  .side { position: fixed; z-index: 20; inset: 0 auto 0 0; width: min(86vw, 320px); transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .msgs { padding: 14px 12px 6px; }
  .main-head { padding-left: 6px; }
}

/* ---------------------------------------------------------------- HavaDesk: Spaces + tabs */
.group.space { margin-top: 8px; }
.group.space > .group-head .name { text-transform: none; letter-spacing: 0; font-size: 13.5px; color: var(--text); }
.space-icon { font-size: 13px; flex: none; }
.space-name { overflow: hidden; text-overflow: ellipsis; }
.sec-head { display: flex; align-items: center; gap: 2px; padding: 0 4px 0 18px; min-height: 30px; color: var(--muted);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.sec-name { flex: 1; display: flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; min-height: 28px; }
.sec-name .chev { width: 12px; height: 12px; transition: transform .15s; }
.sec-head.closed .chev { transform: rotate(-90deg); }
.sec-count { font-weight: 500; background: var(--line); color: var(--muted); border-radius: 99px; padding: 0 6px; font-size: 10.5px; letter-spacing: 0; }
.sec-head .icon-btn { width: 26px; height: 26px; }
.sec-head .icon-btn svg { width: 15px; height: 15px; }
.sec-body { padding-left: 10px; }
.sec-empty { font-size: 12.5px; min-height: 32px; cursor: default; }
.sec-empty:hover { background: none; }
.file-item { min-height: 36px; padding-top: 5px; padding-bottom: 5px; }
.file-item .t b { font-size: 13.5px; }
.file-item .t small { font-size: 11.5px; }
.fi-icon { flex: none; width: 20px; text-align: center; font-size: 15px; }

.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 6px 10px 0; border-bottom: 1px solid var(--line); background: var(--side);
  scrollbar-width: none; flex: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: flex; align-items: center; gap: 6px; max-width: 220px; min-width: 0; height: 34px; padding: 0 4px 0 10px; border: 1px solid transparent;
  border-bottom: 0; border-radius: 9px 9px 0 0; color: var(--muted); font-size: 13px; cursor: pointer; flex: none; user-select: none; }
.tab:hover { background: var(--hover); color: var(--text); }
.tab.active { background: var(--bg); border-color: var(--line); color: var(--text); margin-bottom: -1px; height: 35px; }
.tab-icon { flex: none; font-size: 13px; }
.tab-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tab .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.tab-close { flex: none; width: 24px; height: 24px; border: 0; border-radius: 6px; background: none; color: inherit; font-size: 17px; line-height: 1; cursor: pointer; opacity: .55; }
.tab-close:hover { opacity: 1; background: var(--line); }

.file-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.fv-bar { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.fv-kind { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .04em; }
.fv-spacer { flex: 1; }
.fv-bar .btn { height: 34px; padding: 0 14px; font-size: 13.5px; }
.fv-body { flex: 1; min-height: 0; overflow: auto; padding: 16px; }
.fv-pdf, .fv-html { padding: 0; display: flex; flex-direction: column; }
.fv-frame { flex: 1; width: 100%; min-height: 60vh; border: 0; background: #fff; }
.fv-img { display: block; max-width: 100%; max-height: 100%; margin: 0 auto; border-radius: 8px; }
.fv-media { display: block; width: 100%; max-width: 900px; margin: 0 auto; }
.fv-doc { max-width: 860px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px 26px; }
.fv-doc img { max-width: 100%; }
.fv-pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.fv-note { margin: 8px 16px; font-size: 13px; }
.fv-none { display: grid; place-items: center; min-height: 40vh; color: var(--muted); text-align: center; padding: 24px; }
.fv-sheets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { height: 30px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 13px; cursor: pointer; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.fv-sheet { overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.fv-sheet table { border-collapse: collapse; font-size: 13px; }
.fv-sheet td, .fv-sheet th { border: 1px solid var(--line); padding: 4px 8px; white-space: nowrap; }
.fv-slides { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.fv-slide { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 20px; }
.fv-slide-no { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.fv-slide h4 { margin: 0 0 6px; font-size: 17px; }
.fv-slide ul { margin: 0; padding-left: 20px; }
.fv-slide-pics { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.fv-slide-pics img { max-height: 140px; max-width: 48%; border-radius: 8px; border: 1px solid var(--line); }

.space-kinds { display: grid; gap: 8px; }
.space-kind { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.space-kind:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.space-kind input { margin-top: 3px; }
.space-kind b { display: block; }
.space-kind small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.45; margin-top: 2px; }
.space-kind.disabled { opacity: .55; cursor: not-allowed; }

@media (max-width: 760px), (pointer: coarse) {
  .tabs { padding: 4px 6px 0; }
  .tab { max-width: 160px; height: 38px; }
  .tab.active { height: 39px; }
  .tab-close { width: 30px; height: 30px; }
  .fv-body:not(.fv-pdf):not(.fv-html) { padding: 10px; }
  .fv-doc { padding: 16px; }
}
