:root {
  --ink: #222;
  --muted: #555;
  --line: #444;
  --soft: #aaa;
  --bg: #f3f3f1;
  --panel: #fff;
  --tint: #e9e9e6;
  --blue: #1f4fd1;
  --blue-dark: #173ba0;
  --warn-bg: #fff4d6;
  --warn-line: #b7791f;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'IBM Plex Sans', system-ui, sans-serif; color: var(--ink); background: var(--bg); line-height: 1.45; }
h1, h2, h3 { margin: 0; }
button, input, textarea, select { font-family: inherit; font-size: 15px; color: inherit; }
code { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 13px; background: var(--tint); padding: 1px 5px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* Header */
.top { background: var(--panel); border-bottom: 2px solid var(--line); }
.top-inner { max-width: 1600px; margin: 0 auto; padding: 14px 24px; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 36px; }
.brand { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.logo { width: 44px; height: 44px; border: 2px solid var(--line); border-radius: 8px; background: #d9d9d6; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; }
.brand-name { font-size: 22px; font-weight: 600; }
.tabs { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; flex: 1 1 auto; }
.tab { display: flex; align-items: center; min-height: 44px; padding: 0 18px; border: 2px solid var(--line); border-radius: 8px; background: #fff; font-size: 15px; font-weight: 500; color: var(--ink); text-decoration: none; }
.tab-on { background: #222; color: #fff; }
.tab-off { border-color: var(--soft); color: #6a6a6a; border-style: dashed; cursor: not-allowed; }
.feynman { border: 2px dashed #888; border-radius: 10px; padding: 6px 10px 10px; display: flex; flex-direction: column; gap: 6px; }
.feynman-label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.feynman-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.who { display: flex; align-items: center; gap: 10px; min-height: 48px; font-weight: 500; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #d9d9d6; border: 2px solid var(--line); }

/* Layout: queue on the left; on the right the ticket, then chats side by side, then console + notes */
.layout { max-width: 1600px; margin: 0 auto; padding: 24px; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 24px; }
.main-col { flex: 1 1 640px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.chat-row, .work-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: stretch; }
.panel { background: var(--panel); border: 2px solid var(--line); border-radius: 8px; padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.eyebrow { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 0; }

/* Queue */
.queue { flex: 0 0 220px; }
.queue-closed { flex: 0 0 60px; align-items: center; padding: 10px 6px; }
.vertical-label { writing-mode: vertical-rl; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding-bottom: 8px; }
.queue-list { display: flex; flex-direction: column; gap: 10px; }
.q-item { width: 100%; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 6px; padding: 12px; min-height: 44px; border: 2px solid var(--soft); border-radius: 6px; background: #fff; font-weight: 500; }
.q-item[aria-current="true"] { border-color: #222; background: var(--tint); font-weight: 600; }
.q-item:disabled { cursor: not-allowed; color: #6a6a6a; border-style: dashed; }
.q-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.q-status { font-size: 12px; border: 2px solid #888; border-radius: 999px; padding: 0 9px; background: #fff; }
.q-prev { font-size: 13px; font-weight: 400; color: var(--muted); }
.icon-btn { width: 44px; height: 44px; flex: none; cursor: pointer; border: 2px solid var(--line); border-radius: 6px; background: #fff; display: flex; align-items: center; justify-content: center; }

/* Buttons */
.btn { min-height: 44px; padding: 0 18px; border: 2px solid var(--line); border-radius: 8px; font-weight: 600; cursor: pointer; background: #fff; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); }
.btn-ghost:hover { background: var(--tint); }
.btn:disabled, .tool:disabled { opacity: .55; cursor: not-allowed; }

/* Current ticket */
.ticket-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 32px; }
.ticket-line { display: flex; flex-wrap: wrap; gap: 4px 24px; align-items: baseline; }
.ticket-actions { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; }
.ticket-num { font-size: 24px; font-weight: 600; }
.ticket-user { font-size: 16px; color: var(--muted); }
.ticket-user strong { color: var(--ink); font-weight: 500; }
.user-message { border: 2px solid #888; border-radius: 6px; background: #f7f7f5; padding: 10px 16px; font-size: 16px; }
.timer-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.timer { font-size: 22px; font-weight: 600; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.switch { width: 64px; height: 44px; padding: 0 6px; cursor: pointer; border: 2px solid #222; border-radius: 999px; background: #222; display: flex; align-items: center; justify-content: flex-end; }
.switch .knob { width: 28px; height: 28px; border-radius: 50%; background: #fff; }
.switch[aria-checked="false"] { background: #fff; border-color: #888; justify-content: flex-start; }
.switch[aria-checked="false"] .knob { background: #aaa; }

/* Chats */
.chat { height: clamp(520px, 66vh, 780px); }
.messages { flex: 1 1 auto; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 2px; }
.msg { max-width: 92%; border-radius: 10px; padding: 10px 14px; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .who-tag { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg-them { align-self: flex-start; background: var(--tint); border: 2px solid var(--soft); }
.msg-coach { align-self: flex-start; background: #fff; border: 2px dashed var(--line); }
.msg-me { align-self: flex-end; background: #fff; border: 2px solid var(--line); }
.msg-err { align-self: stretch; max-width: 100%; background: var(--warn-bg); border: 2px solid var(--warn-line); font-size: 14px; }
.msg-typing { align-self: flex-start; color: var(--muted); border: 2px dashed #888; font-size: 14px; }
.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1 1 auto; min-width: 0; min-height: 52px; max-height: 180px; resize: none; line-height: 1.4; }
.composer .btn { height: 52px; }
.hint { margin-top: -6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn { min-height: 36px; padding: 0 14px; border: 2px solid var(--line); border-radius: 999px; background: #fff; cursor: pointer; font-size: 14px; }
.chip-btn:hover:not(:disabled) { background: var(--tint); }
.chip-btn:disabled { opacity: .55; cursor: not-allowed; }
.chip-btn.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 13px; border-radius: 6px; }
.style-pick { display: flex; align-items: center; gap: 8px; }
.style-pick select { min-height: 36px; border: 2px solid var(--line); border-radius: 6px; padding: 0 8px; background: #fff; }

/* Console */
.tools-intro { margin: -6px 0 0; }
.shell-tabs { display: flex; gap: 0; }
.shell-tab { min-height: 40px; padding: 0 14px; border: 2px solid var(--line); background: #fff; cursor: pointer; font-weight: 500; }
.shell-tab:first-child { border-radius: 6px 0 0 6px; }
.shell-tab:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.shell-tab[aria-selected="true"] { background: #222; color: #fff; }
.terminal { background: #1d1f21; color: #e8e8e8; border-radius: 6px 6px 0 0; padding: 12px 14px; min-height: 300px; max-height: 460px; flex: 1 1 auto; overflow: auto; font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 13px; line-height: 1.5; }
.term-empty { color: #9aa0a6; }
.term-cmd { color: #8ab4f8; margin-top: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.term-cmd:first-child { margin-top: 0; }
.term-time { color: #9aa0a6; margin-left: 8px; }
.term-out { white-space: pre-wrap; margin: 2px 0 0; overflow-wrap: anywhere; font-family: inherit; }
.term-form { display: flex; align-items: center; gap: 8px; background: #1d1f21; border-top: 1px solid #3a3d40; border-radius: 0 0 6px 6px; padding: 8px 14px; margin-top: -14px; }
.term-prompt { color: #8ab4f8; font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 13px; white-space: nowrap; }
.term-form input[type="text"] { flex: 1 1 auto; min-width: 0; width: auto; min-height: 36px; border: 0; border-radius: 0; background: transparent; color: #e8e8e8; font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 13px; padding: 0; }
.term-form input[type="text"]:focus-visible { outline: none; }
.term-form:focus-within { outline: 3px solid var(--blue); outline-offset: 2px; }
.tool-group { display: flex; flex-direction: column; gap: 8px; }
.tool-title { font-size: 13px; font-weight: 600; }
.tool-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.tool { min-height: 44px; padding: 0 14px; border: 2px dashed var(--line); border-radius: 6px; background: #fff; cursor: pointer; font-weight: 500; }
.tool:hover:not(:disabled) { background: var(--tint); }

/* Docs */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 15px; font-weight: 600; }
textarea, input[type="text"], input[type="password"] { width: 100%; padding: 10px 12px; border: 2px solid var(--line); border-radius: 6px; background: #fff; }
.docs textarea { min-height: 96px; resize: vertical; }
textarea[readonly] { background: #f3f3f1; }
.close-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; border-top: 2px dashed #bbb; padding-top: 14px; }
.close-row input[type="checkbox"] { width: 24px; height: 24px; margin: 0; cursor: pointer; }
.close-label { font-size: 16px; font-weight: 600; min-height: 44px; display: flex; align-items: center; cursor: pointer; }
.chip { font-size: 14px; border: 2px solid #222; border-radius: 999px; padding: 2px 12px; background: var(--tint); }
.notice { border: 2px solid var(--warn-line); background: var(--warn-bg); border-radius: 6px; padding: 10px 14px; font-size: 14px; }

/* Dialogs */
dialog { border: 2px solid var(--line); border-radius: 10px; padding: 0; max-width: min(92vw, 440px); width: 100%; color: var(--ink); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dlg { padding: 24px; display: flex; flex-direction: column; gap: 10px; }
.dlg label { font-weight: 600; margin-top: 4px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
dialog.wide { max-width: min(94vw, 820px); }
.sc-top { display: flex; flex-wrap: wrap; gap: 16px 28px; align-items: center; }
.sc-cs { display: flex; flex-direction: column; gap: 2px; }
.sc-cs-num { font-size: 56px; font-weight: 600; line-height: 1; }
.sc-summary { flex: 1 1 280px; margin: 0; font-size: 15px; }
.sc-dims { display: flex; flex-direction: column; border: 2px solid var(--line); border-radius: 8px; }
.sc-dim { display: grid; grid-template-columns: 180px 190px 1fr; gap: 6px 14px; align-items: start; padding: 10px 14px; border-top: 1px solid #ccc; }
.sc-dim:first-child { border-top: 0; }
.sc-dim-name { font-weight: 600; }
.pips { display: flex; gap: 4px; align-items: center; padding-top: 4px; }
.pip { flex: none; width: 16px; height: 16px; border: 2px solid var(--line); border-radius: 3px; }
.pip.on { background: #222; }
.pip-label { font-size: 12px; margin-left: 6px; color: var(--muted); }
.sc-dim-comment { font-size: 14px; }
.sc-cols { display: flex; flex-wrap: wrap; gap: 12px 32px; }
.sc-cols > div { flex: 1 1 260px; }
.sc-cols ul { margin: 6px 0 0; padding-left: 20px; font-size: 14px; }

/* Narrower screens: stack the side-by-side rows */
@media (max-width: 1100px) {
  .chat-row, .work-row { grid-template-columns: minmax(0, 1fr); }
  .chat { height: clamp(460px, 70vh, 700px); }
}
@media (max-width: 640px) {
  .sc-dim { grid-template-columns: 1fr; }
  .layout { padding: 16px; }
  .queue, .queue-closed { flex: 1 1 100%; }
  .queue-closed { flex-direction: row; }
  .vertical-label { writing-mode: horizontal-tb; padding: 0; }
  .ticket-actions { margin-left: 0; }
}
