@font-face {
  font-family: "Sarabun";
  src: url("assets/fonts/accessibility/Sarabun-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Sarabun";
  src: url("assets/fonts/accessibility/Sarabun-SemiBold.ttf") format("truetype");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "Sarabun";
  src: url("assets/fonts/accessibility/Sarabun-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

.accessibility-button {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--emerald-dark);
  background: transparent;
  border: 1px solid var(--line-strong, var(--line));
  border-radius: 50%;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.accessibility-button:hover,
.accessibility-button[aria-expanded="true"] { color: white; background: var(--emerald); border-color: var(--emerald); }
.accessibility-button:focus-visible { outline: 3px solid #ffbf47; outline-offset: 3px; }

.accessibility-panel {
  position: fixed;
  top: calc(var(--header-height, 72px) + 10px);
  right: 24px;
  z-index: 220;
  width: min(370px, calc(100vw - 24px));
  max-height: calc(100svh - var(--header-height, 72px) - 22px);
  overflow-y: auto;
  padding: 20px;
  color: #17362c;
  background: #fffef8;
  border: 1px solid rgba(23, 54, 44, 0.24);
  border-radius: 16px;
  box-shadow: 0 22px 60px rgba(0, 45, 32, 0.2);
}

.accessibility-panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 14px; border-bottom: 1px solid rgba(23, 54, 44, 0.16); }
.accessibility-panel-header h2 { margin: 0; font-size: 1.35rem; line-height: 1.2; }
.accessibility-panel-header p { margin: 4px 0 0; color: #53665f; font-size: 0.82rem; line-height: 1.4; }
.accessibility-close { display: grid; place-items: center; flex: 0 0 40px; width: 40px; height: 40px; padding: 0; color: #17362c; background: transparent; border: 1px solid rgba(23, 54, 44, 0.24); border-radius: 50%; font-size: 1.35rem; line-height: 1; cursor: pointer; }
.accessibility-close:hover { background: #dceee6; border-color: #00744b; }

.accessibility-group { margin: 18px 0 0; padding: 0; border: 0; }
.accessibility-group legend,
.accessibility-group-title { display: block; margin: 0 0 9px; color: #17362c; font-size: 0.9rem; font-weight: 700; }
.accessibility-size-controls { display: grid; grid-template-columns: 44px 1fr 44px; gap: 8px; }
.accessibility-size-controls button { min-height: 44px; padding: 6px; color: #004b36; background: white; border: 1px solid rgba(23, 54, 44, 0.26); border-radius: 9px; font-weight: 700; cursor: pointer; }
.accessibility-size-controls button:hover:not(:disabled) { background: #dceee6; border-color: #00744b; }
.accessibility-size-controls button:disabled { opacity: 0.4; cursor: not-allowed; }
.accessibility-size-value { display: grid; place-items: center; min-height: 44px; color: #17362c; background: #f4f1e7; border-radius: 9px; font-size: 0.9rem; font-weight: 700; }

.accessibility-fonts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.accessibility-font-option { position: relative; display: grid; place-items: center; min-height: 54px; padding: 7px 5px; color: #17362c; background: white; border: 1px solid rgba(23, 54, 44, 0.22); border-radius: 9px; text-align: center; cursor: pointer; }
.accessibility-font-option:has(input:checked) { color: white; background: #00744b; border-color: #00744b; }
.accessibility-font-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.accessibility-font-option:focus-within { outline: 3px solid #ffbf47; outline-offset: 2px; }
.accessibility-font-option span { font-size: 0.78rem; font-weight: 700; line-height: 1.2; }
.accessibility-font-option[data-font="pridi"] span { font-family: "Pridi", "Sarabun", sans-serif; }
.accessibility-font-option[data-font="sarabun"] span { font-family: "Sarabun", sans-serif; }

.accessibility-switches { display: grid; gap: 7px; }
.accessibility-switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 46px; padding: 8px 10px; background: white; border: 1px solid rgba(23, 54, 44, 0.18); border-radius: 9px; cursor: pointer; }
.accessibility-switch > span:first-child { font-size: 0.86rem; font-weight: 600; line-height: 1.3; }
.accessibility-switch input { position: absolute; opacity: 0; pointer-events: none; }
.accessibility-switch-control { position: relative; flex: 0 0 42px; width: 42px; height: 24px; background: #d7dedb; border: 1px solid #9aacA5; border-radius: 999px; transition: background 160ms ease; }
.accessibility-switch-control::after { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; content: ""; background: white; border-radius: 50%; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22); transition: transform 160ms ease; }
.accessibility-switch input:checked + .accessibility-switch-control { background: #00744b; border-color: #00744b; }
.accessibility-switch input:checked + .accessibility-switch-control::after { transform: translateX(18px); }
.accessibility-switch:focus-within { outline: 3px solid #ffbf47; outline-offset: 2px; }

.accessibility-reset { width: 100%; min-height: 44px; margin-top: 18px; color: #004b36; background: transparent; border: 1px solid rgba(23, 54, 44, 0.34); border-radius: 9px; font-weight: 700; cursor: pointer; }
.accessibility-reset:hover { background: #dceee6; border-color: #00744b; }

html[data-a11y-font="pridi"] body,
html[data-a11y-font="pridi"] button,
html[data-a11y-font="pridi"] input,
html[data-a11y-font="pridi"] select { font-family: "Pridi", "Sarabun", Arial, sans-serif !important; }
html[data-a11y-font="sarabun"] body,
html[data-a11y-font="sarabun"] button,
html[data-a11y-font="sarabun"] input,
html[data-a11y-font="sarabun"] select { font-family: "Sarabun", Arial, sans-serif !important; }

html.a11y-high-contrast {
  --ink: #071a14;
  --muted: #2e403a;
  --emerald: #005f3d;
  --emerald-dark: #003d2c;
  --emerald-deep: #002d22;
  --line: rgba(0, 25, 18, 0.38);
  --line-strong: rgba(0, 25, 18, 0.58);
}
html.a11y-readable-spacing p,
html.a11y-readable-spacing li,
html.a11y-readable-spacing label,
html.a11y-readable-spacing td,
html.a11y-readable-spacing th { line-height: 1.75 !important; letter-spacing: 0.015em; }
html.a11y-underline-links body a:not(.brand) { text-decoration: underline !important; text-decoration-thickness: 0.1em !important; text-underline-offset: 0.18em !important; }
html.a11y-reduce-motion { scroll-behavior: auto !important; }
html.a11y-reduce-motion *,
html.a11y-reduce-motion *::before,
html.a11y-reduce-motion *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }

@media (max-width: 540px) {
  .accessibility-panel { top: calc(var(--header-height, 68px) + 6px); right: 8px; width: calc(100vw - 16px); max-height: calc(100svh - var(--header-height, 68px) - 14px); padding: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  .accessibility-panel, .accessibility-panel * { scroll-behavior: auto; }
}
