:root {
  color-scheme: light;
  --fg: #1a1a1a;
  --bg: #fdfdfb;
  --muted: #6b6b6b;
  --accent: #2b6cb0;
  --green: #2f855a;
  --yellow: #b7791f;
  --red: #c53030;
  --border: #e2e2e2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, "PingFang TC", "Noto Sans TC", sans-serif;
  font-size: 17px;
  line-height: 1.7;
}

.topbar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  text-decoration: none;
  color: var(--fg);
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

h1 { font-size: 1.8rem; }
h2 { font-size: 1.3rem; margin-top: 2em; border-bottom: 1px solid var(--border); padding-bottom: 4px; }

.ipa { font-size: 1rem; color: var(--muted); font-weight: normal; }

.core-image {
  font-size: 1.15rem;
  font-weight: 600;
  padding: 12px;
  background: #f4f4f0;
  border-radius: 8px;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 17px;
}

th, td {
  border: 1px solid var(--border);
  padding: 8px;
  text-align: left;
  vertical-align: top;
  font-size: 17px;
}

.ex-zh { color: var(--muted); font-size: 17px; }

/* ready/pending 除顏色外另靠底線樣式區分，不只靠色彩辨識狀態 */
.wl-ready { color: var(--green); text-decoration: underline solid; text-underline-offset: 2px; }
.wl-pending { color: var(--muted); text-decoration: underline dashed; text-underline-offset: 2px; }

.lookup-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lookup-form textarea {
  min-height: 3em;
  font-size: 1rem;
  padding: 8px;
}

.lookup-form input, .lookup-form button {
  font-size: 1rem;
  padding: 8px;
}

.feedback-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.feedback-buttons button { padding: 10px 14px; font-size: 1rem; }

.learner-current { color: var(--muted); font-weight: 600; }
#feedback-status { color: var(--green); min-height: 1.4em; }

#play-audio {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 1.2rem;
  vertical-align: middle;
  border-radius: 8px;
}

.error { color: var(--red); }

.back { margin-top: 2em; }

.morpheme-overview .morpheme-cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.morpheme-col h3 { margin-bottom: 6px; }
.morpheme-col ul { list-style: none; padding: 0; margin: 0; }
.morpheme-col li { padding: 4px 0; border-bottom: 1px solid var(--border); font-size: 17px; }
.morpheme-col li.empty { color: var(--muted); border-bottom: none; }

@media (max-width: 480px) {
  .morpheme-overview .morpheme-cols {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #eaeaea;
    --bg: #16171a;
    --muted: #9a9a9a;
    --border: #333;
  }
  .core-image { background: #202226; }
}

/* 真人怎麼講：YouGlish widget + PlayPhrase 電影片段 */
.clips { margin: 2em 0; }
.youglish-mount { margin-bottom: 1.5em; }
.youglish-accent-switch { display: flex; gap: 8px; margin-bottom: 8px; }
.youglish-accent-switch button {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--fg);
  font-size: 14px;
  cursor: pointer;
}
.youglish-accent-switch button.active { background: #337ab7; color: #fff; border-color: #337ab7; }
.youglish-frame { width: 100%; min-height: 120px; }

.clip-loading, .clip-empty { color: var(--muted); }
.clip-empty a { font-weight: 600; }

.clip-list { display: flex; flex-direction: column; gap: 16px; }
.clip-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.clip-item video { width: 100%; max-width: 100%; border-radius: 6px; background: #000; }
.clip-text { margin: 10px 0 4px; font-size: 17px; line-height: 1.6; }
.clip-text mark { background: #ffe08a; color: inherit; padding: 0 2px; border-radius: 3px; }
.clip-movie { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.clip-feedback { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.clip-feedback button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--fg);
  font-size: 14px;
  cursor: pointer;
}
.clip-feedback button:disabled { opacity: 0.5; cursor: default; }
.clip-feedback-status { font-size: 13px; color: var(--muted); }

@media (prefers-color-scheme: dark) {
  .clip-text mark { background: #7a5c00; color: #fff; }
}

/* 手機：多義表與連帶組合表改逐列卡片，避免橫向溢出 */
@media (max-width: 480px) {
  .senses table,
  .senses thead,
  .senses tbody,
  .senses th,
  .senses td,
  .senses tr,
  .family table,
  .family thead,
  .family tbody,
  .family th,
  .family td,
  .family tr {
    display: block;
    width: 100%;
  }
  .senses thead,
  .family thead { position: absolute; left: -9999px; top: -9999px; }
  .senses tbody tr,
  .family tbody tr {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 12px;
  }
  .senses tbody td,
  .family tbody td {
    border: none;
    padding: 6px 0;
  }
  .senses tbody td::before,
  .family tbody td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 2px;
  }
}

/* 一眼結論／故事：加小標題方便掃讀定位 */
.section-label {
  margin: 1.6em 0 0.4em;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* 首頁字根總覽：預設只露前 8 筆，其餘用「展開全部」開 */
.morpheme-col li.morpheme-extra { display: none; }
.morpheme-col.expanded li.morpheme-extra { display: list-item; }
.morpheme-more {
  margin-top: 6px;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--fg);
  font-size: 15px;
  cursor: pointer;
}

/* 回饋三鍵：手指點得到（≥44px）＋選中態明顯 */
.feedback-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.feedback-buttons button,
#wrong-submit {
  min-height: 44px;
  padding: 10px 16px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
}
.feedback-buttons button[aria-pressed="true"] {
  background: #337ab7;
  border-color: #337ab7;
  color: #fff;
  font-weight: 700;
}
.clip-feedback button { min-height: 44px; padding: 10px 16px; font-size: 15px; }
.clip-feedback button[aria-pressed="true"] {
  background: #337ab7;
  border-color: #337ab7;
  color: #fff;
  font-weight: 700;
  opacity: 1;
}
