:root {
  --bg: #0f1117;
  --bg-elevated: #171b26;
  --bg-card: #1c2233;
  --border: #2a3348;
  --text: #e8ecf4;
  --text-muted: #9aa5be;
  --accent: #6b9fff;
  --accent-dim: #3d5a8a;
  --positive: #4ecb8c;
  --radius: 8px;
  --space: 1rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.app-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.app-header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.app-header .tagline {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.operator-identity {
  margin: 0.35rem 0 0;
  color: var(--accent);
  font-size: 0.8rem;
}

.login-panel,
.home-panel,
.import-panel,
.survey-panel {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

.operator-panel {
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
}

.operator-panel .hint,
.operator-section .hint {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.operator-hero h2 {
  margin: 0 0 0.35rem;
}

.operator-section {
  margin-top: 2rem;
}

.operator-section h3 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-value {
  font-size: 1.5rem;
  line-height: 1.2;
}

.stat-detail {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.operator-card {
  margin-top: 0.75rem;
  padding: 0.9rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.operator-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.operator-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
  font-size: 0.875rem;
}

.operator-table th,
.operator-table td {
  border: 1px solid var(--border);
  padding: 0.55rem 0.7rem;
  text-align: left;
  vertical-align: top;
}

.operator-table th {
  background: var(--bg-card);
  color: var(--text-muted);
  font-weight: 600;
}

.console-back {
  margin-bottom: 0.75rem;
  padding: 0.35rem 0;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.console-back:hover {
  text-decoration: underline;
}

.home-panel .hint,
.import-panel .hint {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.path-cards {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.path-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.path-card strong {
  display: block;
  margin-bottom: 0.35rem;
}

.path-card span {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.path-card:hover {
  border-color: var(--accent);
}

.import-panel label {
  display: block;
  margin: 1rem 0 0.35rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.import-panel input[type="text"],
.import-panel input[type="file"] {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
}

.import-actions {
  margin-top: 1rem;
}

.import-result {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  font-size: 0.9rem;
}

.login-panel label {
  display: block;
  margin: 1rem 0 0.35rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.login-panel input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
}

.login-panel .hint {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.google-signin-slot {
  margin-top: 1rem;
  min-height: 44px;
}

.token-login-details {
  margin-top: 1.25rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.875rem;
}

.token-login-details summary {
  cursor: pointer;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.btn {
  margin-top: 0.75rem;
  margin-right: 0.5rem;
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent-dim);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--text);
}

#progress {
  margin-bottom: 1rem;
}

.progress-track {
  height: 6px;
  background: var(--bg-card);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border);
}

#progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
}

#progress-label {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

#chat {
  flex: 1;
  min-height: 280px;
  max-height: 55vh;
  overflow-y: auto;
  padding: 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.msg {
  max-width: 88%;
  margin-bottom: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.45;
}

.msg.bot {
  background: var(--bg-card);
  border: 1px solid var(--border);
  margin-right: auto;
}

.msg.user {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  margin-left: auto;
}

#composer {
  padding-top: 0.5rem;
}

.scale-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.scale-buttons button {
  min-width: 2.25rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.scale-buttons button:hover,
.scale-buttons button.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}

#free-text {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
  resize: vertical;
  margin-bottom: 0.75rem;
}

.assignment-picker h2 {
  font-size: 1rem;
  margin: 0 0 0.75rem;
}

#assignment-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}

#assignment-list li {
  margin-bottom: 0.5rem;
}

#assignment-list button {
  width: 100%;
  text-align: left;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

#assignment-list button:hover {
  border-color: var(--accent);
}
