/* All visual rules live under the application root, away from the SDK's print nodes. */
#practice {
  --canvas: #f5f1e9;
  --surface: #fbf8f1;
  --sidebar: #efeae1;
  --ink: #303b44;
  --muted: #58636c;
  --line: #ded8cd;
  --accent: #3e647a;
  --accent-hover: #32546a;
  --accent-soft: #e7edf0;
  --error: #8f302b;
  --error-bg: #fff3ef;
  --radius: 18px;
  --shadow: 0 2px 6px #4539290a;
  --title-font: "Songti SC", "Noto Serif CJK SC", "SimSun", Georgia, serif;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font: 16px/1.55 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

body:has(> #practice) { margin: 0; }
#practice:lang(en) { --title-font: Georgia, serif; }
#practice *, #practice *::before, #practice *::after { box-sizing: border-box; }
#practice [hidden][hidden] { display: none; }
#practice :is(h1, h2, h3, p, fieldset) { margin: 0; }
#practice h1 { font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.25; font-family: var(--title-font); font-weight: 600; letter-spacing: .035em; }
#practice h2 { font-size: 1.25rem; line-height: 1.35; }
#practice h3 { font-size: .875rem; }
#practice .shell { width: min(1080px, calc(100% - 40px)); margin-inline: auto; }
#practice .top { border-bottom: 1px solid var(--line); }
#practice .top-inner { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#practice .brand { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: .9rem; font-weight: 600; }
#practice .language-control { position: relative; flex: 0 0 auto; }
#practice #language-toggle .mark { color: var(--accent); }
#practice #language-toggle[aria-expanded=true] .mark { background: var(--accent-soft); border-color: #aebfc7; }
#practice .language-options {
  position: absolute;
  z-index: 2;
  inset-block-start: calc(100% + 6px);
  inset-inline-end: 0;
  min-width: 155px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 24px #4539291a;
}
#practice .language-options button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding-inline: 10px;
  background: transparent;
  font-size: .9rem;
  text-align: start;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
#practice .language-options button[aria-pressed=true] { color: var(--accent); }
#practice .language-options button[aria-pressed=false] svg { visibility: hidden; }
#practice button.logo-toggle {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  min-height: 44px;
  margin-inline: -7px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}
#practice .mark { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); }
#practice .logo-toggle[aria-pressed=true] .mark { border-color: var(--accent); }
#practice .deltoid-needle { fill: none; stroke: #d6e4e7; stroke-width: 5; stroke-linecap: round; clip-path: url(#deltoid-edge); }
#practice .main { padding-block: clamp(28px, 6vw, 72px); }
#practice .account { display: flex; align-items: center; gap: 12px; margin-inline-start: auto; min-width: 0; text-align: right; font-size: .875rem; }
#practice .account > div { min-width: 0; }
#practice #username { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#practice .account span { display: block; color: var(--muted); }
#practice #logout { flex-shrink: 0; }
#practice .panel { padding: clamp(18px, 3vw, 28px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
#practice .startup { max-width: 500px; margin-inline: auto; }
#practice .startup button { margin-top: 12px; }
#practice .login { max-width: 420px; margin: clamp(0px, 3vh, 32px) auto 0; display: grid; gap: 28px; }
#practice .intro { text-align: center; }
#practice .intro h1 { font-size: clamp(2rem, 5vw, 2.75rem); }
#practice button.welcome-mark {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 0 auto 16px;
  padding: 0;
  border: 1px solid #9aafba;
  border-radius: 50%;
  box-shadow: 0 0 0 4px var(--canvas), 0 0 0 5px var(--line);
  background: radial-gradient(circle at 30% 20%, var(--surface), var(--accent-soft));
  color: var(--accent);
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  transition: transform 230ms cubic-bezier(.2, .75, .25, 1), border-color 180ms ease;
}
#practice button.welcome-mark:is(:active, .is-pressed) {
  transform: scale(.955);
  transition-duration: 90ms;
}
#practice .welcome-mark svg {
  grid-area: 1 / 1;
  display: block;
  width: 83%;
  height: 83%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms cubic-bezier(.25, .6, .35, 1);
}
#practice .welcome-mark svg.is-current { opacity: 1; }
@media (hover: hover) {
  #practice .logo-toggle:hover .mark { border-color: var(--accent); }
  #practice button.welcome-mark:hover { border-color: #849ba8; }
  #practice .language-options button:hover { background: var(--accent-soft); }
}
@media (prefers-reduced-motion: reduce) {
  #practice button.welcome-mark:is(:active, .is-pressed) { transform: none; }
  #practice button.welcome-mark,
  #practice .welcome-mark svg { transition: none; }
}
#practice .login-tagline { margin: 8px auto 0; color: var(--muted); }
#practice .eyebrow { color: var(--accent); font-size: .76rem; font-weight: 750; letter-spacing: .14em; margin-bottom: 10px; }
#practice .muted { color: var(--muted); }
#practice .login-panel h2 + p, #practice .workspace-heading p, #practice #exercise-meta, #practice #detail-status { margin-top: 6px; }
#practice .login-panel form { display: grid; gap: 8px; margin-top: 20px; }
#practice .login-panel form > label:not(:first-child) { margin-top: 6px; }
#practice .login-panel .primary { margin-top: 10px; }
#practice .password { display: flex; gap: 8px; }
#practice .password input { flex: 1; min-width: 0; }
#practice button.password-toggle {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  padding: 0;
  border-color: var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  -webkit-tap-highlight-color: transparent;
}
#practice .password-toggle .eye-open,
#practice .password input[type=text] + .password-toggle .eye-closed { display: none; }
#practice .password input[type=text] + .password-toggle .eye-open { display: block; }
@media (hover: hover) {
  #practice button.password-toggle:hover { color: var(--accent); border-color: #aebfc7; }
}
#practice :is(button, input, select) { font: inherit; color: inherit; }
#practice :is(input:not([type=radio], [type=checkbox]), select) { min-height: 42px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
#practice button { min-height: 40px; border: 1px solid transparent; border-radius: 10px; padding: 7px 14px; cursor: pointer; font-weight: 600; }
#practice .primary { background: var(--accent); color: white; }
#practice .primary:hover:not(:disabled) { background: var(--accent-hover); }
#practice .secondary { background: var(--surface); border-color: var(--line); }
#practice .secondary:hover:not(:disabled) { background: var(--accent-soft); }
#practice :disabled { opacity: .58; cursor: not-allowed; }
#practice :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#practice :is(h1, h2)[tabindex="-1"]:focus { outline: none; }
#practice .mobile-only { display: none; }
#practice .workspace-heading { margin-bottom: 24px; }
#practice .workspace-heading h1 { font-size: clamp(2rem, 4vw, 2.7rem); }
#practice .workspace-grid { display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); align-items: start; gap: 24px; }
#practice .catalog { padding: 16px 12px 12px; background: var(--sidebar); box-shadow: none; }
#practice .catalog h2 { margin-inline: 8px; font-size: .95rem; }
#practice .catalog #catalog-status { margin: 6px 8px; font-size: .875rem; }
#practice .catalog-view-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin: 10px 8px 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
#practice .catalog-view-switch button {
  min-height: 34px;
  padding: 4px 6px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: .83rem;
}
#practice .catalog-view-switch button[aria-pressed=true] {
  background: var(--surface);
  border-color: var(--line);
  color: var(--accent-hover);
}
#practice .settings { padding: clamp(20px, 4vw, 36px); }
#practice .settings h2 { font-family: var(--title-font); font-size: 1.5rem; font-weight: 600; }
#practice .exercise-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
#practice .exercise-heading h2 { min-width: 0; overflow-wrap: anywhere; }
#practice #search { width: calc(100% - 16px); min-height: 36px; margin: 10px 8px; font-size: .875rem; }
#practice #exercise-list { max-height: 500px; overflow: auto; padding: 3px; }
#practice .exercise-group + .exercise-group { margin-top: 2px; }
#practice .exercise-group summary {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 35px;
  padding: 5px 8px;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  font-size: .875rem;
}
#practice .exercise-group summary::-webkit-details-marker { display: none; }
#practice .exercise-group summary::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
}
#practice .exercise-group[open] > summary::before { transform: rotate(45deg); }
#practice .exercise-group summary small { font-size: .72rem; font-weight: 500; font-variant-numeric: tabular-nums; }
#practice .exercise-group summary:hover { background: var(--surface); }
#practice .exercise-group:not([open]):has([aria-current=true]) > summary { background: var(--accent-soft); color: var(--accent); }
#practice .exercise-group ul { list-style: none; margin: 2px 0 6px 12px; padding: 0 0 0 7px; border-left: 1px solid var(--line); }
#practice .exercise-results { list-style: none; margin: 0; padding: 0; }
#practice .exercise-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px; }
#practice button.favorite-toggle {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px;
  min-height: 36px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  -webkit-tap-highlight-color: transparent;
}
#practice .favorite-toggle svg { fill: none; stroke: currentColor; }
#practice button.favorite-toggle[aria-pressed=true] { color: #8a6030; }
#practice .favorite-toggle[aria-pressed=true] svg { fill: currentColor; }
@media (hover: hover) {
  #practice button.favorite-toggle:hover:not(:disabled) { background: var(--accent-soft); }
}
#practice button.exercise-option {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0 6px;
  width: 100%;
  min-height: 32px;
  padding: 4px 7px 4px 11px;
  text-align: left;
  background: transparent;
  font-size: .875rem;
  font-weight: 500;
}
#practice .exercise-option span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
#practice .exercise-option small { color: var(--muted); font-size: .68rem; font-weight: 500; white-space: nowrap; }
#practice .exercise-option .exercise-section { flex-basis: 100%; white-space: normal; }
#practice .exercise-option:hover:not(:disabled) { background: var(--surface); }
#practice .exercise-option[aria-current=true] { background: var(--accent-soft); border-color: #b5c5cf; color: var(--accent-hover); font-weight: 750; }
#practice .exercise-option[aria-current=true]::before {
  position: absolute;
  inset: 7px auto 7px 3px;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
  content: "";
}
#practice .settings form { margin-top: 20px; }
#practice #example { margin-top: 16px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--canvas); }
#practice .example-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 6px; }
#practice .example-heading span, #practice #example-status { font-size: .8rem; }
#practice #example-content { overflow-wrap: anywhere; }
#practice:lang(en) #example-content [data-i18n^="sample_"] { margin-inline-end: .25em; }
#practice #example-content .accesshide { display: none; }
#practice #example-content img { max-width: 100%; height: auto; }
#practice #example-content .local-quizpdf-batch-input { display: inline-block; min-width: 2.5em; border-bottom: 1px solid currentColor; }
#practice #retry-example { margin-top: 8px; }
#practice fieldset { padding: 0; border: 0; min-width: 0; }
#practice :is(label, legend, summary) { font-weight: 650; }
#practice .profiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 350px; gap: 8px; margin-top: 8px; }
#practice .profiles label { position: relative; cursor: pointer; }
#practice .profiles input { position: absolute; width: 1px; height: 1px; opacity: 0; }
#practice .profiles span { display: block; text-align: center; border: 1px solid var(--line); border-radius: 999px; padding: 7px 8px; }
#practice .profiles input:checked + span { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
#practice .profiles input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
#practice fieldset:disabled .profiles { opacity: .65; }
#practice .field-help { font-size: .875rem; margin: 6px 0 14px; }
#practice .pages-field, #practice .check { display: flex; align-items: center; gap: 8px; margin: 8px 0 14px; }
#practice .pages-field input { width: 80px; }
#practice input[type=checkbox] { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
#practice .answer-settings { padding: 14px; margin-bottom: 14px; background: var(--canvas); border-radius: 8px; }
#practice .answer-settings select, #practice .more select { margin-left: 8px; }
#practice .answer-settings p { margin-bottom: 0; }
#practice .more { border-block: 1px solid var(--line); padding-block: 10px; margin: 10px 0 16px; }
#practice .more summary { cursor: pointer; }
#practice .settings .primary { min-width: 180px; }
#practice .notice { border-radius: 8px; padding: 9px 12px; color: var(--error); background: var(--error-bg); margin: 10px 0; }
#practice .job { background: var(--canvas); border-radius: 10px; margin-top: 16px; padding: 12px 14px; overflow-wrap: anywhere; }
#practice .job[data-kind=error] { background: var(--error-bg); }
#practice .job[data-kind=success] { background: var(--accent-soft); }
#practice .job progress { width: 100%; margin-top: 8px; accent-color: var(--accent); }
#practice .job ul { margin: 6px 0 12px; padding-left: 22px; }
#practice .job button, #practice #retry-detail { margin-top: 8px; }
#practice .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 700px), (max-width: 960px) and (max-height: 540px) and (pointer: coarse) {
  #practice { min-height: 100dvh; }
  #practice .shell { width: min(640px, calc(100% - 24px)); }
  #practice .top-inner { gap: 8px; padding-block: 6px; }
  #practice .brand { gap: 7px; white-space: nowrap; }
  #practice .account { gap: 8px; }
  #practice #balance { font-size: .75rem; overflow-wrap: anywhere; }
  #practice .main { padding-block: 16px 28px; }
  #practice .login { gap: 20px; margin-top: 8px; }
  #practice button.welcome-mark { width: 58px; height: 58px; margin-bottom: 12px; }
  #practice .login-panel { padding: 16px; }
  #practice .login-panel :is(#login-user, #login-password) { width: 100%; }
  #practice .workspace-heading { margin-bottom: 14px; }
  #practice .workspace-heading h1 { font-size: 1.65rem; }
  #practice .workspace-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  #practice .panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  #practice .panel-heading :is(h2, p) { margin: 0; }
  #practice .mobile-only { display: block; font-size: .875rem; white-space: nowrap; }
  #practice #workspace[data-mobile-view="catalog"] .settings,
  #practice #workspace[data-mobile-view="settings"] :is(.catalog, .workspace-heading) { display: none; }
  #practice .catalog { padding: 12px; }
  #practice .settings { padding: 14px; overflow-wrap: anywhere; }
  #practice #exercise-title { font-size: 1.25rem; margin-top: 8px; }
  #practice #exercise-list { max-height: none; overflow: visible; }
  #practice #search { min-height: 44px; font-size: 1rem; }
  #practice :is(button, input:not([type=checkbox], [type=radio]), select, .exercise-group summary, .profiles span, .check) {
    min-height: 44px;
  }
  #practice button.exercise-option { padding-block: 7px; }
  #practice button.favorite-toggle { width: 44px; min-height: 44px; }
  #practice .catalog-view-switch button { min-height: 44px; }
  #practice .exercise-option small { font-size: .75rem; }
  #practice :is(.exercise-group summary, .exercise-section) { overflow-wrap: anywhere; }
  #practice .profiles { max-width: none; gap: 6px; }
  #practice .profiles span { display: grid; place-items: center; }
  #practice #example { padding: 10px 12px; }
  #practice .settings form { margin-top: 14px; }
  #practice .settings select { display: block; width: 100%; margin: 4px 0 0; }
  #practice .settings .check { margin-block: 4px; }
  #practice .settings .check input { flex-shrink: 0; }
  #practice .more summary { padding-block: 10px; }
  #practice .settings .primary { min-width: 0; width: 100%; }
}

@media (max-width: 520px) {
  #practice .top-inner { flex-wrap: wrap; }
  #practice .account {
    order: 1;
    flex-basis: 100%;
    justify-content: space-between;
    padding-block-start: 5px;
    border-top: 1px solid var(--line);
    text-align: left;
  }
}
