:root {
  color-scheme: dark;
  --ink: #111111;
  --ink-soft: #3f3f3f;
  --muted: #747474;
  --muted-light: #9b9b9b;
  --paper: #ffffff;
  --surface: #f7f7f7;
  --surface-strong: #eeeeee;
  --line: #e2e2e2;
  --line-strong: #c5c5c5;
  --sidebar: #111111;
  --sidebar-line: #2c2c2c;
  --sidebar-muted: #969696;
  --sidebar-hover: #1d1d1d;
  --sidebar-width: 248px;
  font-family: Inter, "Pretendard", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
body { margin: 0; min-width: 0; overflow: hidden; background: var(--paper); color: var(--ink); font-size: 14px; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
button:disabled { cursor: not-allowed; }
kbd { padding: 2px 5px; border: 1px solid var(--line-strong); border-radius: 2px; background: var(--surface); color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; }

.shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); width: 100%; height: 100dvh; overflow: hidden; }
.sidebar { display: flex; min-width: 0; flex-direction: column; border-right: 1px solid var(--sidebar-line); padding: 24px 16px 16px; background: var(--sidebar); color: var(--paper); }
.sidebar-toolbar { display: none; }

.new-session { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 42px; padding: 0 12px; border: 1px solid var(--paper); border-radius: 2px; background: #000000; color: var(--paper); cursor: pointer; text-align: left; transition: background .16s, color .16s, border-color .16s; }
.new-session:hover { border-color: var(--paper); background: var(--sidebar-hover); }
.new-session .plus { color: var(--paper); font-size: 20px; font-weight: 300; line-height: 1; }
.new-session > span:nth-child(2) { flex: 1; font-size: 12px; font-weight: 750; }
.session-list { min-height: 0; flex: 1 1 auto; overflow: auto; padding-right: 1px; scrollbar-color: #565656 transparent; scrollbar-width: thin; }
.session-list-empty { padding: 20px 10px; color: var(--sidebar-muted); font-size: 12px; line-height: 1.55; }
.session-item { position: relative; display: block; width: 100%; margin-bottom: 3px; border: 1px solid var(--sidebar-line); border-radius: 2px; background: #000000; color: var(--paper); transition: background .16s, border-color .16s, color .16s; }
.session-item:hover { border-color: var(--paper); background: var(--sidebar-hover); color: var(--paper); }
.session-item.is-active { border-color: var(--paper); background: #000000; color: var(--paper); }
.session-item-select { display: block; width: 100%; padding: 10px 35px 10px 11px; border: 0; border-radius: 1px; outline: 0; background: transparent; color: inherit; cursor: pointer; text-align: left; }
.session-item-select:focus-visible { outline: 2px solid var(--paper); outline-offset: -3px; }
.session-item.is-active .session-item-select:focus-visible { outline-color: var(--paper); }
.session-item-title { overflow: hidden; font-size: 12px; font-weight: 650; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.session-item-delete { position: absolute; top: 50%; right: 5px; display: inline-flex; align-items: center; justify-content: center; width: 27px; height: 27px; padding: 0; border: 1px solid transparent; border-radius: 2px; background: transparent; color: var(--sidebar-muted); cursor: pointer; font-size: 18px; line-height: 1; opacity: 0; transform: translateY(-50%); transition: border-color .16s, background .16s, color .16s, opacity .16s; }
.session-item:hover .session-item-delete, .session-item:focus-within .session-item-delete { opacity: 1; }
.session-item-delete:hover { border-color: #777777; background: #2b2b2b; color: var(--paper); }
.session-item-delete:focus-visible { border-color: var(--paper); color: var(--paper); opacity: 1; outline: 2px solid var(--paper); outline-offset: 1px; }
.session-item.is-active .session-item-delete { color: var(--sidebar-muted); }
.session-item.is-active .session-item-delete:hover { border-color: var(--paper); background: var(--sidebar-hover); color: var(--paper); }
.session-item-delete:disabled { color: #5c5c5c; cursor: not-allowed; opacity: .45; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.main-column {
  --ink: #ffffff;
  --ink-soft: #e0e0e0;
  --muted: #a6a6a6;
  --muted-light: #888888;
  --paper: #000000;
  --surface: #0d0d0d;
  --surface-strong: #1b1b1b;
  --line: #2d2d2d;
  --line-strong: #5a5a5a;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  color-scheme: dark;
}
.topbar { display: none; align-items: center; justify-content: space-between; min-height: 0; gap: 20px; padding: 0; border-bottom: 1px solid var(--line); background: var(--paper); }
.mobile-session-controls { display: none; align-items: center; min-width: 0; gap: 6px; }
.session-select { min-width: 0; max-width: 235px; padding: 8px 28px 8px 10px; border: 1px solid var(--line-strong); border-radius: 2px; outline: 0; background: var(--paper); color: var(--ink); font-size: 12px; text-overflow: ellipsis; }
.session-select:focus { border-color: var(--ink); }
.session-select option { background: var(--paper); color: var(--ink); }
.drawer-close { display: none !important; }

.conversation-shell { position: relative; display: flex; min-height: 0; flex: 1; flex-direction: column; width: min(100%, 1160px); margin: 0 auto; padding: 0 clamp(24px, 5vw, 72px); }
.conversation-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 28px 4px 19px; border-bottom: 1px solid var(--line); }
.conversation-title-wrap { min-width: 0; }
.conversation-title-row { display: flex; align-items: center; min-width: 0; gap: 7px; }
.conversation-heading h1 { overflow: hidden; margin: 0; color: var(--ink); font-size: clamp(20px, 1.65vw, 24px); font-weight: 700; letter-spacing: -.04em; text-overflow: ellipsis; white-space: nowrap; }
.session-rename { width: 28px; height: 28px; flex: 0 0 auto; font-size: 14px; }
.session-state { padding: 6px 9px; border: 1px solid var(--line-strong); border-radius: 2px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .05em; white-space: nowrap; }
.session-state.running { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.session-state.error { border-color: #ff5c5c; color: #ff5c5c; }
.fatal-error { margin: 14px 4px 0; padding: 12px 14px; border: 1px solid var(--ink); border-left-width: 3px; border-radius: 2px; background: var(--surface); color: var(--ink); font-size: 13px; line-height: 1.55; white-space: pre-wrap; }
.transcript { display: block; min-width: 0; min-height: 0; height: 0; flex: 1 1 0; overflow-x: hidden; overflow-y: auto; padding: 0 4px; overscroll-behavior: contain; overflow-anchor: auto; scrollbar-color: var(--line-strong) transparent; scrollbar-gutter: stable; touch-action: pan-y; }
.transcript:focus-visible { outline: 1px solid var(--ink); outline-offset: -1px; }
.transcript::-webkit-scrollbar { width: 11px; }
.transcript::-webkit-scrollbar-track { background: transparent; }
.transcript::-webkit-scrollbar-thumb { border: 3px solid transparent; border-radius: 99px; background: var(--line-strong); background-clip: padding-box; }
.transcript-content { display: flex; min-height: 100%; flex-direction: column; padding: 20px 0 32px; }
.empty-state { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 22px 0 55px; }
.empty-state-inner { width: min(560px, 100%); text-align: center; }
.empty-title { margin: 0; color: var(--ink); font-size: clamp(21px, 2vw, 28px); font-weight: 650; letter-spacing: -.045em; }
.message-row { display: flex; flex: 0 0 auto; width: 100%; max-width: 900px; margin: 0 auto 30px; }
.message-row.user { justify-content: flex-end; }
.message-body { position: relative; min-width: 0; max-width: min(800px, 94%); }
.message-row.user .message-body { max-width: min(700px, 86%); }
.message-meta { position: absolute; z-index: 1; top: 7px; right: 7px; display: flex; align-items: center; margin: 0; pointer-events: none; }
.message-row.user .message-meta { margin-right: 0; }
.message-delete { padding: 3px 6px; border: 1px solid transparent; border-radius: 2px; background: transparent; color: var(--muted); cursor: pointer; font-size: 10px; opacity: 0; pointer-events: auto; transition: background .16s, border-color .16s, color .16s, opacity .16s; }
.message-body:hover .message-delete, .message-delete:focus-visible { opacity: 1; }
.message-delete:hover { border-color: var(--line-strong); background: var(--surface); color: var(--ink); }
.message-delete:disabled { cursor: wait; opacity: .7; }
.message-content { padding: 14px 17px; border: 1px solid var(--line); border-left: 2px solid var(--ink); border-radius: 2px; background: var(--surface); color: var(--ink); font-size: 14px; line-height: 1.75; overflow-wrap: anywhere; }
.message-row.user .message-content { border-color: var(--line-strong); border-radius: 2px; background: var(--surface-strong); color: var(--ink); }
.message-row.error .message-content, .message-row.stopped .message-content { border-color: var(--ink); border-style: dashed; background: var(--surface-strong); color: var(--ink); }
.markdown-paragraph { margin: 0 0 13px; white-space: pre-wrap; }
.markdown-paragraph:last-child { margin-bottom: 0; }
.markdown-heading { margin: 17px 0 8px; color: var(--ink); font-size: 1em; font-weight: 750; line-height: 1.4; }
.markdown-heading:first-child { margin-top: 0; }
.markdown-heading h1, .markdown-heading h2, .markdown-heading h3 { font-size: inherit; }
.markdown-list { margin: 8px 0 13px; padding-left: 23px; }
.markdown-list li { margin: 3px 0; }
.markdown-quote { margin: 10px 0; padding: 4px 0 4px 12px; border-left: 2px solid var(--ink); color: var(--ink-soft); }
.markdown-rule { height: 1px; margin: 17px 0; border: 0; background: var(--line-strong); }
.message-content code { padding: 2px 5px; border-radius: 2px; background: var(--surface-strong); color: var(--ink); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; }
.message-content .inline-code { display: block; max-width: 100%; margin: 12px 0; padding: 14px 15px; overflow: auto; border: 1px solid var(--line-strong); border-radius: 2px; background: #050505; color: var(--ink); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.65; white-space: pre; }
.message-content .inline-code:first-child { margin-top: 0; }
.message-content .inline-code:last-child { margin-bottom: 0; }
.message-content strong { color: inherit; font-weight: 800; }
.stream-cursor { display: inline-block; width: 6px; height: 16px; margin-left: 4px; vertical-align: -3px; background: var(--ink); animation: blink 1s step-end infinite; }
.message-row.user .stream-cursor { background: var(--paper); }
.activity-strip { display: flex; align-items: center; gap: 9px; width: min(900px, 100%); min-height: 39px; margin: 0 auto 11px; padding: 9px 12px; border: 1px solid var(--ink); border-radius: 2px; background: var(--paper); color: var(--ink-soft); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-spinner { width: 9px; height: 9px; flex: 0 0 auto; border: 1px solid var(--ink); border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.scroll-latest { position: absolute; z-index: 2; right: clamp(28px, 5vw, 78px); bottom: var(--scroll-latest-offset, 110px); width: 35px; height: 35px; padding: 0; border: 1px solid var(--ink); border-radius: 2px; background: var(--paper); color: var(--ink); cursor: pointer; font-size: 17px; }
.scroll-latest:hover { background: var(--surface-strong); }

.composer-wrap { padding: 0 0 22px; }
.composer-status { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 9px; padding: 10px 12px; border: 1px solid var(--ink); border-left-width: 3px; border-radius: 2px; background: var(--surface); color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.composer-status::before { width: 7px; height: 7px; flex: 0 0 auto; margin-top: 5px; border-radius: 50%; background: var(--ink); content: ""; }
.composer { border: 1px solid var(--ink); border-radius: 2px; background: var(--paper); box-shadow: none; transition: border-color .16s, outline-color .16s, opacity .16s; }
.composer.is-disabled { border-color: var(--line-strong); opacity: .72; }
.composer:focus-within { border-color: var(--ink); outline: 2px solid var(--surface-strong); outline-offset: 2px; }
#prompt-input { display: block; width: 100%; min-height: 64px; max-height: 190px; padding: 16px 16px 7px; overflow-y: hidden; border: 0; outline: 0; resize: none; background: transparent; color: var(--ink); font-size: 14px; line-height: 1.65; }
#prompt-input::placeholder { color: var(--muted-light); }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 9px 9px 12px; }
.composer-context { display: flex; align-items: center; min-width: 0; gap: 6px; overflow: hidden; }
.composer-model-select { display: block; min-width: 0; }
.model-select { width: min(190px, 42vw); min-width: 150px; max-width: 220px; padding: 7px 27px 7px 9px; border: 1px solid var(--line-strong); border-radius: 2px; outline: 0; background: var(--surface); color: var(--ink-soft); font-size: 11px; text-overflow: ellipsis; }
.model-select:focus { border-color: var(--ink); }
.model-select:disabled { color: var(--muted); cursor: not-allowed; }
.model-select option { background: var(--paper); color: var(--ink); }
.send-button { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; width: 40px; height: 35px; flex: 0 0 auto; padding: 0; border: 1px solid var(--ink); border-radius: 2px; background: var(--surface-strong); color: var(--ink); cursor: pointer; font-size: 12px; font-weight: 800; line-height: 1; transition: background .16s, color .16s, transform .16s; }
.send-button:hover { background: #2a2a2a; transform: translateY(-1px); }
.send-icon { font-size: 17px; line-height: 1; }
.send-button:disabled { border-color: var(--line-strong); background: var(--surface-strong); color: var(--muted-light); transform: none; }
.send-button.is-stop { background: var(--paper); color: var(--ink); }
.send-button.is-stop:hover { background: var(--surface-strong); }
.send-label { display: none; }

.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border: 1px solid transparent; border-radius: 2px; background: transparent; color: var(--muted); cursor: pointer; font-size: 17px; }
.icon-button:hover { border-color: var(--line-strong); background: var(--surface); color: var(--ink); }
.icon-button:disabled { color: var(--muted-light); cursor: not-allowed; }
.panel-backdrop { position: fixed; z-index: 30; inset: 0; background: rgba(0, 0, 0, .42); }
.toast-region { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: flex; max-width: min(420px, calc(100vw - 36px)); flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 11px 10px 11px 13px; border: 1px solid var(--ink); border-radius: 2px; background: var(--paper); color: var(--ink-soft); font-size: 12px; line-height: 1.5; animation: fade-up .18s ease-out; }
.toast > span { flex: 1; overflow-wrap: anywhere; }
.toast.error { border-left-width: 3px; color: var(--ink); }
.toast-close { width: 22px; height: 22px; flex: 0 0 auto; padding: 0; border: 1px solid transparent; border-radius: 2px; background: transparent; color: currentColor; cursor: pointer; font-size: 17px; line-height: 1; }
.toast-close:hover { border-color: currentColor; background: var(--surface-strong); }

.is-hidden { display: none !important; }
@keyframes fade-up { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes pulse { 50% { opacity: .35; transform: scale(.75); } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1340px) {
  :root { --sidebar-width: 232px; }
  .topbar { padding-inline: 22px; }
  .conversation-shell { padding-inline: clamp(20px, 3vw, 36px); }
}

@media (max-width: 1180px) {
  .shell { grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
  .topbar { min-height: 64px; }
}

@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: min(320px, calc(100vw - 28px)); border-right: 1px solid var(--sidebar-line); transform: translateX(-105%); transition: transform .2s ease; }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-toolbar { display: flex; justify-content: flex-end; margin-bottom: 10px; }
  .sidebar .drawer-close { display: inline-flex !important; margin-left: auto; color: var(--sidebar-muted); }
  .sidebar .drawer-close:hover { border-color: var(--sidebar-line); background: var(--sidebar-hover); color: var(--paper); }
  .topbar { display: flex; min-height: 62px; gap: 8px; padding: 0 10px; }
  .mobile-session-controls { display: flex; flex: 1 1 auto; }
  .session-select { width: min(190px, calc(100vw - 206px)); max-width: none; }
  .conversation-shell { padding-inline: 11px; }
  .conversation-heading { padding: 19px 3px 14px; }
  .conversation-heading h1 { font-size: 20px; }
  .transcript { padding-inline: 1px; }
  .transcript-content { padding-top: 16px; }
  .message-row { margin-bottom: 21px; }
  .message-body, .message-row.user .message-body { max-width: 96%; }
  .message-content { padding: 12px 13px; font-size: 13px; line-height: 1.7; }
  .message-delete { opacity: 1; }
  .composer-wrap { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  #prompt-input { min-height: 58px; padding: 14px 13px 6px; font-size: 13px; }
  .send-button { min-width: 38px; width: 38px; padding: 0; }
  .send-label { display: none; }
  .scroll-latest { right: 19px; }
  .toast-region { right: 12px; bottom: 12px; left: 12px; max-width: none; }
}

@media (max-width: 480px) {
  .session-select { width: min(185px, calc(100vw - 164px)); }
  .conversation-heading { align-items: flex-start; }
  .session-state { margin-top: 2px; }
  .empty-title { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
