:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1c1c1e;
  --text-muted: #6b6b70;
  --border: #e5e5ea;
  --accent: #4f46e5;
  --accent-contrast: #ffffff;
  --error: #d92d20;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101014;
    --surface: #1c1c22;
    --text: #f2f2f5;
    --text-muted: #9a9aa2;
    --border: #2e2e36;
    --accent: #7c74f1;
    --accent-contrast: #ffffff;
    --error: #ff6b61;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* --- Login --- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.login-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-contrast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 22px;
}

.login-card h1 {
  margin: 0;
  font-size: 20px;
}

.login-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
}

.login-error {
  margin: 0;
  color: var(--error);
  font-size: 14px;
  text-align: center;
}

.login-card input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}

.login-card button {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.login-card button:active {
  opacity: 0.85;
}

/* --- App shell --- */

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.app-header-title {
  font-weight: 700;
  font-size: 17px;
}

.logout-button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

.app-main {
  flex: 1;
  padding: 24px 20px 96px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.placeholder-card {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 28px 24px;
  margin-top: 24px;
}

.review-card {
  width: 100%;
  max-width: 620px;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 26px 22px;
}

.review-card h1 { margin: 0 0 22px; font-size: 24px; }
.review-card h2 { margin: 24px 0 8px; font-size: 16px; }
.review-card ul, .review-card ol { padding-left: 22px; line-height: 1.5; }
.review-card p { line-height: 1.5; }
.review-badge {
  display: inline-block;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 999px;
  padding: 5px 10px;
  margin-bottom: 14px;
  font-size: 12px;
  font-weight: 700;
}
.review-lines { display: flex; flex-direction: column; gap: 7px; }
.review-line { margin: 0; white-space: pre-wrap; }
.review-line.is-question {
  margin-top: 6px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--bg);
}

.answer-section {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.section-kicker,
.question-progress {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.answer-form {
  margin-top: 12px;
}

.answer-form.has-js .question-card {
  display: none;
}

.answer-form.has-js .question-card.is-active {
  display: block;
}

.question-card {
  margin-top: 12px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg);
}

.question-card h2 {
  margin: 8px 0 5px;
  font-size: 19px;
  line-height: 1.35;
}

.item-id {
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.question-card label {
  display: block;
  margin: 20px 0 7px;
  font-size: 13px;
  font-weight: 650;
}

.question-card textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 13px 14px;
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
}

.question-card textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-color: var(--accent);
}

.question-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 14px;
}

.primary-button,
.secondary-button {
  border-radius: 11px;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
}

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

.processing-hint {
  margin: 12px 2px 0 !important;
  color: var(--text-muted);
  font-size: 12px;
}

.answer-saved {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 12px;
  padding: 16px;
  border-radius: 14px;
  background: color-mix(in srgb, #22a06b 12%, var(--surface));
}

.answer-saved-icon {
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  height: 28px;
  border-radius: 50%;
  background: #22a06b;
  color: white;
  font-weight: 800;
}

.answer-saved p {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.saved-answers {
  margin-top: 12px;
  padding: 12px 15px;
  border: 1px solid var(--border);
  border-radius: 13px;
}

.saved-answers p {
  margin: 5px 0;
}

@media (max-width: 520px) {
  .app-main { padding: 14px 12px 92px; }
  .review-card { padding: 20px 16px; border-radius: 16px; }
  .question-card { padding: 17px 14px; }
}

.placeholder-badge {
  display: inline-block;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.placeholder-card h1 {
  font-size: 19px;
  margin: 0 0 10px;
}

.placeholder-card p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
  font-size: 15px;
}

/* --- Bottom navigation --- */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: none;
}

.bottom-nav-icon {
  font-size: 20px;
}

.bottom-nav-item.is-active {
  color: var(--accent);
  font-weight: 600;
}

.bottom-nav-item.is-disabled {
  opacity: 0.4;
}
