:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --text: #222;
  --muted: #777;
  --line: #e6e0d7;
  --accent: #6f8f72;
  --accent-dark: #58735a;
  --good: #d9f0dc;
  --good-text: #27612e;
  --bad: #ffd9d9;
  --bad-text: #9d1c1c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  width: min(1080px, 94vw);
  margin: 0 auto;
  padding: 24px 0 60px;
}

header { text-align: center; margin-bottom: 20px; }
header h1 { margin: 0; font-size: 30px; }
header p { margin: 6px 0 0; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.04);
}

.config-card { margin-bottom: 16px; }
.compact-card { padding: 14px 18px; }
.compact-card h2 { margin: 0 0 4px; font-size: 18px; }

.tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 16px 0;
}

.tab, button {
  border: 1px solid var(--line);
  background: white;
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 15px;
}

.tab.active,
button.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

button:hover { opacity: 0.9; }
.panel { display: none; }
.panel.active { display: block; }

.row { display: flex; gap: 8px; }

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;
  background: #fff;
}

textarea { resize: vertical; margin-top: 8px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 0.7fr 1.3fr;
  gap: 10px;
  margin-bottom: 12px;
}

.search-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  margin: 12px 0 16px;
}

.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 10px 0;
}

.quiz-options label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.quiz-options select { margin-top: 6px; }

.hint { color: var(--muted); font-size: 14px; }
.status { margin: 4px 0 0; color: var(--accent-dark); }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.section-head h2 { margin: 0; }
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th, td {
  border-bottom: 1px solid var(--line);
  padding: 12px 8px;
  text-align: left;
  vertical-align: top;
}

.quiz-list { display: grid; gap: 10px; }

.quiz-item {
  display: grid;
  grid-template-columns: 1fr 1.3fr 90px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.question {
  font-weight: 700;
  font-size: 18px;
  word-break: break-word;
}

.result {
  text-align: center;
  padding: 10px;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 700;
}

.correct-answer {
  grid-column: 2 / 4;
  color: var(--bad-text);
  font-weight: 700;
  min-height: 1.2em;
}

.quiz-item.correct { background: var(--good); }
.quiz-item.correct .result { color: var(--good-text); }
.quiz-item.wrong { background: var(--bad); }
.quiz-item.wrong .result { color: var(--bad-text); }
.score { font-weight: 700; color: var(--accent-dark); }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.82);
  color: white;
  padding: 10px 16px;
  border-radius: 999px;
  display: none;
  z-index: 100;
}

@media (max-width: 720px) {
  .tabs { grid-template-columns: repeat(2, 1fr); }
  .form-grid,
  .quiz-item,
  .search-grid,
  .quiz-options { grid-template-columns: 1fr; }
  .row,
  .section-head { align-items: stretch; flex-direction: column; }
  .correct-answer { grid-column: 1; }
}
