:root {
  --bg: linear-gradient(180deg, #f7fbff 0%, #eef5eb 100%);
  --card: #ffffff;
  --text: #1f2a33;
  --muted: #5b6b7a;
  --primary: #0e7c86;
  --primary-hover: #0a666f;
  --warn: #cf5f2f;
  --border: #d8e3e6;
  --shadow: 0 8px 24px rgba(18, 45, 64, 0.08);
}

body.theme-dark {
  --bg: linear-gradient(180deg, #0f1720 0%, #111a24 100%);
  --card: #182330;
  --text: #e7eff7;
  --muted: #a2b6c8;
  --primary: #58b7c3;
  --primary-hover: #6bc8d2;
  --warn: #d17b52;
  --border: #314354;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans TC", "PingFang TC", "Avenir Next", sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 1rem;
}

.hero {
  text-align: center;
  padding: 1rem 0 0.5rem;
}

.hero h1 {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: 0.04em;
}

.hero p {
  color: var(--muted);
  margin: 0.5rem 0 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 14px;
  padding: 1rem;
  margin: 1rem 0;
}

.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.tab-btn {
  width: auto;
  min-width: 110px;
  background: #e8eff1;
  color: #21424a;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
}

.tab-panel {
  margin-top: 0.25rem;
}

.grid-2 {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, 1fr);
}

.panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem;
}

.panel h3 {
  margin: 0 0 0.5rem;
}

label {
  display: block;
  font-size: 0.95rem;
  margin: 0.6rem 0;
}

input,
select,
button {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 0.6rem 0.7rem;
  font-size: 1rem;
}

button {
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  border: none;
  font-weight: 600;
}

button:hover {
  background: var(--primary-hover);
}

button.ghost {
  background: #f2f7f8;
  color: #21424a;
}

body.theme-dark button.ghost {
  background: #253546;
  color: #d7e6f4;
}

button.warning {
  background: var(--warn);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
}

.toolbar button {
  width: auto;
}

.stats {
  margin: 0.6rem 0;
  color: var(--muted);
}

.app-toolbar {
  margin-top: 1rem;
}

.hero-stats {
  text-align: center;
  margin: 0.35rem 0 0.8rem;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.inline-actions button {
  width: auto;
  min-width: 110px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
}

.inline-check input {
  width: auto;
}

.form-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.quiz-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.prompt-title {
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.question {
  font-size: 1.8rem;
  margin: 0;
  word-break: break-word;
}

.review-answer {
  font-size: 1.3rem;
  margin: 0;
  color: #24424d;
  word-break: break-word;
}

.paper-box {
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: #f7fbfc;
  padding: 1rem;
  margin: 0.5rem 0;
  color: var(--muted);
}

body.theme-dark .paper-box {
  background: #1c2a38;
}

.answer-box {
  border-left: 4px solid var(--primary);
  background: #eef9fa;
  padding: 0.7rem;
  margin: 0.5rem 0;
  font-size: 2rem;
  line-height: 1.4;
}

body.theme-dark .answer-box {
  background: #223243;
}

#stroke-viewer {
  margin: 0.65rem 0;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fcfd;
}

body.theme-dark #stroke-viewer {
  background: #1c2a38;
}

.stroke-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.55rem;
}

.stroke-size-control {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
}

.stroke-size-control input {
  width: 170px;
}

#stroke-size-value {
  color: var(--muted);
  min-width: 52px;
}

.stroke-char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.55rem;
}

.stroke-char-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem;
  background: var(--card);
}

.stroke-char-target {
  margin: 0 auto;
  width: fit-content;
}

.stroke-char-label {
  text-align: center;
  font-size: 1.2rem;
  margin-top: 0.3rem;
}

.feedback {
  min-height: 1.2em;
  font-weight: 600;
  color: #1d5f4a;
}

.table-wrap {
  overflow-x: auto;
}

#results-table {
  width: 100%;
  border-collapse: collapse;
}

#results-table th,
#results-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.55rem;
  text-align: left;
  vertical-align: top;
  font-size: 0.95rem;
}

#manage-table {
  width: 100%;
  border-collapse: collapse;
}

#manage-table th,
#manage-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.45rem;
  text-align: left;
  vertical-align: top;
  font-size: 0.9rem;
}

#manage-table input,
#manage-table select {
  font-size: 0.9rem;
  padding: 0.45rem 0.55rem;
}

.table-actions {
  display: flex;
  gap: 0.4rem;
}

.table-actions button {
  min-width: 74px;
  width: auto;
}

#progress-records-table {
  width: 100%;
  border-collapse: collapse;
}

#progress-records-table th,
#progress-records-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.5rem;
  text-align: left;
  vertical-align: top;
  font-size: 0.92rem;
}

.progress-lists {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.progress-list-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem;
  background: #fbfefe;
}

body.theme-dark .progress-list-box {
  background: #1d2a37;
}

.progress-list-box h4 {
  margin: 0 0 0.4rem;
}

.word-list {
  max-height: 280px;
  overflow: auto;
  font-size: 0.92rem;
  line-height: 1.45;
}

.word-list-item {
  padding: 0.18rem 0;
  border-bottom: 1px dashed #e6eeef;
}

.progress-word-item {
  cursor: pointer;
  border-radius: 8px;
  padding: 0.25rem 0.35rem;
}

.progress-word-item:hover {
  background: #f1f8f9;
}

body.theme-dark .progress-word-item:hover {
  background: #2a3a4b;
}

.progress-word-item.selected {
  background: #d9eef2;
  border-bottom-color: #c2dfe5;
}

body.theme-dark .progress-word-item.selected {
  background: #345064;
  border-bottom-color: #43627b;
}

.word-category-group + .word-category-group {
  margin-top: 0.75rem;
}

.word-category-title {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  color: #2b5460;
}

.progress-list-actions {
  margin-top: 0.6rem;
}

.progress-list-actions button {
  min-width: 128px;
  width: auto;
}

.muted {
  color: var(--muted);
}

.global-message {
  color: #9c3f1a;
  font-weight: 600;
  min-height: 1.2em;
}

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .grid-2,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .progress-lists {
    grid-template-columns: 1fr;
  }

  .question {
    font-size: 1.5rem;
  }

  .stroke-size-control input {
    width: 130px;
  }
}
