:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-subtle: #f8fafd;
  --surface-hover: #eef2fa;
  --text: #17213a;
  --text-secondary: #4a5772;
  --text-muted: #66748f;
  --border: #e1e7f0;
  --border-strong: #c9d4e5;
  --primary: #304cca;
  --primary-hover: #253da9;
  --primary-soft: #eef1fd;
  --primary-soft-border: #ccd5f7;
  --success: #157f4b;
  --success-soft: #eaf8f0;
  --success-border: #b4e4c9;
  --danger: #c62828;
  --danger-soft: #fdeeee;
  --danger-border: #f5c2c2;
  --warning: #9a5b00;
  --warning-soft: #fff6e5;
  --warning-border: #f3d69b;
  --sidebar-width: 232px;
  --topbar: 56px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(23, 33, 58, 0.05);
  --shadow-md: 0 6px 20px rgba(23, 33, 58, 0.08);
  --shadow-lg: 0 14px 36px rgba(23, 33, 58, 0.14);
  --font-sans: "Inter", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Code", "Consolas", "Noto Sans Mono CJK JP", monospace;
  --font-math: "Cambria Math", "STIX Two Math", "Latin Modern Math", "Times New Roman", "Noto Sans JP", serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

body.drawer-open,
body.modal-open {
  overflow: hidden;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Skip Link */
.skip-link {
  position: fixed;
  top: -100px;
  left: 12px;
  z-index: 2000;
  padding: 10px 16px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 12px;
  text-decoration: none;
}

/* Canvas Mask Icons */
.ui-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  background-color: currentColor;
  -webkit-mask-image: var(--icon-image);
  mask-image: var(--icon-image);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.ui-icon-sm {
  width: 15px;
  height: 15px;
}

.ui-icon-lg {
  width: 22px;
  height: 22px;
}

/* Shell Layout */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 900;
}

.sidebar-header {
  height: var(--topbar);
  padding: 0 14px 0 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.brand-link:hover {
  text-decoration: none;
  color: var(--primary);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-close-btn {
  display: none;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px 20px;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.nav-link:hover {
  background: var(--surface-hover);
  color: var(--text);
  text-decoration: none;
}

.nav-link[aria-current="page"] {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.nav-link-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.nav-link[aria-current="page"] .nav-count {
  color: var(--primary);
}

.nav-section-label {
  margin: 16px 10px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-other-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.nav-other-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

.nav-other-toggle:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-chevron {
  transition: transform 0.15s ease;
}

.nav-other-toggle[aria-expanded="true"] .nav-chevron {
  transform: rotate(180deg);
}

.nav-other-panel {
  margin-top: 4px;
}

.storage-notice {
  margin: 10px 10px 0;
  padding: 8px 10px;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text-muted);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.storage-notice.is-warning {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: var(--warning-border);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 850;
}

/* Main Column */
.app-body {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Sticky Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 700;
  height: var(--topbar);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

.menu-toggle-btn,
.sidebar-close-btn {
  display: none;
}

/* Global Search */
.global-search {
  position: relative;
  flex: 1;
  max-width: 460px;
  min-width: 0;
}

.search-form {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 11px;
  color: var(--text-muted);
  pointer-events: none;
}

.global-search-input {
  width: 100%;
  height: 36px;
  padding: 0 64px 0 36px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--text);
  transition: border-color 0.12s ease, background-color 0.12s ease, box-shadow 0.12s ease;
}

.global-search-input:focus {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(48, 76, 202, 0.12);
  outline: none;
}

.search-kbd {
  position: absolute;
  right: 8px;
  padding: 2px 6px;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  pointer-events: none;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 800;
  max-height: 360px;
  overflow-y: auto;
}

.search-option {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.search-option:hover,
.search-option[aria-selected="true"] {
  background: var(--primary-soft);
}

.search-option-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.search-option-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
}

.search-option-cat {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.search-option-def {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-option-footer {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 8px;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 600;
}

.search-empty-item {
  padding: 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Progress Pill & Language Toggle */
.progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  border: 1px solid var(--primary-soft-border);
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.progress-pill:hover {
  background: #e1e7fc;
  text-decoration: none;
}

.lang-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 8px 0 9px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.lang-picker:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
}

.lang-picker:focus-within {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.lang-picker-icon {
  width: 16px;
  height: 16px;
}

.lang-picker-chevron {
  width: 12px;
  height: 12px;
  opacity: 0.7;
}

.lang-picker-short {
  display: none;
}

.lang-picker-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: 0;
  font-size: 16px; /* avoid iOS zoom on focus */
}

/* Main Content */
.main-content {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 24px 48px;
  min-width: 0;
}

.main-content:focus {
  outline: none;
}

.app-loading {
  padding: 48px 16px;
  text-align: center;
  color: var(--text-muted);
}

/* Page Header */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 20px;
}

.page-title {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--text);
}

.page-subtitle {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.page-header-compact {
  align-items: center;
  margin-bottom: 14px;
}

.page-header-text {
  min-width: 0;
}

.page-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.label-short {
  display: none;
}

.btn-lg {
  height: 46px;
  padding: 0 18px;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
}

.btn.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.btn:not(.btn-primary) .btn-count {
  background: var(--surface-hover);
  color: var(--text-secondary);
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin: 24px 0 14px;
}

.section-header:first-child {
  margin-top: 0;
}

.section-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text);
}

.section-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.86rem;
  font-weight: 600;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 0.8rem;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #ffffff;
}

.btn-soft {
  background: var(--primary-soft);
  border-color: var(--primary-soft-border);
  color: var(--primary);
}

.btn-soft:hover:not(:disabled) {
  background: #e1e7fc;
  border-color: #b7c4f5;
}

.btn-success-soft {
  background: var(--success-soft);
  border-color: var(--success-border);
  color: var(--success);
}

.btn-danger-soft {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: var(--danger);
}

/* Cards & Grids */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.featured-exam-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.domain-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  color: inherit;
  transition: border-color 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease;
}

.domain-card:hover {
  border-color: var(--primary-soft-border);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
}

.domain-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.domain-icon-wrap {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.domain-card-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}

.domain-card-desc {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Badges / Chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-standard {
  background: #edf2ff;
  color: #2b44b5;
  border: 1px solid #d4dffa;
}

.badge-advanced {
  background: #f4eefc;
  color: #5b31a8;
  border: 1px solid #dfd2f7;
}

.badge-neutral {
  background: var(--surface-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

/* Filter Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.field-input,
.field-select {
  height: 36px;
  padding: 0 12px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  color: var(--text);
  min-width: 0;
}

.field-input:focus,
.field-select:focus {
  background: var(--surface);
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(48, 76, 202, 0.12);
}

.toolbar-search {
  flex: 1 1 220px;
}

.toolbar-select {
  flex: 0 1 230px;
  max-width: 100%;
}

.toolbar-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.toolbar-check:has(input:checked) {
  background: var(--primary-soft);
  border-color: var(--primary-soft-border);
  color: var(--primary);
}

.catalog-toolbar .toolbar-main,
.catalog-toolbar .toolbar-more {
  display: contents;
}

.toolbar-filter-toggle {
  display: none;
}

.toolbar-filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}

.toolbar-filter-toggle[aria-expanded="true"] {
  background: var(--primary-soft);
  border-color: var(--primary-soft-border);
  color: var(--primary);
}

/* Exams Page */
.exam-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.exam-group-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.exam-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.12s ease, opacity 0.12s ease, box-shadow 0.12s ease;
}

.exam-group.is-dragging {
  opacity: 0.55;
  box-shadow: var(--shadow-lg);
}

.exam-group.drop-before {
  box-shadow: 0 -3px 0 0 var(--primary), var(--shadow-sm);
}

.exam-group.drop-after {
  box-shadow: 0 3px 0 0 var(--primary), var(--shadow-sm);
}

.exam-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  cursor: grab;
  user-select: none;
}

.exam-group-header:active {
  cursor: grabbing;
}

.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: grab;
  touch-action: none;
  flex-shrink: 0;
}

.drag-handle:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.exam-group-toggle {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.exam-group-toggle:hover {
  background: var(--surface-subtle);
}

.exam-group-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}

.exam-group-chevron {
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.exam-group.is-collapsed .exam-group-chevron {
  transform: rotate(-90deg);
}

.exam-group-body {
  padding: 0 14px 16px;
  border-top: 1px solid var(--border);
}

.exam-group-notice {
  margin: 12px 0 0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--warning-soft);
  border: 1px solid var(--warning-border);
  color: var(--warning);
  font-size: 0.81rem;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.exam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.exam-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.exam-card:hover {
  border-color: var(--primary-soft-border);
  background: var(--surface);
}

.exam-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.exam-card-title-link {
  font-weight: 700;
  font-size: 0.94rem;
  line-height: 1.4;
  color: var(--text);
}

.exam-card-title-link:hover {
  color: var(--primary);
}

.exam-card-desc {
  margin: 0;
  font-size: 0.81rem;
  color: var(--text-secondary);
  line-height: 1.5;
  flex: 1;
}

.exam-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

.exam-official-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.exam-official-link:hover {
  color: var(--primary);
}

.hidden-groups-box {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.hidden-groups-summary {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-secondary);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hidden-groups-summary::-webkit-details-marker {
  display: none;
}

.hidden-groups-list {
  padding: 0 16px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.hidden-group-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
}

/* Catalog List & Bulk Actions */
.list-meta-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.list-select-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.bulk-bar {
  position: sticky;
  top: calc(var(--topbar) + 6px);
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--primary-soft);
  border: 1px solid var(--primary-soft-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.bulk-bar-count {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--primary);
  margin-right: 4px;
}

.term-list {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.term-row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.1s ease;
}

.term-row:last-child {
  border-bottom: 0;
}

.term-row:hover {
  background: var(--surface-subtle);
}

.term-row-check {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
  cursor: pointer;
}

.term-row-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.term-row-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.term-row-title-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.term-row-link {
  font-weight: 700;
  font-size: 0.94rem;
  color: var(--text);
}

.term-row-link:hover {
  color: var(--primary);
}

.term-row-alt {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.term-row-def {
  margin: 0;
  font-size: 0.83rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.term-row-indicators {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}

.term-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.bookmark-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}

.bookmark-btn:hover {
  background: var(--surface-hover);
  color: var(--primary);
}

.bookmark-btn[aria-pressed="true"] {
  background: var(--primary-soft);
  border-color: var(--primary-soft-border);
  color: var(--primary);
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.pagination-info {
  font-size: 0.84rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* Term Detail */
.term-detail-wrap {
  max-width: 900px;
  margin: 0 auto;
}

.term-nav-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.breadcrumbs a {
  color: var(--text-secondary);
  font-weight: 500;
}

.breadcrumbs a:hover {
  color: var(--primary);
}

.term-pager {
  display: flex;
  align-items: center;
  gap: 8px;
}

.term-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}

.term-card.slide-next {
  animation: slideFromRight 0.18s ease-out;
}

.term-card.slide-prev {
  animation: slideFromLeft 0.18s ease-out;
}

@keyframes slideFromRight {
  from { opacity: 0.5; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideFromLeft {
  from { opacity: 0.5; transform: translateX(-18px); }
  to { opacity: 1; transform: translateX(0); }
}

.term-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.term-meta-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.term-title {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.term-alternate {
  margin: 4px 0 0;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.term-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.notice-banner {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  font-size: 0.84rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.notice-banner.is-info {
  background: var(--primary-soft);
  border-color: var(--primary-soft-border);
  color: var(--primary);
}

.notice-banner.is-warning {
  background: var(--warning-soft);
  border-color: var(--warning-border);
  color: var(--warning);
}

.term-section {
  margin-top: 22px;
}

.term-section-title {
  margin: 0 0 8px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.term-body-text {
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.75;
  color: var(--text);
}

/* Diagrams */
.diagram-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  overflow: hidden;
}

.diagram-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.diagram-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text);
}

.diagram-scroll {
  overflow-x: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

.diagram-svg {
  display: block;
  margin: 0 auto;
  max-width: none;
}

.diagram-mermaid-details {
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.diagram-mermaid-summary {
  padding: 9px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

.diagram-mermaid-body {
  padding: 0 14px 14px;
}

.diagram-mermaid-pre {
  margin: 0 0 8px;
  padding: 10px 12px;
  background: #141c2f;
  color: #e6edf8;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.55;
  overflow-x: auto;
}

/* Code Example Block */
.code-example-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}

.code-example-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
}

.code-lang-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary);
}

.code-example-pre {
  margin: 0;
  padding: 14px;
  background: #141c2f;
  color: #edf2fc;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.code-example-note {
  margin: 0;
  padding: 10px 14px;
  font-size: 0.84rem;
  color: var(--text-secondary);
  background: var(--surface-subtle);
  border-top: 1px solid var(--border);
}

/* References & Related */
.ref-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ref-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.86rem;
  font-weight: 500;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.related-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  color: inherit;
}

.related-card:hover {
  border-color: var(--primary-soft-border);
  background: var(--surface);
  text-decoration: none;
}

.related-card-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text);
}

.related-card-def {
  font-size: 0.78rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.term-footer-cta {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Study View (max-width 860px centered) */
.study-wrap {
  max-width: 860px;
  margin: 0 auto;
}

/* Study setup screen */
.study-setup-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.study-controls {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 10px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.control-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
}

.study-controls .field-select {
  width: 100%;
  height: 40px;
}

.study-progress-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.study-progress-meta {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.study-progress-pct {
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-hover);
  overflow: hidden;
}

.progress-fill {
  display: block;
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.25s ease;
}

.study-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.study-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  min-width: 0;
}

.study-stat dt {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.study-stat dd {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.study-stat.is-review dd {
  color: var(--danger);
}

.study-stat.is-passed dd {
  color: var(--success);
}

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

.study-start-btn {
  width: 100%;
  min-width: 0;
}

.study-start-btn > span:not(.ui-icon):not(.btn-count) {
  overflow: hidden;
  text-overflow: ellipsis;
}

.study-start-btn:hover {
  text-decoration: none;
}

.study-learned-link {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 600;
}

.study-learned-panel {
  margin-bottom: 16px;
}

/* Study session: question-only focus mode */
body.is-study-focus .sidebar,
body.is-study-focus .sidebar-backdrop,
body.is-study-focus .topbar,
body.is-study-focus .skip-link {
  display: none !important;
}

body.is-study-focus {
  min-height: 0;
}

body.is-study-focus .app-body {
  margin-left: 0;
  min-height: 0;
}

body.is-study-focus .main-content {
  max-width: none;
  padding: 0;
}

.study-session {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 860px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: 16px 20px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.study-session-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  min-width: 0;
}

.study-exit-btn:hover {
  text-decoration: none;
}

.study-session-title {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}

.study-session-scope {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.study-session-meta {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.study-session-remaining {
  flex-shrink: 0;
}

.study-session-progress {
  flex-shrink: 0;
  height: 4px;
}

.study-inline-notice {
  margin: 0 0 10px;
  padding: 6px 10px;
  font-size: 0.78rem;
}

.study-session > .study-inline-notice {
  margin: 0;
  flex-shrink: 0;
}

/* Study Card: sized to its content, capped by the viewport; scrolls internally */
.study-card {
  display: flex;
  flex-direction: column;
  flex: 0 1 auto;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.study-card-empty .empty-state {
  border: 0;
}

.empty-state-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.study-card-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 22px 16px;
  overscroll-behavior: contain;
}

.study-question-prompt {
  margin: 0 0 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.study-type-badge {
  margin-right: 8px;
  vertical-align: 1px;
}

.study-question-main .study-type-badge {
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.4;
  vertical-align: 2px;
}

.study-question-main {
  margin: 0 0 14px;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}

.study-question-main.is-long {
  font-size: 1.02rem;
  line-height: 1.6;
}

.study-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.study-choice-btn {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  text-align: left;
  font-size: 0.9rem;
  line-height: 1.55;
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.study-choice-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.study-choice-btn:disabled {
  cursor: default;
}

.study-choice-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
  margin-top: 0;
}

.study-choice-text {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.study-choice-btn.is-correct {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--text);
}

.study-choice-btn.is-correct .study-choice-index {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.study-choice-btn.is-wrong {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--text);
}

.study-choice-btn.is-wrong .study-choice-index {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.study-formula {
  font-family: var(--font-math);
  font-size: 1rem;
  line-height: 1.65;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.study-feedback {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  line-height: 1.65;
}

.study-feedback.is-correct {
  background: var(--success-soft);
  border-color: var(--success-border);
}

.study-feedback.is-wrong {
  background: var(--danger-soft);
  border-color: var(--danger-border);
}

.study-feedback-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  margin-bottom: 6px;
}

.study-feedback.is-correct .study-feedback-title {
  color: var(--success);
}

.study-feedback.is-wrong .study-feedback-title {
  color: var(--danger);
}

.study-card-footer {
  flex-shrink: 0;
  min-height: 56px;
  padding: 9px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.study-footer-hint {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 14px;
  width: 100%;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Inline Expanded Term Detail Below Study Card */
.study-expanded-detail {
  margin-top: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

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

.study-expanded-title {
  margin: 0;
  font-size: 1.1rem;
}

/* Completed Scenarios List */
.scenario-completed-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scenario-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.scenario-item-summary {
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.scenario-item-body {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
  font-size: 0.86rem;
}

/* Empty & Error States */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.empty-state-title {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 700;
}

.empty-state-desc {
  margin: 0 0 16px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

/* Toast Notification */
.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 36px);
  pointer-events: none;
}

.toast {
  padding: 10px 14px;
  background: #17213a;
  color: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.84rem;
  font-weight: 500;
  pointer-events: auto;
}

/* Sidebar Review Badge & Accent Count Badges */
.nav-count-review {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  font-size: 0.72rem;
  font-weight: 700;
}

.count-badge.is-accent {
  background: var(--primary-soft);
  border-color: var(--primary-soft-border);
  color: var(--primary);
}

.exam-card-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  flex-shrink: 0;
}

/* Home Study-First Focus Bar */
.home-focus-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 14px 18px;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.home-focus-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.home-action-btn {
  max-width: 100%;
  min-width: 0;
}

.home-action-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 340px;
}

/* Home Exam Group Tab Strip */
.home-group-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

.home-group-tab {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.home-group-tab:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
}

.home-group-tab.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

/* Home Scenario Exam Cards */
.sf-exam-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.sf-exam-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease;
}

.sf-exam-card:hover {
  border-color: var(--primary-soft-border);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.sf-exam-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.sf-exam-title {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text);
}

.sf-exam-title:hover {
  color: var(--primary);
  text-decoration: none;
}

.sf-exam-progress {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sf-exam-progress .progress-track {
  flex: 1;
  height: 5px;
}

.sf-exam-progress-text {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sf-exam-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 2px;
}

/* Home Compact IT図鑑 Domain Index */
.catalog-chip-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.catalog-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  transition: border-color 0.12s ease, background-color 0.12s ease, transform 0.12s ease;
}

.catalog-chip:hover {
  border-color: var(--primary-soft-border);
  background: var(--primary-soft);
  text-decoration: none;
  transform: translateY(-1px);
}

.catalog-chip-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.catalog-chip-name {
  flex: 1;
  min-width: 0;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.catalog-chip-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* Study Setup: Segmented Question Type Pills & Reset Controls */
.study-controls-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.study-controls-stack .field-select {
  width: 100%;
  height: 40px;
}

.study-type-pills {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.study-type-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.study-type-pill:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
}

.study-type-pill.is-active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.study-type-pill.is-empty:not(.is-active) {
  opacity: 0.65;
}

.study-type-pill-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.study-type-pill.is-active .study-type-pill-count {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.study-setup-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.study-reset-trigger {
  color: var(--text-secondary);
}

.study-reset-confirm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.study-reset-confirm-text {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--danger);
}

/* Study Session Enhancements: Domain Badge, Quick Bookmark, Dont-Know Reveal */
.study-bookmark-btn.is-active {
  background: var(--primary-soft);
  border-color: var(--primary-soft-border);
  color: var(--primary);
}

.study-question-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.study-question-tags .study-type-badge {
  margin-right: 0;
}

.badge-domain {
  background: var(--surface-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}

.study-domain-badge {
  margin-right: 6px;
}

.study-dontknow-btn {
  color: var(--text-secondary);
}

.study-feedback.is-skipped {
  background: var(--warning-soft);
  border-color: var(--warning-border);
}

.study-feedback.is-skipped .study-feedback-title {
  color: var(--warning);
}

.study-feedback-answer {
  margin: 0 0 6px;
}

.study-feedback-body {
  margin: 0;
}

.inline-code {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(23, 33, 58, 0.07);
  font-family: var(--font-mono);
  font-size: 0.88em;
  font-weight: 500;
  word-break: break-word;
}

/* Responsive <= 900px: Off-canvas Sidebar */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    visibility: hidden;
    pointer-events: none;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.is-open {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
    transition: transform 0.2s ease;
  }

  .sidebar-close-btn {
    display: inline-flex;
  }

  .app-body {
    margin-left: 0;
  }

  .menu-toggle-btn {
    display: inline-flex;
  }

  .featured-exam-grid,
  .sf-exam-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .main-content {
    padding: 18px 16px 40px;
  }
}

/* Responsive <= 620px: Mobile Layout */
@media (max-width: 620px) {
  :root {
    --topbar: 54px;
  }

  .topbar {
    padding: 0 10px;
    gap: 6px;
  }

  .search-kbd {
    display: none;
  }

  .global-search-input {
    padding-right: 10px;
    font-size: 0.82rem;
  }

  .progress-pill {
    padding: 0 8px;
    font-size: 0.76rem;
    gap: 4px;
  }

  .lang-picker {
    height: 34px;
    padding: 0 6px 0 7px;
    gap: 3px;
  }

  .lang-picker-label {
    display: none;
  }

  .lang-picker-short {
    display: inline;
    font-size: 0.74rem;
  }

  .main-content {
    padding: 12px 12px 36px;
  }

  .page-title {
    font-size: 1.28rem;
  }

  /* Compact page header: title + one-line subtitle, actions on the right */
  .page-header-compact {
    flex-wrap: nowrap;
    gap: 10px;
    margin-bottom: 10px;
  }

  .page-header-compact .page-header-text {
    flex: 1;
  }

  .page-header-compact .page-title {
    font-size: 1.15rem;
    line-height: 1.3;
  }

  .page-header-compact .page-subtitle {
    margin-top: 2px;
    font-size: 0.76rem;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .page-header-actions {
    flex-wrap: nowrap;
    flex-shrink: 0;
    gap: 6px;
  }

  .page-header-actions .btn {
    height: 34px;
    padding: 0 11px;
    font-size: 0.8rem;
  }

  .page-header-actions .btn-icon-mobile {
    width: 34px;
    padding: 0;
  }

  .label-full {
    display: none;
  }

  .label-short {
    display: inline;
  }

  /* Catalog toolbar: search + filter toggle in one row, the rest collapsible */
  .toolbar {
    padding: 8px;
    gap: 8px;
    margin-bottom: 10px;
    border-radius: var(--radius-md);
  }

  .catalog-toolbar .toolbar-main {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
  }

  .catalog-toolbar .toolbar-main .toolbar-search {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
  }

  .toolbar-filter-toggle {
    display: inline-flex;
    flex-shrink: 0;
    padding: 0 10px;
  }

  .catalog-toolbar .toolbar-more {
    display: none;
  }

  .catalog-toolbar.is-expanded .toolbar-more {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }

  .catalog-toolbar .toolbar-more #cat-level {
    flex: 1 1 100%;
  }

  .catalog-toolbar .toolbar-check {
    flex: 1 1 0;
    justify-content: center;
    height: 34px;
  }

  .list-meta-bar {
    gap: 6px 10px;
    margin-bottom: 8px;
    font-size: 0.78rem;
  }

  .bulk-bar {
    padding: 8px 10px;
    gap: 6px;
    margin-bottom: 10px;
  }

  .featured-exam-grid,
  .exam-grid {
    grid-template-columns: 1fr;
  }

  .category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .domain-card {
    padding: 12px;
    gap: 8px;
  }

  .domain-card-title {
    font-size: 0.88rem;
  }

  .domain-card-desc {
    font-size: 0.76rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .term-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px 10px;
  }

  .term-row-icon {
    display: none;
  }

  .term-card {
    padding: 16px 14px;
  }

  .term-title {
    font-size: 1.3rem;
  }

  /* Study setup */
  .study-setup-card {
    gap: 12px;
    padding: 12px;
    margin-bottom: 12px;
  }

  .study-controls {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .study-stat {
    padding: 8px 10px;
  }

  .study-stat dd {
    font-size: 1.1rem;
  }

  .study-start-actions {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  /* Study session: fill the screen so every choice is visible without page scrolling */
  .study-session {
    gap: 8px;
    padding: 8px 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .study-session .study-card {
    flex: 1 1 auto;
  }

  .study-exit-btn,
  .study-bookmark-btn {
    width: 34px;
    height: 34px;
  }

  .study-session-scope {
    font-size: 0.88rem;
  }

  .study-session-meta {
    font-size: 0.7rem;
  }

  .study-card-scroll {
    padding: 12px 12px 10px;
  }

  .study-question-prompt {
    margin-bottom: 4px;
    font-size: 0.76rem;
    line-height: 1.55;
  }

  .study-question-tags {
    margin-bottom: 6px;
  }

  .study-type-badge {
    margin-right: 6px;
  }

  .study-card-footer.is-idle {
    min-height: 44px;
    padding: 6px 12px;
    justify-content: flex-end;
  }

  .study-question-main {
    margin-bottom: 10px;
    font-size: 1.08rem;
    line-height: 1.45;
  }

  .study-question-main.is-long {
    font-size: 0.9rem;
    line-height: 1.55;
  }

  .study-choices {
    gap: 6px;
  }

  .study-choice-btn {
    gap: 8px;
    padding: 8px 10px;
    font-size: 0.84rem;
    line-height: 1.5;
  }

  .study-choice-index {
    width: 22px;
    height: 22px;
    font-size: 0.74rem;
  }

  .study-formula {
    font-size: 0.92rem;
  }

  .study-feedback {
    margin-top: 10px;
    padding: 10px 12px;
    font-size: 0.84rem;
    line-height: 1.6;
  }

  .study-card-footer {
    min-height: 52px;
    padding: 8px 12px;
  }

  .study-card-footer .btn-primary {
    flex: 1 1 auto;
  }

  .study-footer-keys {
    display: none;
  }

  .study-expanded-detail {
    padding: 12px;
  }

  .home-focus-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .home-focus-actions {
    width: 100%;
  }

  .home-action-btn {
    flex: 1 1 auto;
  }

  .home-group-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .home-group-tabs::-webkit-scrollbar {
    display: none;
  }

  .sf-exam-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .catalog-chip-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .study-type-pills {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .study-type-pill {
    padding: 8px 6px;
    font-size: 0.78rem;
    flex-direction: column;
    gap: 2px;
  }

  .study-setup-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .exam-toolbar-actions {
    margin-left: 0;
    width: 100%;
  }

  .exam-group-header {
    padding: 10px;
  }

  .toolbar-search,
  .toolbar-select,
  .field-select,
  .field-input {
    width: 100%;
    max-width: 100%;
    flex: 1 1 100%;
  }

  .study-controls .field-select {
    width: 100%;
    max-width: 100%;
    height: 40px;
    flex: 0 0 auto;
  }

  .term-row-actions {
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
  }
}

@media (max-width: 420px) {
  .topbar {
    padding: 0 8px;
    gap: 5px;
  }

  .topbar-left,
  .topbar-right {
    gap: 5px;
  }

  .icon-btn {
    width: 32px;
    height: 32px;
  }

  .global-search-input {
    height: 32px;
    padding-left: 30px;
    padding-right: 6px;
    font-size: 0.78rem;
  }

  .search-icon {
    left: 8px;
    width: 15px;
    height: 15px;
  }

  .progress-pill {
    height: 30px;
    padding: 0 7px;
    font-size: 0.7rem;
  }

  .progress-icon {
    display: none;
  }

  .lang-picker {
    height: 30px;
    padding: 0 5px;
  }

  .lang-picker-icon {
    width: 14px;
    height: 14px;
  }

  .lang-picker-chevron {
    display: none;
  }
}

@media (hover: none) {
  .study-footer-keys {
    display: none;
  }
}

/* Sidebar Footer: Ad-free settings entry */
.sidebar-footer {
  flex-shrink: 0;
  padding: 10px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.sidebar-adfree-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.sidebar-adfree-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
}

.sidebar-adfree-btn.is-ad-free {
  background: var(--success-soft);
  border-color: var(--success-border);
  color: var(--success);
}

.sidebar-adfree-btn.is-ad-free:hover {
  background: #dcf4e6;
}

.sidebar-adfree-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-adfree-pill {
  flex-shrink: 0;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--success);
  color: #ffffff;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.5;
}

/* Header ad button (opens the center-screen HisatorNotebook ad) */
.ad-header-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 9px 0 4px;
  border-radius: 999px;
  border: 1.5px solid #0e1f3d;
  background-color: #12264a;
  background-image: linear-gradient(135deg, #0e1f3d 0%, #1b3a6b 100%);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.ad-header-btn:hover {
  filter: brightness(1.15);
}

.ad-header-logo {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 1.5px rgba(214, 170, 92, 0.9);
}

.ad-header-tag {
  padding: 1px 5px;
  border-radius: 4px;
  background-color: rgba(255, 255, 255, 0.18);
  color: #f1ddb0;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

@media (max-width: 1080px) {
  .ad-header-name {
    display: none;
  }

  .ad-header-btn {
    padding: 0 7px 0 4px;
    gap: 5px;
  }
}

@media (max-width: 480px) {
  .ad-header-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    justify-content: center;
  }

  .ad-header-tag {
    display: none;
  }
}

/* Modals / Dialogs */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1600;
  background-color: rgba(15, 23, 42, 0.56);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-panel {
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
  display: flex;
  flex-direction: column;
  background-color: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.26);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background-color: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
}

.modal-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--text);
}

.modal-title:focus {
  outline: none;
}

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background-color: var(--surface);
  color: var(--text);
  flex-shrink: 0;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.modal-close:hover {
  background-color: var(--text);
  border-color: var(--text);
  color: #ffffff;
}

.modal-close .ui-icon {
  width: 16px;
  height: 16px;
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* 30-minute ad — centered interstitial (aligned with Trivia) */
.ad-overlay {
  z-index: 1620;
  align-items: center;
  justify-content: center;
  background-color: rgba(15, 23, 42, 0.66);
}

.ad-modal-panel {
  max-width: 460px;
  border: 2px solid #0e1f3d;
  animation: ad-pop-in 0.22s ease-out;
}

@keyframes ad-pop-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.ad-hero {
  padding: 14px 18px 18px;
  color: #ffffff;
  background-color: #12264a;
  background-image: radial-gradient(circle at 92% -10%, rgba(214, 170, 92, 0.22) 0 20%, transparent 21%),
    linear-gradient(135deg, #0e1f3d 0%, #1b3a6b 100%);
  border-bottom: 1.5px solid #0e1f3d;
}

.ad-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ad-label {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background-color: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.ad-close {
  border-color: rgba(255, 255, 255, 0.32);
  background-color: rgba(255, 255, 255, 0.92);
  color: #12264a;
}

.ad-close:hover {
  background-color: #ffffff;
  border-color: #ffffff;
  color: #0e1f3d;
}

.ad-hero-brand {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.ad-hero-logo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(214, 170, 92, 0.85), 0 6px 18px rgba(0, 0, 0, 0.35);
}

.ad-promo-eyebrow {
  display: block;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #e3c27e;
}

.ad-hero-name {
  margin: 0;
  font-size: 1.22rem;
  font-weight: 900;
  line-height: 1.2;
  color: #ffffff;
}

#dialog-ad-popup .ad-promo-title {
  margin: 12px 0 0;
  font-size: 1.16rem;
  font-weight: 900;
  line-height: 1.4;
  color: #ffffff;
  /* Wrap only between phrases (spaces, or the zero-width space in the CJK headlines), never
     inside a word like 「ワークスペース」; overflow-wrap is the fallback on very narrow screens */
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.ad-body {
  padding: 18px;
}

.ad-promo-desc {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.65;
}

.ad-features {
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ad-features li {
  padding: 4px 11px;
  border-radius: 999px;
  background-color: #eef2f8;
  border: 1px solid #c9d4e6;
  font-size: 0.78rem;
  font-weight: 800;
  color: #12264a;
}

.ad-promo-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ad-promo-actions .btn {
  width: 100%;
  height: auto;
  min-height: 40px;
  padding: 9px 14px;
  white-space: normal;
  text-decoration: none;
  text-align: center;
  line-height: 1.4;
}

.ad-btn-primary {
  background-color: #12264a;
  border-color: #0e1f3d;
  color: #ffffff;
}

.ad-btn-primary:hover:not(:disabled) {
  background-color: #1b3a6b;
  border-color: #0e1f3d;
  color: #ffffff;
}

.ad-btn-secondary {
  border-color: var(--border-strong);
  background-color: var(--surface);
  color: var(--text);
}

.ad-promo-note {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 9px;
  background-color: var(--surface-subtle);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.ad-popup-footer {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

/* Ad-free settings modal */
.adfree-modal-panel {
  max-width: 500px;
}

.license-status-card {
  padding: 14px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background-color: var(--surface-subtle);
  margin-bottom: 14px;
}

.license-status-card.is-pro {
  background-color: var(--success-soft);
  border-color: var(--success-border);
}

.license-status-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.license-plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  background-color: var(--surface-hover);
  color: var(--text-secondary);
}

.license-status-card.is-pro .license-plan-badge {
  background-color: var(--success);
  color: #ffffff;
}

.license-status-desc {
  margin: 8px 0 0;
  font-size: 0.84rem;
  color: var(--text);
  line-height: 1.55;
}

.license-meta-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-wrap: anywhere;
}

.license-preview-wrap {
  margin-top: 10px;
}

.adfree-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.adfree-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.adfree-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text);
}

.adfree-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

.adfree-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(48, 76, 202, 0.12);
  outline: none;
}

.adfree-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.auth-message {
  margin: 0;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 0.83rem;
  font-weight: 700;
  line-height: 1.5;
}

.auth-message.is-error {
  background-color: var(--danger-soft);
  border: 1px solid var(--danger-border);
  color: var(--danger);
}

.auth-message.is-success {
  background-color: var(--success-soft);
  border: 1px solid var(--success-border);
  color: var(--success);
}

@media (max-width: 480px) {
  .modal-overlay {
    padding: 10px;
  }

  .modal-panel {
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
  }

  .ad-hero {
    padding: 12px 14px 14px;
  }

  .ad-body,
  .modal-body {
    padding: 14px;
  }

  #dialog-ad-popup .ad-promo-title {
    font-size: 1.08rem;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .term-card.slide-next,
  .term-card.slide-prev,
  .ad-modal-panel {
    animation: none !important;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
