:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --paper: #fffdfa;
  --panel: #ffffff;
  --text: #16202a;
  --muted: #667486;
  --line: #d8dee7;
  --teal: #0f766e;
  --teal-dark: #0a5f59;
  --ink: #213547;
  --amber: #8a5a12;
  --amber-soft: #fff4dd;
  --violet: #5b3db5;
  --violet-soft: #f0ecff;
  --shadow: 0 18px 45px rgba(22, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.74), rgba(243,245,247,0.94)),
    repeating-linear-gradient(0deg, rgba(15, 118, 110, 0.025) 0 1px, transparent 1px 34px);
  color: var(--text);
  font-family: Tahoma, Arial, sans-serif;
}

.layout {
  width: min(1180px, calc(100% - 32px));
  margin: 30px auto 46px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 2px 22px;
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0 0 7px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.15;
  color: var(--ink);
}

p {
  margin: 0;
}

#stats {
  color: var(--muted);
  font-size: 15px;
}

.era-badge {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid #ead4a9;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.ask {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modebar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--teal);
  color: white;
  font: 700 16px Tahoma, Arial, sans-serif;
  padding: 11px 20px;
  cursor: pointer;
}

button:hover {
  background: var(--teal-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

button.secondary {
  background: #e8eef2;
  color: var(--text);
}

button.mode {
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  background: #f7f9fb;
  color: var(--muted);
  font-size: 13px;
}

button.mode.active {
  border-color: #cfc5ff;
  background: var(--violet-soft);
  color: var(--violet);
}

textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
  color: var(--text);
  font: 18px Tahoma, Arial, sans-serif;
  line-height: 1.75;
  outline: none;
}

textarea:focus {
  border-color: #81bdb7;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.actions {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  margin-top: 12px;
}

.answer {
  margin-top: 18px;
  padding: clamp(20px, 3vw, 34px);
  border: 1px solid #e2d8c3;
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  line-height: 1.95;
  font-size: 18px;
}

.answer.empty,
.answer.loading {
  color: var(--muted);
}

.answer h2 {
  margin: 22px 0 10px;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.45;
}

.answer h2:first-child {
  margin-top: 0;
}

.answer p {
  margin: 0 0 12px;
}

.answer ul {
  margin: 0 0 16px;
  padding: 0 24px 0 0;
}

.answer li {
  margin: 0 0 8px;
}

.answer strong {
  color: var(--teal-dark);
}

.answer-point {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: start;
  margin: 0 0 13px;
}

.answer-point span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--violet-soft);
  color: var(--violet);
  font-weight: 700;
}

.sources {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.source {
  min-height: 210px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.source-kicker {
  margin-bottom: 8px;
  color: var(--amber);
  font-size: 13px;
  font-weight: 700;
}

.source h3 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.45;
}

.source p {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
}

.source .forum {
  margin-bottom: 8px;
  color: #506070;
  font-weight: 700;
}

.badge {
  display: inline-block;
  margin-top: 14px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #eef7f6;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 720px) {
  .layout {
    width: min(100% - 22px, 1180px);
    margin-top: 18px;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .ask {
    padding: 12px;
  }

  textarea,
  .answer {
    font-size: 16px;
  }

  .actions {
    flex-direction: column;
  }

  button {
    width: 100%;
  }
}
