:root {
  color-scheme: light;
  --bg: #f8f6f1;
  --surface: #ffffff;
  --surface-2: #f2eee6;
  --ink: #1f2725;
  --muted: #6c746f;
  --line: #ded7ca;
  --accent: #1f7a68;
  --accent-dark: #123f38;
  --accent-soft: #dceee9;
  --gold: #e7a72f;
  --danger: #b44747;
  --shadow: 0 10px 26px rgba(36, 31, 23, 0.07);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow: hidden;
  overscroll-behavior: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  max-width: 820px;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  min-height: 100svh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--bg);
  overscroll-behavior: none;
  touch-action: manipulation;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 20px 14px;
  background: var(--accent-dark);
  color: #fff;
  text-align: center;
}

.app-header h1,
.page-title h2,
.section-title h3 {
  margin: 0;
}

.app-header h1 {
  font-size: 25px;
  line-height: 1.18;
}

.eyebrow {
  margin: 0 0 5px;
  color: inherit;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  opacity: 0.65;
  text-transform: uppercase;
}

.header-meta {
  margin: 7px 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
}

.icon-button,
.play-button,
.primary-button,
.ghost-button,
.small-button,
.collection-form button,
.import-button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  font-weight: 800;
}

.icon-button {
  width: 44px;
  flex: 0 0 44px;
  color: #fff;
  background: #289681;
  font-size: 28px;
  line-height: 1;
}

.current-meta,
.hint,
.page-title span,
.vocab-meaning {
  color: var(--muted);
  font-size: 13px;
}

.play-button {
  min-width: 116px;
  padding: 0 20px;
  color: #173a36;
  background: var(--gold);
}

.play-button.compact {
  min-width: 82px;
}

.tab-page {
  display: none;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 18px 18px 104px;
}

.tab-page.active {
  display: block;
}

.page-title,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.page-title h2 {
  font-size: 25px;
  line-height: 1.15;
}

.composer,
.section-block,
.player-panel,
.account-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.translate-toolbar,
.toggle-row,
.transport,
.backup-actions,
.rename-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.translate-toolbar {
  display: grid;
  gap: 10px;
}

.translate-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

.translate-button {
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-weight: 800;
}

.translate-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.toggle-row {
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.hint {
  margin: 10px 0 14px;
}

.field-block {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  outline: 0;
}

input,
select {
  min-height: 44px;
  padding: 0 13px;
}

textarea {
  display: block;
  resize: vertical;
  min-height: 130px;
  padding: 13px;
  line-height: 1.55;
}

.primary-button {
  width: 100%;
  margin-top: 14px;
  color: #fff;
  background: var(--accent);
}

.ghost-button,
.import-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.import-button input {
  display: none;
}

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

.collection-form button {
  color: #fff;
  background: var(--accent);
}

.collection-category-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  width: min(100%, 620px);
  margin: 0 auto;
  padding-top: clamp(20px, 6vh, 58px);
}

.collection-category-card {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 18px;
  min-width: 0;
  min-height: 142px;
  padding: 24px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  transition: transform 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.collection-category-card.sentence {
  border-left: 5px solid var(--gold);
}

.collection-category-card:not(.sentence) {
  border-left: 5px solid var(--accent);
}

.collection-category-card:active {
  transform: translateY(1px);
  background: var(--surface-2);
}

.collection-category-card:focus-visible {
  outline: 3px solid rgba(31, 122, 104, 0.24);
  outline-offset: 2px;
}

.collection-category-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 68px;
  border-radius: 8px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 16px;
  font-weight: 900;
}

.collection-category-card.sentence .collection-category-icon {
  color: #68470d;
  background: #fff1ce;
  font-size: 28px;
}

.collection-category-copy {
  display: grid;
  gap: 9px;
  min-width: 0;
}

.collection-category-name {
  font-size: 23px;
  font-weight: 850;
}

.collection-category-count {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.collection-category-arrow {
  color: var(--muted);
  font-size: 32px;
  line-height: 1;
  text-align: right;
}

.collection-category-title,
.collection-detail-title,
.collection-search-title {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
}

.collection-category-title > div,
.collection-detail-title > div,
.collection-search-title > div {
  min-width: 0;
  text-align: center;
}

.collection-category-title h2,
.collection-detail-title h2,
.collection-search-title h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collection-back {
  min-width: 68px;
}

.collection-order-status {
  margin: 0 0 10px;
}

.play-card {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--accent-dark);
}

.collection-category-play-card {
  margin-bottom: 12px;
}

.play-card #playbackStatus {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.play-actions {
  display: grid;
  grid-template-columns: 1fr 86px;
  gap: 10px;
}

.play-actions .ghost-button {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.12);
}

.collection-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.collection-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 66px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.collection-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.collection-reorder-actions {
  display: flex;
  gap: 6px;
}

.collection-reorder-actions .small-button,
.collection-more {
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.collection-item-actions .collection-play {
  min-width: 52px;
  min-height: 42px;
  padding: 0 10px;
}

.collection-item-actions .collection-more {
  min-height: 42px;
}

.collection-item-actions button:disabled {
  cursor: default;
  opacity: 0.38;
}

.collection-select {
  display: grid;
  gap: 6px;
  min-width: 0;
  flex: 1;
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.collection-item.active {
  border-color: #f3c55b;
  background: #f9d477;
}

.collection-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 850;
}

.collection-count {
  color: inherit;
  font-size: 13px;
  opacity: 0.72;
}

.section-block {
  margin-top: 14px;
}

.collection-edit-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.collection-edit-grid .rename-group {
  margin-bottom: 0;
}

.collection-type-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.collection-detail-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.collection-detail-actions button {
  min-width: 0;
}

.collection-empty p {
  margin: 0 0 14px;
}

.collection-empty .primary-button {
  max-width: 220px;
  margin: 0 auto;
}

.rename-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 0;
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.rename-group input {
  min-width: 0;
  border: 0;
  border-radius: 0;
}

.rename-group button {
  min-width: 92px;
  min-height: 44px;
  padding: 0 12px;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface-2);
}

.rename-group button:not(:disabled) {
  color: #fff;
  background: var(--accent);
}

.rename-group button:disabled {
  cursor: default;
  opacity: 0.52;
}

.rename-collection-status {
  min-height: 18px;
  margin: -6px 0 0;
}

.collection-search-panel {
  display: grid;
  gap: 10px;
}

.collection-search-panel input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  font-size: 16px;
}

.collection-search-status {
  min-height: 18px;
  margin: 0;
}

.collection-search-results {
  display: grid;
  gap: 10px;
}

.collection-search-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  padding: 13px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.collection-search-result-copy {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.collection-search-result-text {
  overflow-wrap: anywhere;
  font-size: 17px;
  font-weight: 850;
}

.collection-search-result-meaning {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.collection-search-result-collection {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.collection-search-result-arrow {
  color: var(--muted);
  font-size: 28px;
  line-height: 1;
  text-align: right;
}

.page-title-spacer {
  display: block;
  width: 68px;
}

.batch-page-title {
  align-items: flex-start;
}

.batch-page-title strong {
  color: var(--accent-dark);
}

.batch-import-editor {
  display: grid;
  gap: 12px;
}

.batch-format-hint {
  margin: 0;
}

.batch-import-editor textarea {
  width: 100%;
  min-height: 300px;
  resize: vertical;
  line-height: 1.5;
}

.batch-import-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.batch-import-actions button {
  min-width: 0;
}

.batch-import-preview,
.batch-import-result {
  display: grid;
  gap: 14px;
}

.batch-preview-summary {
  padding: 12px;
  border-radius: 8px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-weight: 800;
  line-height: 1.55;
  white-space: pre-line;
}

.batch-preview-list {
  display: grid;
  gap: 8px;
  max-height: min(54dvh, 620px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.batch-preview-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.batch-preview-item p {
  margin: 0;
  overflow-wrap: anywhere;
}

.batch-preview-english {
  font-weight: 850;
}

.batch-preview-status {
  font-size: 13px;
  font-weight: 800;
}

.batch-preview-status.ready {
  color: var(--accent-dark);
}

.batch-preview-status.warning,
.batch-preview-status.error {
  color: var(--danger);
}

.batch-preview-cleanup {
  color: #8a5a00;
  font-size: 12px;
  font-weight: 800;
}

.batch-import-result h3,
.batch-import-result p {
  margin: 0;
}

.batch-import-result p {
  color: var(--muted);
  font-weight: 750;
  line-height: 1.6;
}

.batch-result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.batch-result-stat {
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: center;
}

.batch-result-stats span,
.batch-result-stats strong {
  display: block;
}

.batch-result-stats span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.batch-result-stats strong {
  margin-top: 3px;
  font-size: 22px;
}

.batch-result-stats .success strong {
  color: var(--accent-dark);
}

.batch-result-stats .failed strong {
  color: var(--danger);
}

.batch-result-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.batch-failure-panel {
  display: grid;
  gap: 10px;
  padding-top: 2px;
}

.batch-failure-panel h4 {
  margin: 0;
  font-size: 16px;
}

.batch-failure-panel textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  line-height: 1.5;
}

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

.vocab-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.vocab-item.search-target-highlight {
  border-color: var(--gold);
  background: #fff3c9;
  box-shadow: 0 0 0 3px rgba(243, 197, 91, 0.22);
}

.vocab-text {
  margin: 0;
  font-size: 17px;
  font-weight: 850;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.vocab-meaning {
  margin: 7px 0 0;
  color: var(--accent-dark);
  font-weight: 800;
  line-height: 1.45;
}

.item-actions {
  display: grid;
  gap: 8px;
  align-content: start;
}

.small-button {
  min-height: 34px;
  padding: 0 12px;
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.small-button.delete {
  color: var(--danger);
  background: #f4e0df;
}

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

.empty-state {
  padding: 34px 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  text-align: center;
}

.player-panel {
  display: grid;
  gap: 18px;
}

.transport {
  justify-content: center;
}

.transport .play-button {
  flex: 1;
  max-width: 220px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.settings-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.setting-static {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
  font-weight: 800;
}

.setting-static strong {
  color: var(--ink);
  font-size: 14px;
}

.settings-grid input[type="range"] {
  accent-color: var(--accent);
}

.settings-grid .toggle-row {
  grid-template-columns: auto 1fr;
  align-content: center;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.account-panel {
  display: grid;
  gap: 12px;
}

.account-status {
  padding: 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--accent-dark);
  font-weight: 850;
  overflow-wrap: anywhere;
}

.account-fields {
  display: grid;
  gap: 10px;
}

.account-view {
  display: grid;
  gap: 12px;
}

.account-view[hidden] {
  display: none;
}

.account-primary {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 850;
}

.text-button {
  min-height: 36px;
  padding: 0;
  border: 0;
  color: var(--accent-dark);
  background: transparent;
  font-weight: 800;
  text-align: left;
}

.text-button:hover {
  color: var(--accent);
  text-decoration: underline;
}

.account-register-action {
  display: grid;
  gap: 4px;
}

.account-register-action .text-button {
  justify-self: end;
}

.account-signed-in {
  padding: 4px 0 0;
}

.logout-button {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-dark);
  background: #fff;
  font-weight: 850;
}

.logout-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.account-dialog {
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 20px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 18px 60px rgba(17, 42, 38, 0.25);
}

.account-dialog[open] {
  display: grid;
  gap: 16px;
}

.account-dialog::backdrop {
  background: rgba(22, 36, 33, 0.42);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-header h3 {
  margin: 0;
  font-size: 20px;
}

.dialog-close {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 26px;
  line-height: 1;
  place-items: center;
}

.dialog-notice {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-weight: 750;
  line-height: 1.45;
}

.dialog-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.dialog-actions .ghost-button {
  padding: 0 18px;
}

.code-row {
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 10px;
}

.password-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 66px;
  gap: 8px;
}

.password-row input {
  min-width: 0;
}

.password-toggle {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-dark);
  background: #fff;
  font-weight: 800;
}

.export-dialog textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  line-height: 1.55;
}

.edit-item-dialog .account-fields {
  display: grid;
  gap: 14px;
}

.edit-item-dialog textarea {
  width: 100%;
  min-height: 16px;
  resize: vertical;
  line-height: 1.5;
}

.full-width {
  width: 100%;
}

.settings-actions {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.settings-actions .hint {
  text-align: center;
}

.manual-sync-manager {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.manual-sync-heading h2,
.manual-sync-heading p,
.sync-choice p,
.manual-sync-status {
  margin: 0;
}

.manual-sync-heading h2 {
  margin-top: 3px;
  font-size: 20px;
}

.sync-choice {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sync-choice strong {
  font-size: 15px;
}

.sync-choice p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.sync-choice .primary-button {
  width: auto;
  min-width: 170px;
  margin: 0;
  padding: 0 14px;
}

.sync-choice .ghost-button {
  min-width: 108px;
}

.overwrite-choice {
  border-color: #d8b86d;
  background: #fffaf0;
}

.manual-sync-status {
  min-height: 20px;
  line-height: 1.55;
}

.manual-sync-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.manual-sync-stats div {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.manual-sync-stats span,
.manual-sync-stats strong {
  display: block;
}

.manual-sync-stats span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.manual-sync-stats strong {
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.manual-sync-stats .danger-stat {
  border-color: #d9a3a0;
  color: var(--danger);
  background: #fff5f4;
}

.manual-sync-warning {
  margin: 0;
  padding: 11px;
  border: 1px solid #d9a3a0;
  border-radius: 8px;
  color: var(--danger);
  background: #fff5f4;
  font-weight: 800;
  line-height: 1.5;
}

.duplicate-manager {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.duplicate-manager-heading,
.duplicate-section-title,
.duplicate-toolbar,
.duplicate-selection-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.duplicate-manager-heading,
.duplicate-section-title,
.duplicate-toolbar {
  justify-content: space-between;
}

.duplicate-manager-heading h2,
.duplicate-section-title h3,
.section-kicker {
  margin: 0;
}

.duplicate-manager-heading h2 {
  margin-top: 3px;
  font-size: 20px;
}

.section-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.duplicate-manager-heading .primary-button,
.duplicate-toolbar .primary-button {
  width: auto;
  min-width: 136px;
  margin-top: 0;
  padding: 0 14px;
}

.duplicate-manager-status {
  margin-bottom: 0;
  line-height: 1.5;
}

.duplicate-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.duplicate-stats div {
  min-width: 0;
  padding: 12px 8px;
  background: #fff;
  text-align: center;
}

.duplicate-stats strong,
.duplicate-stats span {
  display: block;
}

.duplicate-stats strong {
  font-size: 22px;
}

.duplicate-stats span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.duplicate-toolbar {
  margin-top: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.duplicate-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.duplicate-section {
  margin-top: 18px;
}

.duplicate-section[hidden],
.duplicate-manager-results[hidden],
.duplicate-merge-result[hidden] {
  display: none;
}

.duplicate-section-title {
  margin-bottom: 10px;
}

.duplicate-section-title h3 {
  font-size: 16px;
}

.duplicate-section-title span {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.duplicate-group-list {
  display: grid;
  gap: 8px;
}

.duplicate-group {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.duplicate-group.actionable {
  border-left: 4px solid var(--gold);
}

.duplicate-group.shared {
  border-left: 4px solid var(--accent);
}

.duplicate-group summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
}

.duplicate-group summary::-webkit-details-marker {
  display: none;
}

.duplicate-group summary::after {
  content: "+";
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
}

.duplicate-group[open] summary::after {
  content: "−";
}

.duplicate-group-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 850;
}

.duplicate-group-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.duplicate-group-body {
  padding: 0 12px 12px;
  border-top: 1px solid var(--line);
}

.duplicate-group-reason,
.duplicate-merge-preview {
  margin: 10px 0;
  font-size: 13px;
  line-height: 1.5;
}

.duplicate-group-reason {
  color: var(--danger);
  font-weight: 800;
}

.duplicate-record-list {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.duplicate-record {
  display: grid;
  grid-template-columns: minmax(90px, 0.8fr) minmax(100px, 1fr) minmax(120px, 1.5fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: #fff;
  font-size: 13px;
}

.duplicate-record.keep {
  background: #f4fbf7;
}

.duplicate-record.delete {
  background: #fff8f7;
}

.duplicate-record span,
.duplicate-record p {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.duplicate-record p {
  color: var(--muted);
}

.duplicate-record-decision {
  justify-self: end;
  padding: 4px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.duplicate-record-decision.keep {
  color: #17613d;
  background: #dcefe5;
}

.duplicate-record-decision.delete {
  color: #9b2c27;
  background: #f7deda;
}

.duplicate-merge-preview {
  margin-bottom: 0;
  padding: 10px;
  border-radius: 8px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-weight: 750;
  overflow-wrap: anywhere;
}

.duplicate-empty,
.duplicate-merge-result {
  margin: 0;
  padding: 14px;
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-2);
  text-align: center;
}

.duplicate-merge-result {
  margin-top: 14px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-weight: 750;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.duplicate-merge-result p {
  margin: 0;
}

.duplicate-result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.danger-notice {
  border-color: #efbbb4;
  color: #8b2520;
  background: #fff2f0;
}

.duplicate-confirm-message {
  margin: 0;
  font-weight: 800;
  line-height: 1.55;
}

.duplicate-manager button:disabled,
.duplicate-confirm-dialog button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.backup-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mini-player {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(66px + env(safe-area-inset-bottom));
  z-index: 18;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  min-height: 58px;
  overflow: hidden;
  border: 1px solid #c9ded8;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(24, 62, 54, 0.16);
}

.mini-player-open,
.mini-player-toggle {
  min-width: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
}

.mini-player-open {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 8px 9px 14px;
  text-align: left;
}

.mini-player-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.mini-player-copy strong,
.mini-player-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-player-copy strong {
  font-size: 15px;
}

.mini-player-copy span {
  color: var(--muted);
  font-size: 12px;
}

.mini-player-arrow {
  color: var(--muted);
  font-size: 25px;
  line-height: 1;
}

.mini-player-toggle {
  border-left: 1px solid var(--line);
  color: var(--accent-dark);
  font-size: 20px;
  font-weight: 900;
}

.mini-player-toggle:disabled {
  cursor: wait;
  color: var(--muted);
}

.app-shell.has-mini-player .tab-page {
  padding-bottom: 174px;
}

.learning-player {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--bg);
}

.learning-player-header {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: max(10px, env(safe-area-inset-top)) 14px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  text-align: center;
  font-size: 15px;
  font-weight: 850;
}

.player-icon-button,
.player-skip-button,
.player-main-button {
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--accent-dark);
  background: transparent;
  line-height: 1;
}

.player-icon-button {
  width: 44px;
  height: 44px;
  font-size: 30px;
}

.learning-player-main {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.player-session {
  display: grid;
  align-content: start;
  min-height: 100%;
  padding: 14px 22px 24px;
  text-align: center;
}

.player-context {
  display: flex;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  overflow-wrap: anywhere;
}

.player-source,
.player-collection,
.player-session-meta p,
.player-study-content p {
  margin: 0;
}

.player-source {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.player-source::after {
  margin-left: 6px;
  content: "·";
}

.player-collection {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.player-study-content {
  display: grid;
  align-content: start;
  gap: 18px;
  min-height: min(42vh, 360px);
  padding: 48px 0 14px;
}

.player-study-content h2 {
  margin: 0;
  color: var(--ink);
  font-size: 52px;
  line-height: 1.18;
  overflow-wrap: anywhere;
  word-break: normal;
}

.player-study-content h2.long-text {
  font-size: 40px;
}

.player-study-content h2.very-long-text {
  font-size: 32px;
  line-height: 1.3;
}

.player-phonetic {
  color: var(--accent);
  font-size: 22px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.player-meaning {
  color: #46504c;
  font-size: 28px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: normal;
}

.player-session-meta {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

#playerProgress {
  color: var(--ink);
  font-size: 17px;
  font-weight: 850;
}

#playerStateText {
  min-height: 20px;
}

.player-empty {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 14px;
  min-height: 100%;
  padding: 32px 24px;
  text-align: center;
}

.player-empty h2,
.player-empty p {
  margin: 0;
}

.player-empty h2 {
  font-size: 24px;
}

.player-empty p {
  max-width: 330px;
  color: var(--muted);
  line-height: 1.6;
}

.player-empty-actions {
  display: flex;
  width: min(100%, 320px);
  justify-content: center;
  gap: 10px;
}

.player-empty-actions button {
  flex: 1;
}

.learning-player-controls {
  display: grid;
  grid-template-columns: 64px 78px 64px;
  justify-content: center;
  align-items: center;
  gap: clamp(20px, 10vw, 46px);
  min-height: 118px;
  padding: 16px 20px max(20px, calc(14px + env(safe-area-inset-bottom)));
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.player-skip-button {
  width: 60px;
  height: 60px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 38px;
}

.player-main-button {
  width: 76px;
  height: 76px;
  color: #fff;
  background: var(--accent-dark);
  font-size: 25px;
  box-shadow: 0 8px 18px rgba(18, 63, 56, 0.2);
}

.player-skip-button:disabled,
.player-main-button:disabled {
  cursor: default;
  opacity: 0.35;
}

.player-menu-dialog {
  width: min(390px, calc(100% - 28px));
}

.bottom-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  padding: 7px 10px max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.bottom-nav button {
  display: grid;
  justify-items: center;
  gap: 3px;
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 850;
}

.bottom-nav button span {
  font-size: 20px;
  line-height: 1;
}

.bottom-nav button.active {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.admin-body {
  min-height: 100vh;
  overflow: auto;
  background: var(--bg);
}

.admin-shell {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding: 20px;
  border-radius: 8px;
  color: #fff;
  background: var(--accent-dark);
}

.admin-header p,
.admin-header h1 {
  margin: 0;
}

.admin-header p {
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
  font-weight: 800;
}

.admin-header h1 {
  margin-top: 4px;
  font-size: 26px;
}

.admin-header a {
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

.admin-login,
.admin-stats,
.admin-table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.admin-login {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 12px;
  padding: 18px;
}

.admin-login button {
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 850;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  overflow: hidden;
}

.admin-stats article {
  padding: 20px;
  background: #fff;
}

.admin-stats span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.admin-stats strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.admin-table-wrap {
  margin-top: 16px;
  overflow-x: auto;
}

.admin-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.admin-table-wrap th,
.admin-table-wrap td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.admin-table-wrap th {
  color: var(--muted);
  font-size: 13px;
}

@media (min-width: 760px) {
  .app-shell {
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }

  .tab-page {
    padding-left: 26px;
    padding-right: 26px;
  }
}

@media (max-width: 430px) {
  .app-header {
    padding: 18px 16px 15px;
  }

  .app-header h1 {
    font-size: 23px;
  }

  .tab-page {
    padding: 18px 14px 94px;
  }

  .app-shell.has-mini-player .tab-page {
    padding-bottom: 170px;
  }

  .player-session {
    padding-top: 10px;
    padding-right: 18px;
    padding-left: 18px;
  }

  .player-study-content h2 {
    font-size: 46px;
  }

  .player-study-content {
    padding-top: 42px;
  }

  .player-study-content h2.long-text {
    font-size: 36px;
  }

  .player-study-content h2.very-long-text {
    font-size: 28px;
  }

  .player-meaning {
    font-size: 25px;
  }

  .player-phonetic {
    font-size: 20px;
  }

  .learning-player-controls {
    gap: 24px;
  }

  .settings-grid,
  .collection-list {
    grid-template-columns: 1fr;
  }

  .collection-category-grid {
    gap: 12px;
    padding-top: 20px;
  }

  .collection-category-card {
    grid-template-columns: 58px minmax(0, 1fr) 24px;
    gap: 14px;
    min-height: 126px;
    padding: 18px 16px;
  }

  .collection-category-icon {
    width: 58px;
    height: 58px;
  }

  .collection-category-name {
    font-size: 21px;
  }

  .collection-category-title,
  .collection-detail-title,
  .collection-search-title {
    gap: 8px;
  }

  .collection-category-title h2,
  .collection-detail-title h2,
  .collection-search-title h2 {
    font-size: 20px;
  }

  .collection-category-title .ghost-button,
  .collection-detail-title .ghost-button,
  .collection-search-title .ghost-button {
    min-width: 0;
    padding: 0 10px;
  }

  .page-title-spacer {
    width: 52px;
  }

  .collection-item {
    gap: 6px;
    padding: 10px;
  }

  .collection-item-actions,
  .collection-reorder-actions {
    gap: 4px;
  }

  .collection-item-actions .collection-play {
    min-width: 48px;
    padding: 0 8px;
  }

  .collection-reorder-actions .small-button,
  .collection-more {
    width: 40px;
    min-width: 40px;
  }

  .collection-detail-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .vocab-item {
    grid-template-columns: 1fr;
  }

  .item-actions {
    grid-template-columns: 1fr 1fr;
  }

  .rename-group button {
    min-width: 0;
  }

  .collection-edit-grid .rename-group {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .collection-edit-grid .rename-group button {
    width: auto;
  }

  .sync-choice {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .sync-choice .primary-button,
  .sync-choice .ghost-button {
    width: 100%;
  }

  .batch-import-actions {
    grid-template-columns: 1fr 1fr;
  }

  .batch-import-actions .primary-button {
    grid-column: 1 / -1;
  }

  .batch-result-actions .primary-button,
  .batch-failure-panel .primary-button {
    grid-column: auto;
  }

  .duplicate-manager-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .duplicate-manager-heading .primary-button {
    width: 100%;
  }

  .duplicate-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .duplicate-stats div:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .duplicate-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .duplicate-toolbar .primary-button {
    width: 100%;
  }

  .duplicate-section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .duplicate-section-title span {
    text-align: left;
  }

  .duplicate-group summary {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .duplicate-group-name {
    grid-column: 1;
    grid-row: 1;
  }

  .duplicate-group-count {
    grid-column: 1;
    grid-row: 2;
  }

  .duplicate-group summary::after {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .duplicate-record {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .duplicate-record-decision {
    justify-self: start;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  .learning-player-header {
    min-height: 54px;
  }

  .player-session {
    align-content: start;
    padding-top: 18px;
  }

  .player-study-content {
    min-height: 190px;
    padding: 16px 0;
  }

  .learning-player-controls {
    min-height: 90px;
    padding-top: 8px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .player-main-button {
    width: 64px;
    height: 64px;
  }

  .player-skip-button {
    width: 52px;
    height: 52px;
  }
}
