:root {
  --bg: #0e0f13;
  --panel: #181a21;
  --panel-2: #20232c;
  --text: #ecedf0;
  --muted: #8c91a0;
  --accent: #6b8cff;
  --border: rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    "Inter", "Noto Sans JP", -apple-system, BlinkMacSystemFont, system-ui,
    sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

header {
  padding: 28px 36px 12px;
  border-bottom: 1px solid var(--border);
}

header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

main {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px 24px 80px;
}

.setup {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-gap: 14px;
}

.picker {
  background: var(--panel-2);
  border-radius: 10px;
  padding: 12px 14px;
}

.picker label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.persona-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.persona-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  transition: all 0.12s ease;
  font-size: 13px;
}

.persona-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.persona-option.selected {
  background: rgba(107, 140, 255, 0.12);
  border-color: var(--accent);
}

.persona-option .emoji {
  font-size: 22px;
}

.persona-option .meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.persona-option .name {
  font-weight: 600;
}

.persona-option .role {
  font-size: 11px;
  color: var(--muted);
}

.topic-row {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.topic-row label,
.row label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.topic-row input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
}

.topic-row input:focus,
.row input:focus,
.row select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.row input[type="number"],
.row select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
}

.row input[type="number"] {
  width: 70px;
}

button {
  cursor: pointer;
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  transition: opacity 0.12s ease;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#stop {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.examples {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
}

.examples-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-right: 4px;
}

.ex {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 400;
}

.ex:hover {
  background: rgba(255, 255, 255, 0.04);
}

.conversation {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bubble {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.bubble.right {
  flex-direction: row-reverse;
}

.bubble .avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--panel-2);
  border: 2px solid var(--border);
}

.bubble .body {
  background: var(--panel);
  border-radius: 14px;
  padding: 12px 16px;
  max-width: 72%;
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble .who {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.bubble.right .body {
  background: var(--panel-2);
}

.bubble.thinking .body::after {
  content: "▍";
  margin-left: 2px;
  animation: blink 1s steps(2) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.meta-banner {
  font-size: 12px;
  color: var(--muted);
  padding: 10px 14px;
  background: var(--panel);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.error {
  color: #ff8a8a;
  background: rgba(255, 95, 95, 0.08);
  border: 1px solid rgba(255, 95, 95, 0.25);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
}

.setup-group {
  grid-template-columns: repeat(3, 1fr);
}

.nav-sep {
  margin: 0 8px;
  color: var(--muted);
  opacity: 0.6;
}

.nav-link {
  color: var(--accent);
  text-decoration: none;
}

.nav-link:hover {
  text-decoration: underline;
}

.bubble.bubble-group {
  flex-direction: row;
}

.bubble.bubble-group .bubble-content {
  flex: 1;
  min-width: 0;
}

.bubble.bubble-group .body {
  background: var(--panel);
  border-left: 3px solid var(--persona-color, var(--accent));
  max-width: 100%;
}

.meta-banner.thinking-banner {
  font-style: italic;
  opacity: 0.75;
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  user-select: none;
}

.toggle-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.row input[type="number"].disabled,
.row input[type="number"]:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.question-banner {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.question-tag {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 10px;
  border-radius: 999px;
}

.question-body {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
}

.muted {
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}

.objective-block {
  margin-top: 4px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.objective-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

.objective-body {
  font-size: 13px;
  color: var(--text);
  line-height: 1.55;
}

.objective-met-banner {
  background: rgba(95, 200, 130, 0.08);
  border: 1px solid rgba(95, 200, 130, 0.35);
  border-left: 4px solid #5fc882;
  border-radius: 12px;
  padding: 12px 16px;
}

.objective-met-title {
  font-size: 14px;
  font-weight: 700;
  color: #7fdf9d;
  margin-bottom: 4px;
}

.objective-met-reason {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

/* History page */

.history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}

.ghost-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ghost-btn:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.ghost-btn.danger:hover:not(:disabled) {
  color: #ff8a8a;
  border-color: rgba(255, 95, 95, 0.4);
  background: rgba(255, 95, 95, 0.08);
}

.history-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  align-items: start;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding-right: 4px;
}

.history-empty {
  padding: 20px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  background: var(--panel);
  border-radius: 10px;
  border: 1px dashed var(--border);
}

.history-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.12s ease;
}

.history-item:hover {
  background: var(--panel-2);
}

.history-item.selected {
  background: var(--panel-2);
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.history-item-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.history-mode {
  background: rgba(107, 140, 255, 0.15);
  color: var(--accent);
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.history-question {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-meta {
  font-size: 11px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--muted);
}

.history-source {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.history-source-file {
  background: rgba(95, 200, 130, 0.15);
  color: #7fdf9d;
}

.history-source-local {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.history-detail {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.history-placeholder {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 40px 12px;
}

.history-detail-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-detail-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text);
}

.history-detail-summary strong {
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
  margin-right: 6px;
}

.history-detail-actions {
  display: flex;
  justify-content: flex-end;
}

.history-transcript {
  margin-top: 0;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

@media (max-width: 880px) {
  .history-layout {
    grid-template-columns: 1fr;
  }
  .history-list {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .setup,
  .setup-group {
    grid-template-columns: 1fr;
  }
  .bubble .body {
    max-width: 80%;
  }
}

.demo-banner {
  background: #fff7d6;
  border-bottom: 1px solid #e6c84d;
  color: #6b4f00;
  font-size: 13px;
  padding: 8px 16px;
  text-align: center;
}
