:root {
  color-scheme: dark;
  --bg: #07080b;
  --panel: #111318;
  --panel-soft: #0b0d12;
  --ink: #f2f5f3;
  --muted: #9aa4a0;
  --line: #282d36;
  --accent: #10a37f;
  --accent-ink: #ffffff;
  --warn: #f4ba4f;
  --bad: #ff6868;
  --source: #10a37f;
  --source-soft: rgba(16, 163, 127, 0.16);
  --source-border: rgba(16, 163, 127, 0.72);
  --source-glow: rgba(16, 163, 127, 0.24);
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.38);
}

.source-chatgpt {
  --source: #10a37f;
  --source-soft: rgba(16, 163, 127, 0.18);
  --source-border: rgba(16, 163, 127, 0.8);
  --source-glow: rgba(16, 163, 127, 0.28);
}

.source-codex {
  --source: #9b5cff;
  --source-soft: rgba(155, 92, 255, 0.18);
  --source-border: rgba(155, 92, 255, 0.82);
  --source-glow: rgba(155, 92, 255, 0.3);
}

.source-claude {
  --source: #d97732;
  --source-soft: rgba(217, 119, 50, 0.18);
  --source-border: rgba(217, 119, 50, 0.82);
  --source-glow: rgba(217, 119, 50, 0.28);
}

.source-claude-code {
  --source: #e5484d;
  --source-soft: rgba(229, 72, 77, 0.18);
  --source-border: rgba(229, 72, 77, 0.82);
  --source-glow: rgba(229, 72, 77, 0.28);
}

.source-unknown {
  --source: #8b949e;
  --source-soft: rgba(139, 148, 158, 0.16);
  --source-border: rgba(139, 148, 158, 0.74);
  --source-glow: rgba(139, 148, 158, 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family:
    "Segoe UI",
    "Yu Gothic UI",
    "Meiryo",
    system-ui,
    sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(420px, 1fr) minmax(280px, 340px);
  gap: 0;
  min-height: 100vh;
}

.sidebar,
.feedback-panel {
  background: var(--panel);
  border-color: var(--line);
  min-width: 0;
}

.sidebar {
  border-right: 1px solid var(--line);
}

.feedback-panel {
  border-left: 1px solid var(--line);
  padding: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.reader {
  min-width: 0;
  background: var(--panel-soft);
}

.pane-header,
.reader-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.pane-header {
  padding: 16px;
}

.reader-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(11, 13, 18, 0.96);
  padding: 14px 18px;
}

.reader-title {
  min-width: 0;
}

.title-editor {
  position: sticky;
  top: 73px;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 13, 18, 0.96);
}

.title-editor[hidden] {
  display: none;
}

.title-input {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--source-border);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  outline: none;
}

.title-input:focus {
  box-shadow: 0 0 0 3px var(--source-glow);
}

h1,
h2,
p {
  margin: 0;
}

h1,
h2 {
  font-size: 18px;
  line-height: 1.35;
  font-weight: 650;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.count {
  display: inline-grid;
  min-width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--panel-soft);
}

.conversation-list {
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 8px;
  height: calc(100vh - 65px);
  overflow: auto;
}

.source-group {
  display: grid;
  gap: 6px;
}

.source-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--source);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.025);
  text-align: left;
  font-weight: 700;
}

.source-header:hover,
.source-header.is-active {
  background: var(--source-soft);
  border-color: var(--source-border);
  box-shadow: inset 0 0 0 1px var(--source-border);
}

.source-header span:last-child {
  display: inline-grid;
  min-width: 26px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
}

.source-conversation-list {
  display: grid;
  gap: 5px;
  margin-left: 14px;
  padding-left: 10px;
  border-left: 1px solid var(--source-border);
}

.conversation-item {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 62px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.02);
  text-align: left;
  border-left: 4px solid var(--source);
}

.conversation-item:hover {
  background: var(--source-soft);
  border-color: var(--source-border);
}

.conversation-item.is-active {
  background: linear-gradient(90deg, var(--source-soft), rgba(255, 255, 255, 0.04));
  border-color: var(--source-border);
  box-shadow: inset 0 0 0 1px var(--source-border), 0 0 0 1px var(--source-glow);
}

.conversation-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}

.conversation-item-meta {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item.is-reviewed {
  opacity: 0.62;
}

.conversation-item.is-reviewed .conversation-item-meta {
  color: var(--source);
}

.source-reviewed {
  font-variant-numeric: tabular-nums;
}

.reader-actions,
.turn-actions,
.message-actions,
.feedback-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.primary-action,
.secondary-action,
.inline-action,
.label-button,
.rating-button {
  min-height: 32px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 6px 10px;
}

.primary-action {
  border-color: var(--source);
  background: var(--source);
  color: var(--accent-ink);
  font-weight: 650;
}

.secondary-action {
  color: var(--muted);
}

.inline-action {
  min-height: 28px;
  padding: 4px 8px;
  color: var(--ink);
  background: var(--panel-soft);
}

.range-strip {
  min-height: 34px;
  padding: 8px 18px;
  color: var(--warn);
  border-bottom: 1px solid var(--line);
  background: #151107;
  font-size: 13px;
}

.transcript {
  display: grid;
  gap: 0;
  max-width: 980px;
  margin: 0 auto;
  padding: 8px 18px 48px;
}

.turn-block {
  border-top: 1px solid var(--line);
  padding: 14px 0 18px;
  border-left: 3px solid transparent;
}

.turn-block.is-in-range {
  background: var(--source-soft);
  border-left-color: var(--source);
  outline: 2px solid var(--source-border);
  outline-offset: 5px;
  box-shadow: 0 0 0 4px var(--source-glow);
}

.turn-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  color: var(--muted);
  font-size: 13px;
}

.message {
  display: grid;
  gap: 8px;
  padding: 12px 0;
}

.message + .message {
  border-top: 1px dashed var(--line);
}

.message-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.message-user .message-header span:first-child {
  color: var(--source);
  font-weight: 700;
}

.message-assistant .message-header span:first-child {
  color: #b8c1cc;
  font-weight: 700;
}

.message-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.72;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.message-user .message-text {
  border-left: 4px solid var(--source);
}

.message-assistant .message-text {
  border-left: 4px solid #748091;
}

.label-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 0;
}

.label-button.is-selected,
.rating-button.is-selected {
  border-color: var(--source);
  background: var(--source-soft);
  color: var(--ink);
  font-weight: 700;
}

.rating-block {
  display: grid;
  grid-template-columns: 64px 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.rating-block > span {
  color: var(--muted);
}

.rating-buttons {
  display: grid;
  grid-template-columns: repeat(5, minmax(32px, 1fr));
  gap: 6px;
}

.rating-button {
  padding: 5px 0;
}

.text-field {
  display: grid;
  gap: 6px;
  padding-top: 14px;
  color: var(--muted);
}

.text-field textarea {
  width: 100%;
  min-width: 0;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  color: var(--ink);
  background: #080a0f;
  line-height: 1.55;
}

.feedback-actions {
  padding-top: 16px;
}

.status-line,
.empty-state {
  color: var(--muted);
  padding: 12px 0;
}

.back-button,
.close-feedback {
  display: none;
}

.keyboard-hint {
  margin: 0;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: minmax(220px, 280px) 1fr;
  }

  .feedback-panel {
    grid-column: 1 / -1;
    position: static;
    height: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-right: 0;
  }

  .conversation-list {
    flex: 1;
    height: auto;
    max-height: none;
  }

  .keyboard-hint {
    display: none;
  }

  .reader {
    display: none;
  }

  body.view-reader .sidebar {
    display: none;
  }

  body.view-reader .reader {
    display: block;
    height: 100dvh;
    overflow-y: auto;
  }

  .back-button {
    display: inline-grid;
    place-items: center;
    min-width: 64px;
    flex-shrink: 0;
  }

  .close-feedback {
    display: inline-grid;
    place-items: center;
  }

  .reader-header {
    flex-wrap: wrap;
    align-items: center;
  }

  .reader-title {
    flex: 1;
  }

  .reader-actions {
    width: 100%;
  }

  .title-editor {
    position: static;
    grid-template-columns: 1fr;
  }

  .transcript {
    padding: 8px 12px 48px;
  }

  .turn-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .primary-action,
  .secondary-action,
  .label-button,
  .rating-button {
    min-height: 42px;
  }

  .inline-action {
    min-height: 38px;
  }

  .title-input,
  .text-field textarea {
    font-size: 16px;
  }

  .feedback-panel {
    display: none;
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    height: auto;
    max-height: 80dvh;
    overflow-y: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 14px 14px 0 0;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    box-shadow: 0 -14px 36px rgba(0, 0, 0, 0.55);
  }

  body.fb-open .feedback-panel {
    display: block;
  }
}

/* My Prompt (agent_prompt_state delivery) */
.prompt-state-trigger {
  margin: 8px 12px 0;
  width: calc(100% - 24px);
}

.prompt-state-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.prompt-state-modal[hidden] {
  display: none;
}

.prompt-state-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
}

.prompt-state-dialog {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: 86dvh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.6);
}

.prompt-state-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.prompt-state-summary {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 12px;
}

.prompt-state-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.prompt-state-text {
  width: 100%;
  background: var(--panel-soft);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  resize: vertical;
}

.prompt-state-gaps {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.prompt-state-gaps-heading {
  font-size: 12px;
  color: var(--warn);
  margin: 0 0 2px;
}

.prompt-state-gap-row {
  font-size: 12.5px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.prompt-state-gap-row.gap-overclaim { color: var(--warn); }
.prompt-state-gap-row.gap-blind_spot { color: var(--bad); }
