:root {
  --bg: #0f0f12;
  --surface: #1a1a20;
  --border: #2a2a32;
  --text: #e8e8ed;
  --muted: #8888a0;
  --accent: #6c5ce7;
  --accent-hover: #7d6ef7;
  --error: #e74c3c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

#app {
  max-width: 420px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.btn-logout {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-logout:hover {
  color: var(--text);
  border-color: var(--text);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

#auth-actions button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

#auth-actions button:hover {
  color: var(--text);
  border-color: var(--text);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.card h2 {
  margin: 0 0 1.25rem;
  font-size: 1.25rem;
}

.next-question-block {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.next-question-label {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.next-question {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--text);
}

.next-funfact-section {
  margin-bottom: 1.5rem;
  padding: 1.25rem 1rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.next-funfact-body {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.next-psytest-section {
  margin-bottom: 1rem;
}

.psytest-subtitle-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.next-psytest-subtitle {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.45;
  flex: 1;
}

.btn-psytest-info {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
}

.btn-psytest-info:hover {
  color: var(--text);
  border-color: var(--text);
}

.next-psytest-info-panel {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  white-space: pre-line;
}

.psytest-q-block {
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.psytest-q-text {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--text);
}

.psytest-rating-row {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.psytest-rating-btn {
  width: 100%;
  padding: 0.55rem 0.75rem;
  text-align: left;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.35;
}

.psytest-rating-btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.psytest-rating-btn:disabled {
  cursor: default;
  opacity: 0.85;
}

.psytest-rating-btn.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.next-psytest-actions {
  margin-top: 1rem;
}

.next-psytest-actions .btn.btn-primary {
  width: 100%;
  padding: 0.65rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}

.next-psytest-actions .btn.btn-primary:hover {
  background: var(--accent-hover);
}

.next-finished-msg {
  margin: 0 0 1rem;
  font-size: 1rem;
  color: var(--muted);
}

.next-conversation-history {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.next-conversation-label {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.next-conversation-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.next-conversation-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.next-conversation-item:last-child {
  border-bottom: none;
}

.next-conversation-question {
  margin: 0 0 0.25rem;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.4;
}

.next-conversation-response {
  margin: 0;
  font-size: 1rem;
  color: var(--text);
  line-height: 1.4;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

.form-group textarea {
  resize: vertical;
  min-height: 5rem;
}

.form-group input::placeholder {
  color: var(--muted);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group input.invalid,
.form-group select.invalid,
.form-group .radio-group.invalid {
  border-color: var(--error);
  box-shadow: 0 0 0 1px var(--error);
}

.form-group select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
}

.radio-group {
  display: flex;
  gap: 1rem;
  margin-top: 0.35rem;
}

.radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--text);
}

.intro-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.header .intro-header {
  text-align: left;
  margin-bottom: 0;
}

.intro-header .phase1 { font-size: 0.95rem; color: var(--muted); margin: 0.25rem 0; }
.intro-header .basic { font-size: 1rem; margin: 0.5rem 0 0; }

.error {
  color: var(--error);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.hidden {
  display: none !important;
}

button[type="submit"] {
  width: 100%;
  padding: 0.65rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  margin-top: 0.25rem;
}

button[type="submit"]:hover {
  background: var(--accent-hover);
}

.auth-switch {
  margin: 1rem 0 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.auth-switch a {
  color: var(--accent);
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.gate-card .gate-prompt {
  margin: 0 0 1.25rem;
  color: var(--muted);
}

.gate-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.gate-actions .btn {
  display: block;
  text-align: center;
  padding: 0.65rem;
  text-decoration: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}

.gate-actions .btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.gate-actions .btn-secondary:hover {
  background: #1e1e24;
}

.welcome {
  margin: 0 0 0.5rem;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.muted code {
  background: var(--bg);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85em;
}

.label-text { display: block; margin-bottom: 0.35rem; font-size: 0.9rem; color: var(--muted); }
.field-error { color: var(--error); font-size: 0.85rem; margin-top: 0.25rem; display: block; }
.form-error { margin-top: 0.5rem; }
.small { font-size: 0.85rem; margin-top: 0.25rem; }
button[type="submit"]:disabled { opacity: 0.5; cursor: not-allowed; }

/* FactTest screen */
.next-facttest-section {
  margin-bottom: 1rem;
}

.next-facttest-subtitle {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.45;
}

.facttest-q-block {
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.facttest-q-text {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--text);
}

.facttest-options-col {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.facttest-option-btn {
  width: 100%;
  padding: 0.55rem 0.75rem;
  text-align: left;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.35;
}

.facttest-option-btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.facttest-option-btn:disabled {
  cursor: default;
  opacity: 0.85;
}

.facttest-option-btn.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.next-facttest-actions {
  margin-top: 1rem;
}

.next-facttest-actions .btn.btn-primary {
  width: 100%;
  padding: 0.65rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}

.next-facttest-actions .btn.btn-primary:hover {
  background: var(--accent-hover);
}

/* PsyResult screen */
.next-psyresult-section {
  margin-bottom: 1rem;
}

.next-psyresult-subtitle {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.45;
}

.next-psyresult-similarity {
  margin-bottom: 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 0.92rem;
}

.next-psyresult-total-score-label {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.next-psyresult-score-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.next-psyresult-score-pie {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

.next-psyresult-score-pie::after {
  content: '';
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  position: absolute;
}

.next-psyresult-score-number {
  position: relative;
  z-index: 1;
  font-size: 0.9rem;
  font-weight: 700;
}

.next-psyresult-score-text {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
}

.next-psyresult-dimensions {
  margin-bottom: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.next-psyresult-dim-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
}

.next-psyresult-dim-name {
  margin: 0 0 0.45rem;
  font-size: 0.86rem;
  color: var(--muted);
}

.next-psyresult-bar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.next-psyresult-bar-row:last-child {
  margin-bottom: 0;
}

.next-psyresult-bar {
  height: 10px;
  border-radius: 999px;
  min-width: 2px;
}

.next-psyresult-bar-your {
  background: #39d98a;
}

.next-psyresult-bar-ai {
  background: #4f8bff;
}

.next-psyresult-bar-value {
  font-size: 0.82rem;
  color: var(--text);
}

.next-psyresult-legend {
  display: flex;
  gap: 0.9rem;
  margin-bottom: 0.75rem;
  font-size: 0.84rem;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.legend-your {
  background: #39d98a;
}

.legend-ai {
  background: #4f8bff;
}

.next-psyresult-table-wrap {
  overflow-x: auto;
}

.next-psyresult-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.next-psyresult-table th,
.next-psyresult-table td {
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.88rem;
  vertical-align: top;
}

.next-psyresult-table th {
  color: var(--muted);
  font-weight: 600;
}

.next-psyresult-table tbody tr:last-child td {
  border-bottom: none;
}

.next-psyresult-empty {
  color: var(--muted);
  padding: 0.75rem 0.8rem;
}
