:root {
  --bg: #f7f7f8; --fg: #1a1a1a; --accent: #2563eb; --error: #dc2626;
  --card-bg: #ffffff; --border: #e2e2e5;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg); color: var(--fg); font-size: 16px; line-height: 1.5;
}
.centered-card {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
}
.card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 32px; width: 100%; max-width: 380px;
}
input[type="email"], input[type="text"], select {
  width: 100%; padding: 12px; font-size: 16px; border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 12px; min-height: 44px; background: var(--card-bg); color: var(--fg);
  -webkit-appearance: none; appearance: none;
}
button {
  width: 100%; padding: 12px; font-size: 16px; border: none; border-radius: 8px;
  background: var(--accent); color: white; cursor: pointer; min-height: 44px; margin-bottom: 12px;
  -webkit-tap-highlight-color: transparent;
}
button:last-child { margin-bottom: 0; }
button:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-inline { width: auto; display: inline-block; padding: 10px 16px; margin-bottom: 0; }
.btn-secondary { background: #6b7280; }
.error-text { color: var(--error); font-size: 14px; margin-top: 8px; min-height: 1em; }
.hidden { display: none !important; }

header.app-header {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--card-bg);
}
header.app-header a { color: var(--accent); text-decoration: none; }
.header-actions {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
}
.lang-toggle {
  display: flex; align-items: center; gap: 8px; font-size: 14px; white-space: nowrap;
}
.lang-toggle select { width: auto; min-height: 36px; padding: 6px 10px; margin-bottom: 0; }

main.app-main { max-width: 720px; margin: 0 auto; padding: 20px 16px 40px; }
.question-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 20px;
  margin-bottom: 16px;
}
.progress-bar { font-size: 14px; color: #555; margin-bottom: 12px; }

.loading-indicator { margin-bottom: 12px; }
.loading-bar {
  height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; position: relative;
}
.loading-bar-fill {
  position: absolute; top: 0; left: -40%; height: 100%; width: 40%;
  background: var(--accent); border-radius: 2px; animation: loading-slide 1.1s ease-in-out infinite;
}
.loading-text { font-size: 13px; color: #555; margin: 6px 0 0; }
@keyframes loading-slide {
  0% { left: -40%; }
  100% { left: 100%; }
}
.explanation-box {
  background: #fff7ed; border: 1px solid #fed7aa; border-radius: 8px; padding: 14px 16px; margin-top: 12px; margin-bottom: 12px;
}
.explanation-box p, .explanation-box > div { margin: 0 0 12px; line-height: 1.5; }
.explanation-box > :last-child { margin-bottom: 0; }
.explanation-box strong { display: block; margin-bottom: 6px; }
.explanation-box ul { margin: 0; padding-left: 20px; }
.explanation-box li { margin-bottom: 4px; line-height: 1.4; }
.explanation-box li:last-child { margin-bottom: 0; }
.answer-with-photo { display: flex; align-items: flex-start; gap: 16px; }
.person-photo { width: 176px; height: 176px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 1px solid var(--border); }
.person-info { min-width: 0; }
.person-name { font-weight: 600; margin: 0 0 6px; }
.person-facts { margin: 0 0 8px; padding-left: 20px; }
.person-bio { margin: 0; font-size: 14px; color: #555; line-height: 1.5; }
@media (max-width: 480px) {
  .answer-with-photo { flex-direction: column; align-items: center; text-align: center; gap: 10px; }
  .person-photo { width: 140px; height: 140px; }
  .person-facts { text-align: left; }
}
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 1000;
}
.modal-box {
  background: var(--card-bg); border-radius: 12px; padding: 24px; max-width: 560px; width: 100%; max-height: 80vh; overflow-y: auto;
}

.table-scroll { width: 100%; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 480px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 14px; }
tr[data-clickable] { cursor: pointer; }
tr[data-clickable]:hover { background: var(--bg); }

.admin-nav {
  display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 24px;
}
.admin-nav a {
  flex: 1 1 140px; text-align: center; background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px 12px; text-decoration: none; color: var(--fg); font-weight: 600;
}
.admin-nav a:hover { background: var(--bg); }

.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px;
}
.stat-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: 16px;
}
.stat-card .stat-value { font-size: 28px; font-weight: 700; }
.stat-card .stat-label { font-size: 13px; color: #555; margin-top: 4px; }

.course-access-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.course-access-card .course-access-name { font-weight: 600; }
.course-access-card button { width: auto; min-height: 36px; padding: 6px 14px; margin-bottom: 0; }
.course-access-card button.revoke { background: var(--error); }

.cheatsheet-category {
  margin: 28px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.cheatsheet-category:first-child { margin-top: 0; }
.cheatsheet-question { margin-bottom: 16px; }
.cheatsheet-question .q-text { font-weight: 600; margin-bottom: 4px; }
.cheatsheet-answers { margin: 0; padding-left: 20px; font-size: 14px; color: #444; }
.cheatsheet-answers li { margin-bottom: 2px; }
.cheatsheet-example { font-size: 13px; color: #555; margin: 4px 0 0; }

.course-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px;
}
.course-card {
  display: block; text-align: left; background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; text-decoration: none; color: var(--fg); cursor: pointer;
}
.course-card:hover { background: var(--bg); }
.course-card h3 { margin: 0 0 8px; }
.course-card .badge-coming-soon {
  display: inline-block; margin-top: 10px; background: #f59e0b; color: white;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}

ul#history-list { list-style: none; padding: 0; margin: 0; }
ul#history-list li {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; margin-bottom: 8px; font-size: 14px;
}
.history-title { font-weight: 600; }
.history-detail { font-size: 13px; color: #555; margin-top: 4px; }

.app-footer {
  text-align: center; padding: 20px 12px; font-size: 12px; color: #555;
}
.app-footer a { color: var(--accent); text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }

@media (max-width: 480px) {
  .card { padding: 24px 20px; }
  .question-card { padding: 16px; }
  main.app-main { padding: 16px 12px 32px; }
}
