:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial,
    sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  font-size: 14px;
  line-height: 1.5;
  background: #f6f8fa;
  color: #1f2328;
  --canvas: #ffffff;
  --canvas-subtle: #f6f8fa;
  --canvas-inset: #f6f8fa;
  --border: #d0d7de;
  --border-muted: #d8dee4;
  --text: #1f2328;
  --muted: #656d76;
  --accent: #0969da;
  --success: #1f883d;
  --success-hover: #1a7f37;
  --danger: #cf222e;
  --attention: #9a6700;
  --neutral-emphasis: #6e7781;
  --shadow: 0 1px 0 rgba(31, 35, 40, 0.04);
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  height: 100%;
}

body {
  margin: 0;
  background: var(--canvas-subtle);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid rgba(31, 35, 40, 0.15);
  border-radius: 6px;
  background: var(--success);
  color: #ffffff;
  cursor: pointer;
  min-height: 32px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: normal;
  box-shadow: var(--shadow);
  appearance: none;
}

button:hover:not(:disabled) {
  background: var(--success-hover);
}

button.secondary {
  background: #f6f8fa;
  color: #24292f;
  border-color: rgba(31, 35, 40, 0.15);
}

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

.shell {
  height: 100vh;
  display: grid;
  grid-template-rows: 52px 1fr;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  background: #24292f;
  color: #ffffff;
  border-bottom: 1px solid #57606a;
}

.brand {
  font-weight: 600;
  font-size: 16px;
  color: #ffffff;
  letter-spacing: normal;
}

.brand::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 10px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: transparent;
  vertical-align: -3px;
}

.topic {
  color: #c9d1d9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo,
    monospace;
  font-size: 12px;
}

.status {
  margin-left: auto;
  padding: 3px 8px;
  border: 1px solid rgba(240, 246, 252, 0.2);
  border-radius: 2em;
  background: rgba(240, 246, 252, 0.08);
  color: #f0f6fc;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo,
    monospace;
  font-size: 12px;
  text-transform: none;
}

.main {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(380px, 1fr) minmax(320px, 420px);
  min-height: 0;
  overflow: hidden;
}

.panel {
  border-right: 1px solid var(--border);
  background: var(--canvas);
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.panel:last-child {
  border-right: 0;
}

.panel-header {
  padding: 12px 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: var(--canvas-subtle);
  color: var(--text);
  font-size: 14px;
  letter-spacing: normal;
}

.panel-header::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--success);
}

.form {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 5px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: none;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--canvas);
  color: var(--text);
  padding: 5px 8px;
  min-height: 36px;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  box-shadow: inset 0 1px 0 rgba(208, 215, 222, 0.2);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px rgba(9, 105, 218, 0.18);
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.timeline {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  justify-content: flex-start;
  background: var(--canvas-subtle);
}

.timeline-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.timeline-panel .timeline {
  min-height: 0;
  overflow: auto;
}

.event {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--canvas);
  padding: 10px 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.event.ai {
  background: #f0f7ff;
  border-color: #c8e1ff;
}

.event.user {
  background: var(--canvas);
}

.event.selected {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent), 0 0 0 3px rgba(9, 105, 218, 0.1);
}

.event-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.event-body {
  margin-top: 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  line-height: 1.46;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  background: #afb8c133;
  border: 1px solid transparent;
  border-radius: 2em;
  color: #24292f;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
}

.pill.chat {
  background: #dafbe1;
  color: #116329;
}

.pill.error {
  background: #ffebe9;
  color: var(--danger);
}

.pill.system {
  background: #fff8c5;
  color: var(--attention);
}

.composer {
  border-top: 1px solid var(--border);
  background: var(--canvas);
  padding: 12px;
  box-shadow: 0 -1px 0 rgba(31, 35, 40, 0.04);
  display: grid;
  gap: 10px;
  flex-shrink: 0;
}

.json {
  margin: 0;
  padding: 14px;
  min-height: calc(100vh - 106px);
  overflow: auto;
  background: var(--canvas-subtle);
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo,
    monospace;
}

.empty {
  padding: 24px;
  color: var(--muted);
}

@media (max-width: 1000px) {
  .shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .main {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .timeline-panel {
    min-height: min(720px, calc(100vh - 52px));
  }
}
