:root {
  --bg: #050816;
  --panel: rgba(15, 23, 42, 0.9);
  --panel-soft: rgba(15, 23, 42, 0.72);
  --line: rgba(148, 163, 184, 0.18);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #f97316;
  --accent-2: #38bdf8;
  --danger: #ef4444;
  --success: #10b981;
  --shadow: 0 18px 60px rgba(2, 6, 23, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(249, 115, 22, 0.12), transparent 24%),
    linear-gradient(180deg, #020617 0%, #050816 52%, #071124 100%);
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(148, 163, 184, 0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(148, 163, 184, 0.05) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent 90%);
}

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

button {
  cursor: pointer;
  border: none;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 24px 16px 120px;
}

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

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.topbar h1,
.panel-header h2 {
  margin: 0;
  font-weight: 700;
  line-height: 1.05;
}

.topbar h1 {
  font-size: clamp(32px, 5vw, 48px);
}

.layout,
.workspace {
  display: grid;
  gap: 14px;
}

.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.8));
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255,255,255,0.07), transparent 22%, transparent 80%, rgba(56, 189, 248, 0.08));
}

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

.panel-header.narrow-gap {
  margin-bottom: 12px;
}

.stack-form,
.event-composer {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 8px;
}

label span,
.badge,
.status-pill,
.muted,
.inline-message {
  font-size: 13px;
}

input,
textarea,
select {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.72);
  color: var(--text);
  padding: 14px 15px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 112px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(56, 189, 248, 0.7);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.14);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  background: rgba(2, 6, 23, 0.6);
  border-radius: 16px;
  padding: 6px;
}

.segment {
  border-radius: 12px;
  padding: 12px 10px;
  background: transparent;
  color: var(--muted);
}

.segment.active {
  background: rgba(56, 189, 248, 0.16);
  color: var(--text);
}

.primary-button,
.secondary-button,
.ghost-button,
.voice-button,
.quick-chip {
  border-radius: 16px;
  min-height: 48px;
  padding: 12px 16px;
  transition: transform 0.14s ease, opacity 0.14s ease, background 0.14s ease;
}

.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.voice-button:active,
.quick-chip:active,
.segment:active {
  transform: scale(0.98);
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), #fb923c);
  color: #fff7ed;
  font-weight: 700;
}

.secondary-button {
  background: rgba(56, 189, 248, 0.14);
  color: var(--text);
}

.ghost-button {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text);
}

.voice-button {
  background: linear-gradient(135deg, rgba(248, 113, 113, 0.88), rgba(249, 115, 22, 0.88));
  color: white;
  font-weight: 600;
}

.voice-button.listening {
  box-shadow: 0 0 0 8px rgba(248, 113, 113, 0.12);
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.quick-chip {
  background: rgba(56, 189, 248, 0.1);
  color: var(--text);
}

.quick-chip.active {
  background: rgba(56, 189, 248, 0.24);
}

.composer-row,
.composer-actions,
.action-strip {
  display: grid;
  gap: 10px;
}

.composer-row {
  grid-template-columns: 1fr 1fr;
}

.composer-actions,
.action-strip {
  grid-template-columns: 1fr 1fr;
}

.badge,
.status-pill {
  align-self: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-2);
}

.status-pill.live {
  color: var(--success);
  background: rgba(16, 185, 129, 0.12);
}

.inline-message {
  min-height: 18px;
  color: var(--accent-2);
}

.hidden {
  display: none !important;
}

.empty-state {
  color: var(--muted);
  padding: 18px;
  border-radius: 18px;
  border: 1px dashed rgba(148, 163, 184, 0.2);
  background: rgba(2, 6, 23, 0.32);
}

.event-list,
.history-list,
.score-list {
  display: grid;
  gap: 10px;
}

.event-card,
.history-card,
.score-card {
  position: relative;
  padding: 14px;
  border-radius: 18px;
  background: rgba(2, 6, 23, 0.38);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.event-meta,
.history-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.mini-tag {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-2);
}

.mini-tag.critical {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
}

.mini-tag.concern {
  background: rgba(249, 115, 22, 0.14);
  color: #fdba74;
}

.analysis-summary {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.analysis-box {
  padding: 14px;
  border-radius: 18px;
  background: rgba(2, 6, 23, 0.38);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.analysis-box h3,
.score-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.score-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.score-card input[type="number"] {
  width: 80px;
  padding: 10px 12px;
}

.behavior-list,
.evidence-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.history-card button {
  margin-top: 10px;
  width: 100%;
}

@media (min-width: 720px) {
  .workspace {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .session-panel,
  .capture-panel,
  .timeline-panel,
  .analysis-panel,
  .history-panel {
    grid-column: span 1;
  }

  .analysis-panel,
  .history-panel {
    grid-column: span 2;
  }
}
