:root {
  color-scheme: light;
  --ink: #20252a;
  --muted: #6b747d;
  --line: #dfe3e5;
  --paper: #fbfaf7;
  --panel: #f2f0eb;
  --accent: #176b5b;
  --accent-soft: #e2f0eb;
  --user: #e7f2ee;
  --assistant: #fff;
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); }
button, input, textarea { font: inherit; }
button {
  border: 1px solid var(--line); border-radius: 8px; background: white;
  color: var(--ink); padding: .55rem .8rem; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary, button.send { background: var(--accent); color: white; border-color: var(--accent); }
input, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: .65rem .75rem; background: white; color: var(--ink);
}
textarea { resize: vertical; }
.hidden { display: none !important; }
.app-shell { display: grid; grid-template-columns: 310px minmax(420px, 1fr) 245px; height: 100vh; }
.thread-panel, .outline-panel { background: var(--panel); overflow: auto; padding: 18px; }
.thread-panel { border-right: 1px solid var(--line); }
.outline-panel { border-left: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.brand-mark, .empty-icon {
  display: grid; place-items: center; background: var(--accent); color: white;
  width: 42px; height: 42px; border-radius: 13px; font-weight: 700;
}
.brand h1 { font-size: 1.1rem; margin: 0; }
.brand small { color: var(--muted); }
.beta-notice { margin: -7px 0 14px; padding: 10px; border: 1px solid #d8c786; border-radius: 9px; background: #fff9df; font-size: .74rem; line-height: 1.45; }
.beta-notice strong { color: #765c00; }
.beta-notice p { margin: 4px 0 0; }
.thread-actions { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; margin-bottom: 10px; }
.search { position: relative; display: block; }
.search span { position: absolute; left: 10px; top: 8px; color: var(--muted); }
.search input { padding-left: 30px; }
.archive-toggle { display: block; color: var(--muted); font-size: .82rem; margin: 10px 2px; }
.archive-toggle input { width: auto; }
.thread-item { padding: 12px; border-radius: 10px; cursor: pointer; margin-bottom: 5px; border: 1px solid transparent; }
.thread-item:hover { background: #fff; }
.thread-item.active { background: #fff; border-color: #cdd8d4; box-shadow: 0 2px 8px #24352f10; }
.thread-item strong { display: block; font-size: .94rem; }
.thread-item p { color: var(--muted); font-size: .78rem; margin: 5px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { background: var(--accent-soft); color: #205f53; font-size: .7rem; border-radius: 20px; padding: 2px 7px; }
.chat-panel { min-width: 0; display: flex; flex-direction: column; }
.empty-state { margin: auto; text-align: center; color: var(--muted); }
.empty-icon { margin: 0 auto 15px; width: 58px; height: 58px; font-size: 1.5rem; }
.empty-state h2 { color: var(--ink); }
.thread-view { position: relative; display: flex; flex-direction: column; height: 100dvh; min-height: 0; }
.thread-header {
  min-height: 48px; display: grid; grid-template-columns: minmax(160px, 1fr) auto;
  align-items: center; gap: 12px; padding: 6px 14px; border-bottom: 1px solid var(--line);
}
.title-input { border: none; background: transparent; padding: 3px; font-size: 1.08rem; font-weight: 700; min-width: 0; }
.theme-input { color: var(--ink); }
.model-picker {
  display: grid; grid-template-rows: auto 1fr; align-items: center;
  gap: 1px; color: var(--muted); font-size: .64rem;
}
.model-picker select {
  min-width: 0; width: 100%; border: 1px solid var(--line); border-radius: 7px;
  background: white; color: var(--ink); padding: .3rem .4rem; font-size: .72rem;
}
.header-actions { display: flex; align-items: center; gap: 5px; }
.header-actions button { padding: .4rem .6rem; font-size: .8rem; }
.thread-details {
  position: absolute; z-index: 5; top: 48px; left: 0; right: 0;
  background: #f7f6f2f7; border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 20px #17221f1f; backdrop-filter: blur(8px);
}
.meta-strip {
  display: grid; grid-template-columns: 1.2fr 1fr 1.6fr; gap: 9px;
  padding: 5px 14px 9px;
}
.meta-strip label { display: grid; gap: 3px; color: var(--muted); font-size: .72rem; }
.meta-strip input, .meta-strip textarea { padding: .45rem .55rem; font-size: .82rem; }
.messages {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  padding: 18px max(20px, 6vw); scroll-behavior: smooth;
}
.message { max-width: 820px; margin: 0 auto 20px; scroll-margin-top: 20px; }
.message-head { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .78rem; margin-bottom: 5px; }
.message-body { background: var(--assistant); border: 1px solid var(--line); border-radius: 13px; padding: 14px 17px; line-height: 1.65; box-shadow: 0 2px 8px #1b29240a; }
.message.user .message-body { background: var(--user); border-color: #cfe0da; }
.message.failed .message-body { border-color: #cf7777; background: #fff4f4; }
.message.generating .message-body { color: var(--muted); background: #f7f8f7; font-style: italic; }
.message-body > :first-child { margin-top: 0; }
.message-body > :last-child { margin-bottom: 0; }
.output-limit-notice {
  margin: 7px 4px 0; padding: 7px 10px; border-left: 3px solid #c49a35;
  border-radius: 4px; background: #fff8e8; color: #725a20; font-size: .78rem;
}
.composer {
  flex: 0 0 auto; display: grid; grid-template-columns: minmax(155px, 205px) 1fr auto; align-items: end;
  gap: 8px; padding: 7px 14px 9px; border-top: 1px solid var(--line); background: var(--paper);
}
.composer textarea { min-height: 44px; max-height: 120px; padding: .55rem .7rem; }
.usage-status { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: .72rem; text-align: right; }
.usage-status.limit-reached { color: #a43b3b; font-weight: 700; }
.send { align-self: stretch; min-width: 64px; padding: .55rem .9rem; }
button:disabled, textarea:disabled { cursor: not-allowed; opacity: .65; }
.outline-panel h2 { font-size: .9rem; color: var(--muted); margin: 4px 0 14px; }
.outline-item { padding: 9px; border-left: 2px solid var(--line); font-size: .8rem; cursor: pointer; margin-bottom: 3px; }
.outline-item:hover, .outline-item.active { color: var(--accent); border-color: var(--accent); background: #fff; }
dialog { border: none; border-radius: 14px; padding: 0; box-shadow: 0 15px 60px #1115; }
dialog::backdrop { background: #17221f80; }
.dialog-card { width: min(560px, 90vw); padding: 22px; display: grid; gap: 14px; }
.dialog-card.wide { width: min(800px, 92vw); }
.dialog-head, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dialog-head h2 { margin: 0; }
.dialog-card label { display: grid; gap: 5px; font-size: .86rem; }
.hint { color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; margin: 0; }
.import-messages { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.import-message { padding: 8px; border-bottom: 1px solid var(--line); font-size: .82rem; white-space: pre-wrap; }
.toast { position: fixed; right: 24px; bottom: 24px; background: #202925; color: white; border-radius: 9px; padding: 11px 15px; opacity: 0; pointer-events: none; transition: opacity .2s; }
.toast.show { opacity: 1; }
@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 270px 1fr; }
  .outline-panel { display: none !important; }
}
@media (max-width: 720px) {
  .app-shell { display: block; height: auto; }
  .thread-panel { height: 38vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .thread-view { height: 62dvh; }
  .thread-header { grid-template-columns: 1fr; gap: 4px; padding: 5px 8px; }
  .header-actions { overflow-x: auto; }
  .meta-strip { grid-template-columns: 1fr; max-height: 35vh; overflow-y: auto; padding: 5px 8px 8px; }
  .messages { padding: 10px; }
  .composer { grid-template-columns: 1fr auto; padding: 6px 8px; }
  .composer .model-picker { grid-column: 1 / -1; grid-template-columns: 42px 1fr; grid-template-rows: auto; }
}
