:root {
  --bg: #0f172a;
  --card: #111827;
  --accent: #38bdf8;
  --accent-soft: rgba(56,189,248,0.15);
  --text: #e5e7eb;
  --muted: #9ca3af;
  --danger: #f97373;
  --border: #1f2937;
  --radius: 0.75rem;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 1rem;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
}
.logo {
  display: block;
  margin: 0 auto;
  max-width: 200px;
}
.app {
  width: 100%;
  max-width: 720px;
}
h1 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
}
.tagline {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1rem;
  box-shadow: 0 18px 40px rgba(0,0,0,0.08);
  backdrop-filter: blur(12px);
}
.section-title {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}
select, input[type="number"], button, textarea {
  font-family: inherit;
  font-size: 1rem;
}
select, input[type="number"] {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background-color: var(--card);
  color: var(--text);
  outline: none;
}
select:focus, input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56,189,248,0.4);
}
.scale-fields {
  margin-top: 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: var(--card);
  padding: 0.85rem;
}
.scale-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.4rem;
  gap: 0.5rem;
}
.scale-name {
  font-size: 0.95rem;
  font-weight: 600;
}
.scale-hint {
  font-size: 0.8rem;
  color: var(--muted);
}
.grid {
  display: grid;
  gap: 0.5rem;
}
.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.field-group {
  background: var(--card);
  border-radius: 0.6rem;
  border: 1px solid var(--border);
  padding: 0.5rem 0.55rem 0.55rem;
}
.field-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.faces-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.face-option {
  flex: 1 1 28%;
  min-width: 80px;
  border-radius: 999px;
  padding: 0.4rem 0.3rem;
  border: 1px solid var(--border);
  background: rgba(15,23,42,0.96);
  font-size: 0.75rem;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
}
.face-option strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.15rem;
}
.face-option.active {
  background: linear-gradient(135deg, #38bdf8, #22c55e);
  color: #020617;
  border-color: transparent;
  box-shadow: 0 0 0 1px rgba(15,23,42,0.4);
}
.face-option.active strong {
  color: #020617;
}
.radio-row {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.25rem;
}
.radio-pill {
  flex: 1;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #020617;
  text-align: center;
  padding: 0.25rem 0.2rem;
  font-size: 0.75rem;
  cursor: pointer;
  color: var(--muted);
}
.radio-pill span {
  display: block;
  font-size: 0.75rem;
}
.radio-pill.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}
.radio-pill strong {
  display: block;
  font-size: 0.85rem;
}
.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
  padding-top: 0.55rem;
  border-top: 1px dashed rgba(75,85,99,0.7);
  gap: 0.5rem;
  flex-wrap: wrap;
}
.score-main {
  font-size: 0.92rem;
}
.score-band {
  font-size: 0.8rem;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
}
.band-none { color: #4ade80; border-color: rgba(16,185,129,0.6); }
.band-mild { color: #a3e635; border-color: rgba(132,204,22,0.6); }
.band-moderate { color: #f97316; border-color: rgba(249,115,22,0.7); }
.band-severe { color: #fb7185; border-color: rgba(239,68,68,0.8); }
.narrative {
  margin-top: 0.9rem;
}
.narrative textarea {
  width: 100%;
  min-height: 90px;
  border-radius: 0.6rem;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 0.55rem 0.6rem;
  resize: vertical;
  font-size: 0.92rem;
}
.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.55rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.btn {
  border-radius: 999px;
  border: none;
  padding: 0.5rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg,#38bdf8,#22c55e);
  color: #020617;
  font-weight: 600;
}
.btn-secondary {
  background: rgba(15,23,42,0.9);
  color: var(--muted);
  border: 1px solid var(--border);
}
.status {
  font-size: 0.8rem;
  color: var(--muted);
}
.status.ok {
  color: #4ade80;
}
.status.err {
  color: var(--danger);
}
footer {
  margin-top: 0.9rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}
.btn-toggle {
  background: #fff;
  color: #000;
  border: 1px solid #000;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.5rem 1rem;
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 10;
  transition: background 0.2s, color 0.2s;
}
body.night .btn-toggle {
  background: #000;
  color: #fff;
  border: 1px solid #fff;
}
body.day .btn-toggle {
  background: #fff;
  color: #000;
  border: 1px solid #000;
}

body.day {
  --bg: #fff;
  --card: #f7f7f7;
  --accent: #222;
  --accent-soft: rgba(34,34,34,0.08);
  --text: #222;
  --muted: #555;
  --danger: #dc2626;
  --border: #bbb;
}
body.night {
  --bg: #0f172a;
  --card: #111827;
  --accent: #38bdf8;
  --accent-soft: rgba(56,189,248,0.15);
  --text: #e5e7eb;
  --muted: #9ca3af;
  --danger: #f97373;
  --border: #1f2937;
}
@media (max-width: 480px) {
  body { padding: 0.5rem; }
  .card { padding: 0.8rem; }
  .faces-row { gap: 0.3rem; }
  .grid-2 { grid-template-columns: 1fr; }
  h1 { font-size: 1.2rem; }
  .tagline { font-size: 0.8rem; }
}

@media (min-width: 481px) and (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr; }
}

@media (min-width: 769px) {
  .app { max-width: 800px; }
}

a {
  color: var(--accent);
  text-decoration: underline;
  transition: color 0.2s;
}
a:hover, a:focus {
  color: #22c55e;
}

header {
  background: #111827;
  width: 100vw;
  margin-left: calc(-1 * ((100vw - 100%) / 2));
  padding: 2rem 0 1rem 0;
  text-align: center;
}
body.day header {
  background: #222;
}
header, body.day header {
  color: #fff;
}
header .tagline,
header h1 {
  color: #fff;
}
