:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #171717;
  background: #f5f5f5;
  --line: #e5e5e5;
  --ink: #0d0d0d;
  --muted: #656565;
  --soft: #efefef;
  --panel: #fff;
  --radius: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, textarea { font: inherit; }
a { color: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible, textarea:focus-visible, .chat-scroll:focus-visible {
  outline: 2px solid #404040;
  outline-offset: 3px;
}
.symbols { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.85; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.workspace {
  display: grid;
  grid-template-columns: clamp(242px, 25vw, 306px) minmax(0, 1fr);
  gap: 10px;
  height: 100vh;
  height: 100dvh;
  padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
}

.sidebar {
  min-height: 0;
  overflow: auto;
  background: #f5f5f5;
}
.list-header { min-height: 48px; display: flex; align-items: center; padding: 4px 8px 8px; }
.list-header h1 { margin: 0; font-size: 21px; font-weight: 650; line-height: 1.2; }
.side-card { padding: 6px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.nav-row { width: 100%; min-height: 38px; border: 0; border-radius: 10px; display: flex; align-items: center; gap: 9px; padding: 6px 8px; text-align: left; background: transparent; text-decoration: none; }
.nav-row:hover, .nav-row[aria-current="page"] { background: var(--soft); }
.nav-row .icon { width: 16px; height: 16px; color: #393939; }
.history-row { display: flex; align-items: center; gap: 2px; border-radius: 10px; }
.history-row .nav-row { flex: 1; min-width: 0; background: transparent; }
.history-row .chat-more { width: 38px; height: 38px; color: #393939; background: transparent; opacity: 0; pointer-events: none; }
.history-row:is(:hover, :has(:focus-visible, [aria-expanded="true"])) { background: var(--soft); }
.history-row:is(:hover, :has(:focus-visible, [aria-expanded="true"])) .chat-more { opacity: 1; pointer-events: auto; }
@media (hover: none) {
  .history-row:has([aria-current="page"]) { background: var(--soft); }
  .history-row:has([aria-current="page"]) .chat-more { opacity: 1; pointer-events: auto; }
}
@media (width > 700px) {
  .history-row:has([aria-current="page"]) { background: #e6e6e6; }
}
.chat-actions { position: fixed; z-index: 3; width: 184px; padding: 5px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: 0 3px 12px #00000015; }
.chat-actions button { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 42px; text-align: left; border: 0; border-radius: 8px; padding: 7px 9px; background: transparent; font-size: 14px; }
.chat-actions button:hover { background: var(--soft); }
.chat-actions .icon { width: 18px; height: 18px; }
.side-card.primary { position: relative; }
.chat-kind-menu { position: absolute; top: calc(100% + 4px); left: 6px; z-index: 4; }
.history-row .visibility-mark { display: inline-flex; margin-left: -5px; flex: none; }
.history-row .visibility-mark .icon { width: 13px; height: 13px; color: var(--muted); }
.new-chat, .new-chat:hover { background: transparent; color: var(--ink); font-size: 14px; font-weight: 600; }
.new-chat .icon { color: currentColor; }
.side-label { margin: 7px 8px 5px; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
.row-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.history-empty { margin: 9px 8px; color: var(--muted); font-size: 13px; line-height: 1.4; }

.main { min-width: 0; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.topbar { min-height: 55px; display: flex; align-items: center; gap: 9px; padding: 8px clamp(12px, 2.1vw, 30px); border-bottom: 1px solid var(--line); }
.topbar-label { flex: 1; min-width: 0; }
.topbar h2 { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.2; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.icon-button { display: inline-grid; width: 40px; height: 40px; place-items: center; flex: none; border-radius: 12px; border: 0; background: transparent; }
.icon-button:not(.chat-more):hover { background: #f0f0f0; }
.back-to-chats { display: none; }
.rename-dialog { width: min(calc(100% - 32px), 380px); border: 1px solid var(--line); border-radius: var(--radius); color: inherit; padding: 17px; }
.rename-dialog::backdrop { background: #0005; }
.rename-dialog h2 { margin: 0 0 14px; font-size: 18px; font-weight: 650; }
.rename-dialog label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 5px; }
.rename-dialog input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px; color: inherit; font: inherit; }
.rename-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.rename-actions button { border: 0; border-radius: 10px; background: var(--soft); padding: 9px 12px; }
.rename-actions button[type="submit"] { background: var(--ink); color: #fff; }

.chat-scroll { overflow: auto; overscroll-behavior: contain; }
.chat-content { width: min(100%, 800px); min-height: 100%; margin-inline: auto; padding: 24px clamp(12px, 3vw, 30px) 16px; }
.chat-content:has(.empty-chat) { display: grid; align-items: center; }
.empty-chat { width: min(100%, 465px); margin-inline: auto; padding-block: 15px; }
.empty-chat h2 { margin: 10px 0 8px; font-size: clamp(25px, 5vw, 34px); line-height: 1.1; font-weight: 680; letter-spacing: -.025em; }
.empty-chat p { color: var(--muted); margin: 0 0 19px; line-height: 1.45; }
.empty-chat .empty-mark { display: grid; place-items: center; width: 46px; height: 46px; border: 1px solid var(--line); background: white; border-radius: 14px; }

.turn { margin-bottom: 24px; }
.turn.user { display: flex; flex-direction: column; align-items: flex-end; }
.turn.assistant { width: fit-content; max-width: min(100%, 640px); }
.author { margin: 0 0 5px; font-size: 13px; font-weight: 600; }
.message { max-width: 100%; line-height: 1.5; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.user .message { width: fit-content; max-width: min(92%, 525px); padding: 9px 12px; background: var(--soft); border-radius: 11px; }
.message-mode { color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.reply-status { color: var(--muted); font-size: 13px; line-height: 1.4; }
.copy-button { margin: 8px 0 0 -6px; width: 33px; height: 32px; color: var(--muted); }
.copy-button .icon { width: 16px; height: 16px; }
.inline-file { display: flex; align-items: center; gap: 8px; padding: 9px 10px; width: fit-content; max-width: 100%; background: #f4f4f4; border: 1px solid #e3e3e3; border-radius: 10px; font-size: 13px; }
.result-file { margin-top: 8px; text-decoration: none; }
.result-file:hover { background: #e9e9e9; }
.user .inline-file { margin-bottom: 7px; }
.file-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.compose-region { width: min(100%, 800px); padding: 9px clamp(12px, 3vw, 30px) 9px; margin-inline: auto; }
.composer { padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.composer textarea { display: block; width: 100%; min-height: 42px; max-height: 136px; resize: none; padding: 9px 7px 6px; border: 0; background: transparent; outline: none; font-size: 16px; line-height: 1.35; color: var(--ink); }
.composer textarea { scrollbar-width: none; }
.composer textarea::-webkit-scrollbar { display: none; }
.composer textarea:focus-visible { outline: none; }
.composer:focus-within { border-color: #adadad; }
.composer.file-drag-over { background: var(--soft); border-color: #adadad; }
.composer textarea::placeholder { color: #626262; }
.compose-actions { display: flex; gap: 5px; align-items: center; }
.attach-button { width: 37px; }
.send { margin-left: auto; border-radius: 12px; background: var(--ink); color: white; }
.send:hover { background: #333; }
.send:disabled { background: #e6e6e6; color: #737373; }
.attachment { display: flex; width: fit-content; max-width: 100%; align-items: center; gap: 5px; margin: 0 0 4px 5px; }
.attachment .inline-file { min-width: 0; }
.attachment .icon-button { width: 30px; height: 30px; }
.attachment .icon-button .icon { width: 16px; height: 16px; }
.mode-picker { position: relative; min-width: 0; }
.mode-button { display: flex; align-items: center; gap: 6px; min-height: 36px; max-width: 100%; padding: 4px 9px; border: 1px solid #e1e1e1; background: #f7f7f7; border-radius: 10px; font-size: 13px; white-space: nowrap; }
.mode-button:hover { background: #eee; }
.mode-button .icon { width: 16px; height: 16px; }
.mode-options { position: absolute; z-index: 2; bottom: calc(100% + 8px); left: 0; width: 212px; padding: 5px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: 0 3px 12px #00000010; }
.mode-options button { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 42px; text-align: left; border: 0; border-radius: 8px; padding: 7px 9px; background: #fff; font-size: 13px; }
.mode-options button:hover, .mode-options button[aria-pressed="true"] { background: #eee; }
.mode-options .icon { width: 16px; height: 16px; }
.compose-hint { min-height: 17px; margin: 6px 3px 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.notice { position: absolute; left: 50%; bottom: calc(100% - 112px); transform: translateX(-50%); z-index: 4; max-width: 85%; width: max-content; padding: 8px 13px; border-radius: 10px; background: #222; color: #fff; font-size: 13px; }

@media (max-width: 700px) {
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .workspace[data-view="list"] .main,
  .workspace[data-view="chat"] .sidebar { display: none; }
  .nav-row { min-height: 44px; }
  .history-row .chat-more { width: 44px; height: 44px; }
  .topbar { min-height: 54px; gap: 4px; padding: 4px 8px; }
  .back-to-chats { display: inline-grid; width: 44px; height: 44px; }
  .chat-content { padding-top: 20px; }
  .composer { padding: 8px; }
}

.prime-entry { width: min(100%, 234px); padding: 10px; }
