:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface-2: #1a1a26;
  --border: #2a2a3a;
  --text: #e4e4ef;
  --text-muted: #8888a0;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

header {
  text-align: center;
  margin-bottom: 2.5rem;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

header h1 span { color: var(--accent); }

header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.input-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.input-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.input-header label {
  font-weight: 600;
  font-size: 0.95rem;
}

.type-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}

.type-select:focus { outline: 2px solid var(--accent); outline-offset: 2px; }

textarea {
  width: 100%;
  min-height: 200px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 1rem;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  line-height: 1.6;
}

textarea:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }
textarea::placeholder { color: var(--text-muted); }

.actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.btn {
  padding: 0.6rem 1.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-secondary:hover { color: var(--text); border-color: var(--text-muted); }

.word-count {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

/* Loading */
.loading {
  display: none;
  text-align: center;
  padding: 3rem;
}

.loading.active { display: block; }

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading p { color: var(--text-muted); font-size: 0.9rem; }

/* Results */
.results {
  display: none;
}

.results.active { display: block; }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}

.metric-card .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.metric-card .value {
  font-size: 1.5rem;
  font-weight: 700;
}

.metric-card .sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Sentiment gauge */
.gauge-container {
  position: relative;
  width: 120px;
  height: 64px;
  margin: 0 auto;
  overflow: hidden;
}

.gauge-bg {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: conic-gradient(
    from 180deg,
    var(--red) 0deg,
    var(--yellow) 90deg,
    var(--green) 180deg
  );
  position: absolute;
  top: 0;
}

.gauge-mask {
  width: 80px;
  height: 80px;
  background: var(--surface);
  border-radius: 50%;
  position: absolute;
  top: 20px;
  left: 20px;
}

.gauge-needle {
  width: 2px;
  height: 50px;
  background: var(--text);
  position: absolute;
  bottom: 0;
  left: 59px;
  transform-origin: bottom center;
  transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-radius: 1px;
}

.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.section-card h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.section-card p {
  font-size: 0.95rem;
  line-height: 1.7;
}

.section-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.section-card li {
  padding: 0.5rem 0.75rem;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 0.9rem;
  position: relative;
  padding-left: 1.5rem;
}

.section-card li::before {
  content: '';
  position: absolute;
  left: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.insights-list li::before { background: var(--accent); }
.risks-list li::before { background: var(--red); }
.catalysts-list li::before { background: var(--green); }

.action-box {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(99, 102, 241, 0.05));
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.disclaimer {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-style: italic;
  margin-top: 0.75rem;
}

/* History */
.history-section {
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.history-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color 0.15s;
}

.history-item:hover { border-color: var(--accent); }

.history-item .preview {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}

.history-item .meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.sentiment-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.hidden { display: none; }

@media (max-width: 640px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .container { padding: 1rem; }
}
