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

:root {
  --bg: #0f0f13;
  --surface: #1a1a24;
  --surface2: #22222f;
  --border: #2e2e40;
  --text: #e8e8f0;
  --muted: #888899;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --orange: #f97316;
  --blue: #3b82f6;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

html { font-size: 15px; }
body { background: var(--bg); color: var(--text); font-family: 'Segoe UI', system-ui, sans-serif; min-height: 100vh; }

/* HEADER */
.header { border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 100; }
.header-inner { max-width: 900px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; height: 58px; gap: 16px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; font-weight: 700; color: var(--text); }
.tabs { display: flex; gap: 4px; }
.tab { background: none; border: none; color: var(--muted); padding: 7px 14px; border-radius: 6px; cursor: pointer; font-size: 0.9rem; font-weight: 500; transition: all 0.15s; }
.tab:hover:not(:disabled) { color: var(--text); background: var(--surface2); }
.tab.active { color: var(--accent); background: rgba(99,102,241,0.12); }
.tab:disabled { opacity: 0.35; cursor: default; }

/* MAIN */
.main { max-width: 900px; margin: 0 auto; padding: 32px 20px 60px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* PANEL HEADER */
.panel-header { margin-bottom: 28px; }
.panel-header h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: 6px; }
.panel-header p { color: var(--muted); }

/* VALIDATE ACTION BUTTONS */
.validate-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.validate-actions .btn-secondary { display: inline-flex; align-items: center; gap: 8px; padding: 9px 18px; font-size: 0.88rem; }

/* FORM */
.form { display: flex; flex-direction: column; gap: 18px; }
.form-row.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media(max-width:600px){ .form-row.two-col { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.85rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.req { color: var(--accent); }
.field input[type=text], .field input[type=password], .field textarea, .field select {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 10px 14px; border-radius: var(--radius); font-size: 0.95rem; font-family: inherit;
  transition: border-color 0.15s; resize: vertical; width: 100%;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); }
.field select option { background: var(--surface2); }
.hint { color: var(--muted); font-size: 0.8rem; }
.input-icon-wrap { position: relative; }
.input-icon-wrap input { padding-right: 44px; }
.icon-btn { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px; display: flex; }
.icon-btn:hover { color: var(--text); }

/* SLIDER */
.slider { width: 100%; accent-color: var(--accent); }
.slider-labels { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--muted); margin-top: 4px; }

/* BUTTON */
.btn-primary {
  background: var(--accent); color: #fff; border: none; padding: 12px 28px;
  border-radius: var(--radius); font-size: 1rem; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; transition: background 0.15s;
  align-self: flex-start;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.form-actions { margin-top: 8px; }
.btn-loading { display: inline-flex; align-items: center; gap: 8px; }
.hidden { display: none !important; }
.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ERRORS */
.error-banner { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.35); color: #fca5a5; padding: 12px 16px; border-radius: var(--radius); font-size: 0.9rem; }
.settings-msg { padding: 12px 16px; border-radius: var(--radius); font-size: 0.9rem; }
.settings-msg.success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); color: #86efac; }
.settings-msg.error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.35); color: #fca5a5; }

/* REPORT */
.report { display: flex; flex-direction: column; gap: 32px; }
.report-hero { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px 32px; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.report-title-block h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.report-title-block .ts { color: var(--muted); font-size: 0.82rem; }
.score-big { font-size: 3rem; font-weight: 800; line-height: 1; }
.score-denom { font-size: 1.2rem; font-weight: 400; color: var(--muted); }
.verdict-badge { display: inline-flex; padding: 5px 14px; border-radius: 999px; font-size: 0.85rem; font-weight: 700; letter-spacing: 0.03em; }
.verdict-Promising { background: rgba(34,197,94,0.15); color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.verdict-Neutral   { background: rgba(234,179,8,0.12); color: #facc15; border: 1px solid rgba(234,179,8,0.3); }
.verdict-Risky     { background: rgba(239,68,68,0.12); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }

/* SECTION TITLES */
.section-title { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 14px; }

/* SCORE GRID */
.score-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media(max-width:600px){ .score-grid { grid-template-columns: repeat(2, 1fr); } }
.score-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.score-card-label { font-size: 0.78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.score-card-num { font-size: 1.9rem; font-weight: 800; line-height: 1; margin-bottom: 6px; }
.score-card-num .denom { font-size: 0.85rem; font-weight: 400; color: var(--muted); }
.score-card-verdict { font-size: 0.82rem; color: var(--muted); line-height: 1.4; }
.score-high { color: var(--green); }
.score-mid  { color: var(--yellow); }
.score-low  { color: var(--red); }

/* SCORE BAR */
.score-bar-wrap { margin-top: 8px; height: 4px; background: var(--border); border-radius: 4px; overflow: hidden; }
.score-bar { height: 100%; border-radius: 4px; transition: width 0.6s ease; }

/* NARRATIVE */
.narrative { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 28px; }
.narrative p { line-height: 1.75; color: var(--text); font-size: 0.95rem; }
.narrative p + p { margin-top: 14px; }

/* RECOMMENDATIONS */
.rec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media(max-width:600px){ .rec-grid { grid-template-columns: 1fr; } }
.rec-card { border-radius: var(--radius); padding: 18px 20px; border-left: 4px solid; }
.rec-warning { background: rgba(249,115,22,0.08); border-color: var(--orange); }
.rec-info    { background: rgba(59,130,246,0.08); border-color: var(--blue); }
.rec-success { background: rgba(34,197,94,0.08);  border-color: var(--green); }
.rec-danger  { background: rgba(239,68,68,0.08);  border-color: var(--red); }
.rec-icon-title { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.rec-type-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.rec-warning .rec-type-dot { background: var(--orange); }
.rec-info    .rec-type-dot { background: var(--blue); }
.rec-success .rec-type-dot { background: var(--green); }
.rec-danger  .rec-type-dot { background: var(--red); }
.rec-title { font-weight: 700; font-size: 0.92rem; }
.rec-body { font-size: 0.88rem; color: var(--muted); line-height: 1.6; }

/* IMPROVE IDEA SECTION */
.improve-section { background: linear-gradient(135deg, rgba(99,102,241,0.07) 0%, rgba(129,140,248,0.03) 100%); border: 1px solid rgba(99,102,241,0.28); border-radius: 14px; padding: 28px 32px; display: flex; flex-direction: column; gap: 22px; }
.improve-banner { display: flex; align-items: flex-start; gap: 16px; }
.improve-icon { width: 44px; height: 44px; background: rgba(99,102,241,0.15); border: 1px solid rgba(99,102,241,0.3); border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--accent); }
.improve-headline { font-size: 1.05rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.improve-summary { font-size: 0.92rem; color: var(--muted); line-height: 1.7; }
.improve-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media(max-width:600px){ .improve-fields { grid-template-columns: 1fr; } }
.improve-field { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.improve-field-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin-bottom: 6px; }
.improve-field-value { font-size: 0.88rem; color: var(--text); line-height: 1.55; }
.btn-improve { align-self: flex-start; background: var(--accent); color: #fff; border: none; padding: 13px 26px; border-radius: var(--radius); font-size: 0.95rem; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 10px; transition: background 0.15s, transform 0.1s; }
.btn-improve:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-improve:active { transform: translateY(0); }

/* HISTORY */
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-empty { color: var(--muted); font-size: 0.95rem; padding: 40px 0; text-align: center; }
.history-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.history-title { font-weight: 600; flex: 1; min-width: 120px; }
.history-score { font-size: 1.05rem; font-weight: 700; }
.history-date { color: var(--muted); font-size: 0.82rem; }
.btn-secondary { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 6px 16px; border-radius: 6px; cursor: pointer; font-size: 0.85rem; font-weight: 500; transition: background 0.15s; display: inline-flex; align-items: center; gap: 8px; }
.btn-secondary:hover { background: var(--border); }

/* SETTINGS */
.settings-form { max-width: 580px; }

/* Provider pills */
.provider-pills { display: flex; gap: 10px; flex-wrap: wrap; }
.provider-pill {
  padding: 8px 20px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--muted); cursor: pointer;
  font-size: 0.88rem; font-weight: 600; transition: all 0.15s;
}
.provider-pill:hover { border-color: var(--accent); color: var(--text); }
.provider-pill.active { background: rgba(99,102,241,0.15); border-color: var(--accent); color: var(--accent); }

/* API Keys block */
.keys-section { display: flex; flex-direction: column; gap: 10px; }
.keys-title { font-size: 0.85rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.keys-grid { display: flex; flex-direction: column; gap: 8px; }
.key-row { display: flex; align-items: center; gap: 12px; }
.key-label { font-size: 0.85rem; font-weight: 600; color: var(--text); width: 80px; flex-shrink: 0; }
.key-row.active-provider .key-label { color: var(--accent); }

/* inline code */
code { background: var(--surface2); padding: 1px 6px; border-radius: 4px; font-size: 0.82em; color: var(--accent-hover); }

/* Provider tags on report / history */
.provider-tag { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; margin-right: 6px; }
.provider-tag.small { font-size: 0.72rem; padding: 2px 8px; }
.provider-anthropic { background: rgba(99,102,241,0.12); color: #a5b4fc; border: 1px solid rgba(99,102,241,0.25); }
.provider-openai    { background: rgba(34,197,94,0.10);  color: #86efac; border: 1px solid rgba(34,197,94,0.25); }
.auth-hidden { visibility: hidden; pointer-events: none; }
.auth-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.72); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.auth-modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.auth-modal h2 { margin-bottom: 6px; }
.auth-subtitle { color: var(--muted); margin-bottom: 20px; font-size: 0.9rem; }
.auth-modal label { display: block; margin-bottom: 14px; font-size: 0.85rem; color: var(--muted); }
.auth-modal input[type="text"], .auth-modal input[type="password"] { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); }
.auth-trust { display: flex !important; align-items: center; gap: 8px; color: var(--text) !important; }
.auth-error { background: rgba(239,68,68,0.12); color: #fca5a5; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 0.85rem; }
.auth-submit { width: 100%; margin-top: 8px; }
