/* The shared controls of the panel page and the console as design system v3 draws them (owner, 2026-10-23: the whole
   web; canvas "HSK 1–9 và Thi thử", Thành phần; docs/brand/design-system-v3.md). theme.css keeps the overlay's.
   :where() keeps these at a class's weight, so a page's own rule for its button still wins. */

/* Buttons ---------------------------------------------------------------- */

/* Blue, yellow and red stand on a 3 px lip they sink onto when pressed; 44 px tall, 40 in a dense row. */
:where(html[data-theme]) .btn-primary,
:where(html[data-theme]) .btn-outline,
:where(html[data-theme]) .dialog-actions .button {
  height: auto;
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius-md);
  font: var(--type-button);
  white-space: nowrap;
  transition: background-color var(--motion-fast) var(--ease-standard), transform var(--motion-fast) var(--ease-standard),
    box-shadow var(--motion-fast) var(--ease-standard);
}

:where(html[data-theme]) .btn-primary.small {
  min-height: 40px;
  padding: 0 16px;
}

:where(html[data-theme]) .btn-primary,
:where(html[data-theme]) .dialog-actions .button.primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--block-shadow);
}

:where(html[data-theme]) .btn-primary:hover:not(:disabled),
:where(html[data-theme]) .dialog-actions .button.primary:hover {
  background: var(--accent-hover);
}

/* The second action: white with a grey edge and blue words (v3 action.secondary.canvas), on a card or the ground. */
:where(html[data-theme]) .btn-outline,
:where(html[data-theme]) .dialog-actions .button:not(.primary, .danger) {
  background: var(--surface);
  color: var(--accent-soft);
  box-shadow: var(--white-block-shadow);
}

:where(html[data-theme]) .btn-outline:hover:not(:disabled),
:where(html[data-theme]) .dialog-actions .button:not(.primary, .danger):hover {
  background: var(--hover);
}

:where(html[data-theme]) .btn-outline:active:not(:disabled),
:where(html[data-theme]) .dialog-actions .button:not(.primary, .danger):active {
  background: var(--tonal);
}

:where(html[data-theme]) .btn-outline.is-on {
  color: var(--saved);
}

:where(html[data-theme]) .dialog-actions .button.danger {
  background: var(--danger-fill);
  color: var(--on-accent);
  box-shadow: 0 var(--lip-px) 0 var(--danger-lip);
}

:where(html[data-theme]) .btn-primary:active:not(:disabled),
:where(html[data-theme]) .dialog-actions .button.primary:active,
:where(html[data-theme]) .dialog-actions .button.danger:active {
  transform: translateY(var(--lip-px));
  box-shadow: none;
}

/* Switched off: grey 100 with grey 400 words over a grey 200 lip, never faded (v3 Nút, Tắt). */
:where(html[data-theme]) .btn-primary:disabled,
:where(html[data-theme]) .btn-outline:disabled {
  background: var(--fill-disabled);
  color: var(--text-disabled);
  box-shadow: 0 var(--lip-px) 0 var(--lip-disabled);
  opacity: 1;
}

:where(html[data-theme]) .btn-outline:disabled {
  box-shadow: inset 0 0 0 1px var(--lip-disabled);
}

/* Fields ----------------------------------------------------------------- */

/* A grey 500 edge (3:1 on white), 12 px corners; typing draws a 2 px blue edge in a blue 100 halo (v3 Ô nhập). */
:where(html[data-theme]) .select-field,
:where(html[data-theme]) .combo-input,
:where(html[data-theme]) .text-field,
:where(html[data-theme]) .drawer-select-button,
:where(html[data-theme]) .drawer-select-searchbar {
  border: 1px solid var(--field-border);
  border-radius: var(--radius-md);
  background: var(--field-bg);
  font: var(--type-input);
  transition: border-color var(--motion-fast) var(--ease-standard), box-shadow var(--motion-fast) var(--ease-standard);
}

:where(html[data-theme]) .select-field,
:where(html[data-theme]) .combo-input {
  height: 44px;
}

:where(html[data-theme]) .drawer-select-button {
  min-height: 44px;
}

:where(html[data-theme]) .text-field {
  padding: 13px 14px;
}

:where(html[data-theme]) .select-field:focus-visible,
:where(html[data-theme]) .combo-input:focus,
:where(html[data-theme]) .text-field:focus,
:where(html[data-theme]) .drawer-select-button:focus,
:where(html[data-theme]) .drawer-select-searchbar:focus-within {
  border-color: var(--accent);
  outline: none;
  box-shadow: inset 0 0 0 1px var(--accent), var(--field-focus-ring);
}

:where(html[data-theme]) .text-field[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: inset 0 0 0 1px var(--danger);
}

:where(html[data-theme]) .text-field::placeholder {
  color: var(--text-tertiary);
}

/* The label above a field: 13/600 in grey 700, sentence case; the error under it says how to fix it. */
:where(html[data-theme]) .field-label {
  color: var(--text-label);
  font: 600 13px/18px var(--font);
  letter-spacing: 0;
  text-transform: none;
}

:where(html[data-theme]) .field-error {
  font: 600 12px/16px var(--font);
}

:where(html[data-theme]) .combo-list {
  padding: 6px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}

:where(html[data-theme]) .combo-option {
  min-height: 44px;
  border-radius: var(--radius-sm);
}

:where(html[data-theme]) .combo-option[aria-selected="true"] {
  background: var(--selected);
  color: var(--selected-text);
}

/* The bottom sheet's list (v3 Bảng chọn): 20 px corners, 56 px rows, the chosen row blue 50 with a blue check. */
:where(html[data-theme]) .drawer-select-backdrop {
  background: var(--scrim);
}

:where(html[data-theme]) .drawer-select-paper {
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: var(--surface);
  box-shadow: var(--shadow);
}

:where(html[data-theme]) .drawer-select-option {
  min-height: 56px;
  font: var(--type-body);
}

:where(html[data-theme]) .drawer-select-option.is-selected,
:where(html[data-theme]) .drawer-select-option.is-selected:hover {
  background: var(--selected);
  color: var(--selected-text);
}

:where(html[data-theme]) .drawer-select-option > svg {
  color: var(--accent);
}

/* Native ticks and radios take the blue (v3 Chọn lựa). */
:where(html[data-theme]) input[type="checkbox"],
:where(html[data-theme]) input[type="radio"] {
  accent-color: var(--accent);
}

/* The switch: 44 × 26; off, a grey 500 ring round a small grey knob; on, blue with a white knob (v3 Công tắc). */
:where(html[data-theme]) .switch {
  min-height: 44px;
}

:where(html[data-theme]) .switch-track {
  width: 44px;
  height: 26px;
  margin: 0 12px 0 0;
  border-radius: var(--radius-full);
  background: var(--surface);
  box-shadow: inset 0 0 0 1.5px var(--field-border);
  transition: background-color var(--motion-fast) var(--ease-standard);
}

:where(html[data-theme]) .switch-track::after {
  top: 6px;
  left: 6px;
  width: 14px;
  height: 14px;
  background: var(--field-border);
  box-shadow: none;
  transition: transform var(--motion-fast) var(--ease-standard), width var(--motion-fast) var(--ease-standard),
    height var(--motion-fast) var(--ease-standard), top var(--motion-fast) var(--ease-standard),
    left var(--motion-fast) var(--ease-standard);
}

:where(html[data-theme]) .switch-input:checked + .switch-track {
  background: var(--accent);
  box-shadow: none;
}

:where(html[data-theme]) .switch-input:checked + .switch-track::after {
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: var(--on-accent);
  box-shadow: var(--elevation-1);
  transform: translateX(18px);
}

:where(html[data-theme]) .switch-input:disabled + .switch-track {
  background: var(--fill-disabled);
  box-shadow: inset 0 0 0 1.5px var(--lip-disabled);
}

:where(html[data-theme]) .switch-input:focus-visible + .switch-track {
  outline-offset: 2px;
}

/* Pills and titles ------------------------------------------------------- */

:where(html[data-theme]) .pill {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--text-label);
  font: 600 13px/18px var(--font);
}

/* Titles in sentence case: a section's (v3 type.title) and a dialog's. */
:where(html[data-theme]) .section-title {
  margin: 32px 0 16px;
  padding: 0 0 12px;
  border-bottom-color: var(--line);
  font: var(--type-title);
  letter-spacing: 0;
}

:where(html[data-theme]) .dialog-title {
  font: var(--type-title);
}

/* Dialogs, toasts and notices -------------------------------------------- */

/* A dialog: 20 px corners on elevation 3 over a 45 % dim; its buttons, the safe one first, never touch its edge. */
:where(html[data-theme]) .dialog {
  border-radius: var(--radius-xl);
  font: var(--type-body);
}

:where(html[data-theme]) .dialog::backdrop {
  background: var(--scrim);
}

:where(html[data-theme]) .dialog-actions {
  gap: 12px;
  margin-top: 24px;
}

/* A toast at the top: grey 900 in the light look, raised navy in the dark, its action in blue 300 (v3 Mẫu). */
:where(html[data-theme]) .toast {
  min-height: 52px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  font: var(--type-body);
}

:where(html[data-theme="light"]) .toast {
  border-color: transparent;
}

:where(html[data-theme]) .toast-action {
  min-height: 36px;
  border-radius: var(--radius-sm);
  color: var(--wovia-blue-light);
  font: var(--type-button);
}

:where(html[data-theme]) .notice {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}

/* Parts first drawn for Văn bản của bạn (docs/plans/texts-redesign.md) ------- */

/* A page's heading on the light canvas (owner, 2026-10-23: no blue band): its name in grey 900, a caption beside it. */
:where(html[data-theme]) .page-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 12px;
  min-height: 74px;
  padding-top: 6px;
  color: var(--text-strong);
}

:where(html[data-theme]) .page-title {
  margin: 0;
  font: var(--type-display);
  white-space: nowrap;
}

:where(html[data-theme]) .page-caption {
  color: var(--text-muted);
  font: 500 13px/18px var(--font);
}

/* The main card (elevation 2), and an ordinary card on the ground (elevation 1). */
:where(html[data-theme]) .ds-hero {
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--elevation-2);
}

:where(html[data-theme]) .ds-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--elevation-1);
}

:where(html[data-theme]) .ds-section {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

:where(html[data-theme]) .ds-section h2 {
  margin: 0;
  font: var(--type-heading);
  white-space: nowrap;
}

:where(html[data-theme]) .ds-section-sub {
  color: var(--text-muted);
  font: var(--type-caption);
  white-space: nowrap;
}

/* The tonal button (on white only) and the text button; any button 48 px tall or the whole width. */
:where(html[data-theme]) .btn-tonal,
:where(html[data-theme]) .btn-text {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius-md);
  font: var(--type-button);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

:where(html[data-theme]) .btn-tonal {
  background: var(--tonal);
  color: var(--tonal-text);
}

:where(html[data-theme]) .btn-text {
  padding: 0 12px;
  background: transparent;
  color: var(--accent-soft);
}

:where(html[data-theme]) .btn-text.is-danger {
  color: var(--danger);
}

:where(html[data-theme]) :is(.btn-tonal, .btn-text):hover:not(:disabled) {
  background: var(--hover);
}

:where(html[data-theme]) :is(.btn-tonal, .btn-text):disabled {
  color: var(--text-disabled);
  cursor: not-allowed;
}

:where(html[data-theme]) :is(.btn-primary, .btn-outline, .btn-tonal).is-tall {
  min-height: 48px;
}

:where(html[data-theme]) :is(.btn-primary, .btn-outline, .btn-tonal).is-wide {
  width: 100%;
}

:where(html[data-theme]) a:is(.btn-primary, .btn-outline) {
  text-decoration: none;
}

:where(html[data-theme]) .ds-icon-btn {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
}

:where(html[data-theme]) .ds-icon-btn:hover,
:where(html[data-theme]) .ds-icon-btn[aria-expanded="true"] {
  background: var(--tonal);
  color: var(--tonal-text);
}

/* Tiles: a launcher's solid fill, or a state's tint and line (a text new, being read, read). */
:where(html[data-theme]) .ds-tile {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--pill-bg);
  color: var(--text-muted);
}

:where(html[data-theme]) .ds-tile.is-launch {
  width: 48px;
  height: 48px;
  color: var(--on-accent);
}

:where(html[data-theme]) .ds-tile.is-blue {
  background: var(--accent);
}

:where(html[data-theme]) .ds-tile.is-green {
  background: var(--success-fill);
}

:where(html[data-theme]) .ds-tile.is-yellow {
  background: var(--current);
  color: var(--on-current);
}

:where(html[data-theme]) .ds-tile.is-reading {
  background: var(--yellow-tag);
  color: var(--yellow-tag-text);
}

:where(html[data-theme]) .ds-tile.is-read {
  background: var(--success-tint);
  color: var(--success);
}

/* "Đang đọc", the current item: yellow 400 with grey 900 words; a tag: a fact on grey, blue or green. */
:where(html[data-theme]) .ds-kicker {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  background: var(--current);
  color: var(--on-current);
  font: 600 12px/1 var(--font);
  white-space: nowrap;
}

:where(html[data-theme]) .ds-tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  height: 22px;
  padding: 0 7px;
  overflow: hidden;
  border-radius: var(--radius-xs);
  background: var(--pill-bg);
  color: var(--text-label);
  font: 600 12px/1 var(--font);
  white-space: nowrap;
  text-overflow: ellipsis;
}

:where(html[data-theme]) .ds-tag.is-fact {
  background: var(--chip);
  color: var(--chip-text);
}

:where(html[data-theme]) .ds-tag.is-success {
  background: var(--success-tint);
  color: var(--success);
}

:where(html[data-theme]) .ds-bar {
  display: block;
  height: 8px;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: var(--line);
}

:where(html[data-theme]) .ds-bar > i {
  display: block;
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--progress-fill);
}

:where(html[data-theme]) .ds-bar.is-done > i {
  background: var(--success-fill);
}

:where(html[data-theme]) .ds-number {
  font: 800 15px/1 var(--font-number);
}

:where(html[data-theme]) .ds-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* A menu under its button, and on a phone a sheet from the bottom over the dim (popover.js places it). */
:where(html[data-theme]) .ds-menu {
  position: fixed;
  z-index: 1400;
  display: flex;
  flex-direction: column;
  min-width: 212px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

:where(html[data-theme]) .ds-menu:focus {
  outline: 0;
}

:where(html[data-theme]) .ds-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: var(--type-body);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

:where(html[data-theme]) .ds-menu-item:hover,
:where(html[data-theme]) .ds-menu-item:focus-visible {
  background: var(--tonal);
  color: var(--tonal-text);
}

:where(html[data-theme]) .ds-menu-item.is-danger {
  color: var(--danger);
}

:where(html[data-theme]) .ds-menu-sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--line);
}

:where(html[data-theme]) .ds-sheet-head {
  display: none;
}

@media (max-width: 600px) {
  :where(html[data-theme]) .page-title {
    font: 700 20px/28px var(--font);
  }

  :where(html[data-theme]) .page-heading {
    min-height: 60px;
  }

  :where(html[data-theme]) .ds-menu.is-sheet {
    top: auto !important;
    right: 0 !important;
    bottom: 0;
    left: 0 !important;
    padding: 10px 12px 18px;
    border: 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: 0 0 0 100vmax var(--scrim), var(--shadow);
  }

  :where(html[data-theme]) .ds-menu.is-sheet .ds-menu-item {
    min-height: 52px;
    font-size: 15px;
  }

  :where(html[data-theme]) .ds-menu.is-sheet .ds-sheet-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
    padding: 0 12px 12px;
    border-bottom: 1px solid var(--line);
  }
}

:where(html[data-theme]) .ds-skeleton {
  border-radius: var(--radius-xs);
  background: var(--line);
}

/* The mascot: every pose faces right, so one right of the content is mirrored to look into it. */
:where(html[data-theme]) .ds-mascot {
  flex: none;
  width: var(--mascot-px, 88px);
  height: var(--mascot-px, 88px);
  object-fit: contain;
}

:where(html[data-theme]) .ds-mascot.is-mirrored {
  transform: scaleX(-1);
}
