/* OCS Chat - plain chat UI, single theme. */
:root {
  --bg: oklch(97% 0.01 155);
  --surface: oklch(99.5% 0.004 155);
  --sidebar: oklch(20% 0.03 155);
  --sidebar-hover: oklch(27% 0.03 155);
  --sidebar-active: oklch(32% 0.03 155);
  --sidebar-text: oklch(88% 0.015 155);
  --sidebar-muted: oklch(58% 0.02 155);
  --text: oklch(18% 0.02 155);
  --text-muted: oklch(52% 0.018 155);
  --accent: oklch(58% 0.14 155);
  --accent-hover: oklch(52% 0.14 155);
  --accent-light: oklch(93% 0.04 155);
  --border: oklch(91% 0.01 155);
  --user-bubble: oklch(58% 0.14 155);
  --user-bubble-text: white;
  --ai-bubble: oklch(96% 0.01 155);
  --input-bg: oklch(99.5% 0.004 155);
  --code-bg: oklch(94% 0.012 155);
  --good: oklch(52% 0.12 150);
  --err: oklch(55% 0.16 25);
  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  --mono: "Cascadia Code", Consolas, monospace;
  --sans: "DM Sans", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14.5px/1.6 var(--sans);
}
#shell { display: flex; height: 100vh; }

/* ---------- sidebar ---------- */
#side {
  width: 256px; flex-shrink: 0; background: var(--sidebar);
  display: flex; flex-direction: column; padding: 20px 12px 10px;
}
#brand { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; padding: 0 4px; }
#brand .mark {
  width: 32px; height: 32px; flex-shrink: 0;
  object-fit: contain;
}
#brand span { font-family: var(--sans); font-size: 17px; font-weight: 700; letter-spacing: -.01em; color: var(--sidebar-text); }
#newchat {
  background: var(--accent); color: white; border: none; border-radius: 10px;
  padding: 10px 12px; font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; text-align: center;
}
#newchat:hover { background: var(--accent-hover); }
#sesslabel {
  margin: 18px 10px 6px; font-size: 10px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--sidebar-muted);
}
#sessions { overflow-y: auto; flex: 1; }
.sess {
  padding: 9px 10px; border-radius: 9px; cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--sidebar-text); margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sess:hover { background: var(--sidebar-hover); }
.sess.active { background: var(--sidebar-active); }
.sess small { display: block; font-size: 10.5px; font-weight: 400; color: var(--sidebar-muted); }

#sidefoot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 10px 2px; margin-top: 8px; border-top: 1px solid oklch(30% 0.03 155);
}
#sidefoot #whoami {
  font-size: 12px; color: var(--sidebar-muted); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
#sidefoot #logout {
  background: none; border: none; color: var(--sidebar-muted); font: inherit; font-size: 11.5px;
  cursor: pointer; padding: 4px 6px; border-radius: 6px; flex-shrink: 0;
}
#sidefoot #logout:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }

/* ---------- chat ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
#chat { flex: 1; overflow-y: auto; padding: 28px 0 10px; }
#hello { max-width: 720px; margin: 12vh auto 0; padding: 0 28px; }
#hello h1 { font-family: var(--sans); font-size: 34px; font-weight: 700; }
#hello h1::after { content: ""; display: block; width: 64px; height: 3px; background: var(--accent); margin-top: 14px; border-radius: 2px; }
#hello p { color: var(--text-muted); margin-top: 16px; max-width: 480px; }

.msg { max-width: 720px; margin: 0 auto 20px; padding: 0 28px; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble {
  background: var(--user-bubble); color: var(--user-bubble-text);
  border-radius: 18px 18px 4px 18px; padding: 13px 17px;
  max-width: 78%; width: fit-content;
  font-size: 14.5px; white-space: pre-wrap; word-break: break-word;
}
.msg.ai .who {
  display: flex; align-items: center; gap: 7px; margin-bottom: 6px;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
}
.msg.ai .who .avatar {
  width: 18px; height: 18px; object-fit: contain;
}
.msg.ai .body {
  background: var(--ai-bubble); color: var(--text);
  border-radius: 18px 18px 18px 4px; padding: 13px 17px;
  font-size: 14.5px; word-break: break-word;
}
.body h1, .body h2, .body h3 { font-weight: 600; margin: 14px 0 6px; }
.body p { margin: 8px 0; }
.body ul, .body ol { margin: 8px 0 8px 22px; }
.body code {
  font-family: var(--mono); font-size: 13px;
  background: var(--code-bg); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 5px;
}
.body pre {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; overflow-x: auto; margin: 10px 0;
}
.body pre code { border: 0; padding: 0; background: none; }
.body table { border-collapse: collapse; margin: 10px 0; display: block; overflow-x: auto; }
.body th, .body td { border: 1px solid var(--border); padding: 5px 10px; font-size: 13.5px; }
.body a { color: var(--accent); }
.body a:hover { color: var(--accent-hover); }
.body blockquote { border-left: 3px solid var(--accent); padding-left: 12px; color: var(--text-muted); margin: 8px 0; }

/* tool chips + thinking */
.tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  font-family: var(--mono); font-size: 12px; color: var(--text-muted);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 3px 6px 3px 12px;
}
.chip .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip b { color: var(--good); font-weight: 600; }
.viewbtn {
  flex-shrink: 0; font-family: var(--sans); font-size: 11px; font-weight: 600;
  background: var(--accent); color: white; border: none; border-radius: 999px;
  padding: 2px 10px; cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center;
}
.viewbtn:hover { background: var(--accent-hover); }
.viewbtn.dlbtn {
  background: none; color: var(--text-muted); border: 1px solid var(--border);
  padding: 2px 8px;
}
.viewbtn.dlbtn:hover { color: var(--text); background: var(--code-bg); }
.thinkdots { color: var(--text-muted); font-style: italic; }
.thinkdots::after { content: "thinking"; animation: think 1.4s infinite; }
@keyframes think { 0% { opacity: .35 } 50% { opacity: 1 } 100% { opacity: .35 } }

/* permission card */
.perm {
  background: var(--surface); border: 1.5px solid var(--accent);
  border-radius: 14px; padding: 12px 16px; margin: 8px 0;
}
.perm .ptitle { color: var(--accent); font-weight: 600; margin-bottom: 6px; }
.perm pre {
  font-family: var(--mono); font-size: 12.5px; background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 8px 10px; border-radius: 8px; margin: 6px 0 10px;
  white-space: pre-wrap; word-break: break-all; max-height: 180px; overflow-y: auto;
}
.perm button {
  border-radius: 999px; padding: 6px 18px; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 600;
  margin-right: 8px; border: 1px solid var(--border);
}
.perm .allow { background: var(--accent); color: white; border-color: var(--accent); }
.perm .allow:hover { background: var(--accent-hover); }
.perm .deny { background: none; color: var(--text-muted); }
.perm.answered { opacity: .55; }

/* result footer + errors */
.resline { font-size: 11.5px; color: var(--text-muted); opacity: .8; margin-top: 6px; font-family: var(--mono); }
.errline { color: var(--err); font-size: 13px; margin: 6px 0; }

/* ---------- composer ---------- */
#composer { padding: 10px 28px 24px; flex-shrink: 0; }
#statusline { max-width: 720px; margin: 0 auto; font-size: 12px; color: var(--text-muted); height: 18px; padding: 0 6px 2px; }
#inputcard {
  max-width: 720px; margin: 0 auto; background: var(--input-bg);
  border: 1.5px solid var(--border); border-radius: 18px;
  padding: 13px 16px 10px; box-shadow: var(--card-shadow);
}
#inputcard:focus-within { border-color: var(--accent); }
#input {
  width: 100%; resize: none; background: transparent; color: var(--text);
  border: none; outline: none;
  font: 14.5px/1.5 var(--sans); max-height: 120px;
}
#input::placeholder { color: var(--text-muted); opacity: .6; }
#inputbar { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 6px; }
#attach, #send, #stop {
  width: 30px; height: 30px; border-radius: 50%; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
#attach svg, #send svg { width: 14px; height: 14px; }
#attach { background: var(--accent-light); color: var(--accent); margin-right: auto; }
#attach:hover { color: var(--accent-hover); }
#attach:disabled { opacity: .5; cursor: default; }
#send { background: var(--accent); color: white; }
#send:hover { background: var(--accent-hover); }
#send:disabled { background: var(--border); color: var(--text-muted); cursor: default; }
#stop { background: var(--accent-light); color: var(--accent); font-size: 13px; display: none; }
#stop.on { display: flex; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(128, 128, 128, 0.25); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- viewer panel ---------- */
#viewer {
  width: 42%; min-width: 380px; max-width: 720px; flex-shrink: 0;
  background: var(--surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
}
#viewer[hidden] { display: none; }
#viewerhead {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600; flex-shrink: 0;
}
#viewername {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--mono); font-weight: 500;
}
#vieweractions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
#viewerdownload, #viewerclose {
  background: none; border: none; font-size: 20px; line-height: 1;
  cursor: pointer; color: var(--text-muted); padding: 2px 6px; flex-shrink: 0;
  text-decoration: none; border-radius: 6px;
}
#viewerdownload:hover, #viewerclose:hover { color: var(--text); background: var(--code-bg); }
#viewerbody { flex: 1; overflow: auto; }
#viewerbody.media { padding: 0; }
#viewerbody.media iframe, #viewerbody.media img {
  width: 100%; height: 100%; border: 0; display: block;
  object-fit: contain; background: white;
}
#viewerbody.text { padding: 20px 24px; font-size: 14px; }
#viewerbody.text pre {
  white-space: pre-wrap; word-break: break-word;
  font-family: var(--mono); font-size: 12.5px;
}
