:root {
  color-scheme: light dark;

  --md-sys-color-primary: #005BC0;
  --md-sys-color-on-primary: #FFFFFF;
  --md-sys-color-primary-container: #D8E2FF;
  --md-sys-color-on-primary-container: #004493;
  --md-sys-color-secondary: #585C7E;
  --md-sys-color-on-secondary: #FFFFFF;
  --md-sys-color-secondary-container: #DFE0FF;
  --md-sys-color-on-secondary-container: #414465;
  --md-sys-color-tertiary: #00796B;
  --md-sys-color-on-tertiary: #FFFFFF;
  --md-sys-color-tertiary-container: #B2DFDB;
  --md-sys-color-on-tertiary-container: #00201C;
  --md-sys-color-error: #BA1A1A;
  --md-sys-color-on-error: #FFFFFF;
  --md-sys-color-error-container: #FFDAD6;
  --md-sys-color-on-error-container: #93000A;
  --md-sys-color-background: #FFFFFF;
  --md-sys-color-on-background: #1A1C20;
  --md-sys-color-surface: #FFFFFF;
  --md-sys-color-on-surface: #1A1C20;
  --md-sys-color-surface-variant: #E1E3EA;
  --md-sys-color-on-surface-variant: #44474F;
  --md-sys-color-surface-container-lowest: #FFFFFF;
  --md-sys-color-surface-container-low: #FBFCFE;
  --md-sys-color-surface-container: #F8F9FC;
  --md-sys-color-surface-container-high: #F1F3F9;
  --md-sys-color-surface-container-highest: #E9ECF4;
  --md-sys-color-outline: #74777F;
  --md-sys-color-outline-variant: #C4C6CF;
  --md-sys-color-inverse-surface: #2A2C32;
  --md-sys-color-inverse-on-surface: #F1F3F9;
  --md-sys-color-brand: #1A73E8;
  --md-sys-color-brand-accent: #0073EF;

  --md-sys-shape-corner-extra-small: 4px;
  --md-sys-shape-corner-small: 8px;
  --md-sys-shape-corner-medium: 12px;
  --md-sys-shape-corner-large: 16px;
  --md-sys-shape-corner-large-increased: 20px;
  --md-sys-shape-corner-extra-large: 28px;
  --md-sys-shape-corner-extra-large-increased: 32px;
  --md-sys-shape-corner-full: 999px;

  --md-sys-gradient-hero: linear-gradient(135deg, #0073EF 0%, #004493 100%);
  --md-sys-gradient-brand: linear-gradient(135deg, #1A73E8 0%, #005BC0 100%);
  --md-sys-gradient-btn-sheen: linear-gradient(180deg, color-mix(in srgb, var(--md-sys-color-primary) 88%, white) 0%, var(--md-sys-color-primary) 100%);
  --md-sys-gradient-hairline: linear-gradient(135deg, #1A73E8 0%, #7CACF8 100%);
  --md-sys-gradient-hairline-subtle: linear-gradient(135deg, var(--md-sys-color-outline-variant) 0%, var(--md-sys-color-primary) 100%);
  --md-sys-gradient-divider: linear-gradient(90deg, transparent 0%, var(--md-sys-color-outline-variant) 50%, transparent 100%);
  --md-sys-gradient-ring: conic-gradient(from var(--cc-ring-angle, 0deg), transparent 0%, var(--md-sys-color-primary) 55%, var(--md-sys-color-brand-accent) 100%);

  --md-sys-motion-spring-spatial-fast: linear(0, 0.0912, 0.2944, 0.5274, 0.7384, 0.9019, 1.0111, 1.0713, 1.0936, 1.0906, 1.0739, 1.052, 1.031, 1.0138, 1.0018, 0.9947, 0.9915, 0.9911, 0.9924, 0.9944, 0.9964, 0.9982, 0.9995, 1.0003, 1);
  --md-sys-motion-spring-spatial-default: linear(0, 0.0577, 0.1881, 0.3447, 0.4992, 0.6365, 0.7498, 0.8382, 0.9036, 0.9496, 0.98, 0.9989, 1.0093, 1.014, 1.0152, 1.0142, 1.0122, 1.0098, 1.0075, 1.0054, 1.0037, 1.0024, 1.0014, 1.0007, 1);
  --md-sys-motion-spring-effects-default: linear(0, 0.0661, 0.2032, 0.3554, 0.4963, 0.6161, 0.7127, 0.7881, 0.8454, 0.8883, 0.9199, 0.9429, 0.9596, 0.9715, 0.98, 0.986, 0.9902, 0.9932, 0.9953, 0.9967, 0.9978, 0.9985, 0.9989, 0.9993, 1);
  --md-sys-motion-duration-spatial-fast: 400ms;
  --md-sys-motion-duration-spatial-default: 462ms;
  --md-sys-motion-duration-effects-default: 250ms;
  --md-sys-motion-easing-emphasized: cubic-bezier(0.2, 0, 0, 1);

  --md-sys-font-brand: "Google Sans Flex", "Google Sans", Roboto, system-ui, sans-serif;
  --md-sys-font-code: "Google Sans Code", "Roboto Mono", ui-monospace, monospace;

  --md-sys-typescale-headline-small: 400 24px/32px var(--md-sys-font-brand);
  --md-sys-typescale-headline-small-emphasized: 500 24px/32px var(--md-sys-font-brand);
  --md-sys-typescale-title-large: 400 22px/28px var(--md-sys-font-brand);
  --md-sys-typescale-title-medium: 500 16px/24px var(--md-sys-font-brand);
  --md-sys-typescale-body-large: 400 16px/24px var(--md-sys-font-brand);
  --md-sys-typescale-body-medium: 400 14px/20px var(--md-sys-font-brand);
  --md-sys-typescale-label-large: 500 14px/20px var(--md-sys-font-brand);
  --md-sys-typescale-label-large-emphasized: 700 14px/20px var(--md-sys-font-brand);
  --md-sys-typescale-label-medium: 500 12px/16px var(--md-sys-font-brand);

  --cc-print-bar-space: 210px;
  --cc-content-max: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --md-sys-color-primary: #ADC7FF;
    --md-sys-color-on-primary: #002E68;
    --md-sys-color-primary-container: #004493;
    --md-sys-color-on-primary-container: #D8E2FF;
    --md-sys-color-secondary: #C1C4EB;
    --md-sys-color-on-secondary: #2A2E4D;
    --md-sys-color-secondary-container: #414465;
    --md-sys-color-on-secondary-container: #DFE0FF;
    --md-sys-color-tertiary: #77D9CB;
    --md-sys-color-on-tertiary: #00332C;
    --md-sys-color-tertiary-container: #004D43;
    --md-sys-color-on-tertiary-container: #B2DFDB;
    --md-sys-color-error: #FFB4AB;
    --md-sys-color-on-error: #690005;
    --md-sys-color-error-container: #93000A;
    --md-sys-color-on-error-container: #FFDAD6;
    --md-sys-color-background: #121316;
    --md-sys-color-on-background: #E1E3EA;
    --md-sys-color-surface: #121316;
    --md-sys-color-on-surface: #E1E3EA;
    --md-sys-color-surface-variant: #44474F;
    --md-sys-color-on-surface-variant: #C4C6CF;
    --md-sys-color-surface-container-lowest: #0D0E11;
    --md-sys-color-surface-container-low: #1A1C20;
    --md-sys-color-surface-container: #1E1F24;
    --md-sys-color-surface-container-high: #24262B;
    --md-sys-color-surface-container-highest: #2A2C32;
    --md-sys-color-outline: #8D9199;
    --md-sys-color-outline-variant: #44474F;
    --md-sys-color-inverse-surface: #E1E3EA;
    --md-sys-color-inverse-on-surface: #2A2C32;
    --md-sys-color-brand: #ADC7FF;
    --md-sys-color-brand-accent: #7CACF8;
    --md-sys-gradient-hero: linear-gradient(135deg, #004493 0%, #001A41 100%);
    --md-sys-gradient-brand: linear-gradient(135deg, #1A73E8 0%, #002E68 100%);
    --md-sys-gradient-hairline: linear-gradient(135deg, #ADC7FF 0%, #D8E2FF 100%);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --md-sys-color-primary: #ADC7FF;
  --md-sys-color-on-primary: #002E68;
  --md-sys-color-primary-container: #004493;
  --md-sys-color-on-primary-container: #D8E2FF;
  --md-sys-color-secondary: #C1C4EB;
  --md-sys-color-on-secondary: #2A2E4D;
  --md-sys-color-secondary-container: #414465;
  --md-sys-color-on-secondary-container: #DFE0FF;
  --md-sys-color-tertiary: #77D9CB;
  --md-sys-color-on-tertiary: #00332C;
  --md-sys-color-tertiary-container: #004D43;
  --md-sys-color-on-tertiary-container: #B2DFDB;
  --md-sys-color-error: #FFB4AB;
  --md-sys-color-on-error: #690005;
  --md-sys-color-error-container: #93000A;
  --md-sys-color-on-error-container: #FFDAD6;
  --md-sys-color-background: #121316;
  --md-sys-color-on-background: #E1E3EA;
  --md-sys-color-surface: #121316;
  --md-sys-color-on-surface: #E1E3EA;
  --md-sys-color-surface-variant: #44474F;
  --md-sys-color-on-surface-variant: #C4C6CF;
  --md-sys-color-surface-container-lowest: #0D0E11;
  --md-sys-color-surface-container-low: #1A1C20;
  --md-sys-color-surface-container: #1E1F24;
  --md-sys-color-surface-container-high: #24262B;
  --md-sys-color-surface-container-highest: #2A2C32;
  --md-sys-color-outline: #8D9199;
  --md-sys-color-outline-variant: #44474F;
  --md-sys-color-inverse-surface: #E1E3EA;
  --md-sys-color-inverse-on-surface: #2A2C32;
  --md-sys-color-brand: #ADC7FF;
  --md-sys-color-brand-accent: #7CACF8;
  --md-sys-gradient-hero: linear-gradient(135deg, #004493 0%, #001A41 100%);
  --md-sys-gradient-brand: linear-gradient(135deg, #1A73E8 0%, #002E68 100%);
  --md-sys-gradient-hairline: linear-gradient(135deg, #ADC7FF 0%, #D8E2FF 100%);
}

:root[data-theme="light"] {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-body-large);
  -webkit-font-smoothing: antialiased;
}

img,
svg,
video,
canvas {
  max-width: 100%;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font: var(--md-sys-typescale-title-large);
}

h2 {
  font: var(--md-sys-typescale-title-medium);
}

h3 {
  font: var(--md-sys-typescale-title-medium);
}

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

.skip-link {
  position: absolute;
  top: -60px;
  left: 12px;
  z-index: 100;
  padding: 12px 20px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font: var(--md-sys-typescale-label-large);
  text-decoration: none;
  transition: top var(--md-sys-motion-duration-effects-default) var(--md-sys-motion-easing-emphasized);
}

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

.muted {
  color: var(--md-sys-color-on-surface-variant);
  font: var(--md-sys-typescale-body-medium);
}

.icon {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.icon--lg {
  width: 30px;
  height: 30px;
}

.app-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 12px clamp(12px, 4vw, 32px);
  padding-top: calc(12px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--md-sys-color-surface) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  border-image: var(--md-sys-gradient-divider) 1;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}

.brand-mark {
  display: inline-flex;
  flex: 0 0 auto;
}

.brand-text {
  min-width: 0;
}

.brand-text h1,
.brand-text p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-text p {
  color: var(--md-sys-color-on-surface-variant);
  font: var(--md-sys-typescale-label-medium);
}

.app-bar__tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.lang {
  display: inline-flex;
  align-items: center;
}

.lang select {
  width: auto;
  min-width: 0;
  max-width: 150px;
  padding: 8px 32px 8px 12px;
  font: var(--md-sys-typescale-label-large);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  transition:
    background-color var(--md-sys-motion-duration-effects-default) var(--md-sys-motion-spring-effects-default),
    color var(--md-sys-motion-duration-effects-default) var(--md-sys-motion-spring-effects-default),
    transform var(--md-sys-motion-duration-spatial-fast) var(--md-sys-motion-spring-spatial-fast);
}

.icon-btn:hover {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon--sun {
  display: none;
}

:root[data-theme="dark"] .icon--moon {
  display: none;
}

:root[data-theme="dark"] .icon--sun {
  display: inline-block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon--moon {
    display: none;
  }
  :root:not([data-theme="light"]) .icon--sun {
    display: inline-block;
  }
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
  font: var(--md-sys-typescale-label-large);
  white-space: nowrap;
}

.chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--md-sys-color-outline);
}

.chip[data-state="connected"] {
  background: var(--md-sys-color-tertiary-container);
  color: var(--md-sys-color-on-tertiary-container);
}

.chip[data-state="connected"]::before {
  background: var(--md-sys-color-tertiary);
}

.chip[data-state="busy"]::before {
  background: var(--md-sys-color-brand-accent);
  animation: pulse 900ms ease-in-out infinite alternate;
}

.chip[data-state="error"] {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
}

.chip[data-state="error"]::before {
  background: var(--md-sys-color-error);
}

main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: var(--cc-content-max);
  margin: 0 auto;
  padding: 16px clamp(12px, 4vw, 32px) calc(var(--cc-print-bar-space) + env(safe-area-inset-bottom));
}

.card {
  background: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-corner-large);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap;
}

.card-head > div:first-child {
  min-width: 0;
}

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

.row-actions .btn {
  flex: 1 1 auto;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar .btn {
  flex: 1 1 150px;
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 22px;
  border: none;
  cursor: pointer;
  font: var(--md-sys-typescale-label-large);
  overflow-wrap: anywhere;
  border-radius: var(--md-sys-shape-corner-full);
  transition:
    border-radius var(--md-sys-motion-duration-spatial-fast) var(--md-sys-motion-spring-spatial-fast),
    transform var(--md-sys-motion-duration-spatial-fast) var(--md-sys-motion-spring-spatial-fast),
    background-color var(--md-sys-motion-duration-effects-default) var(--md-sys-motion-spring-effects-default),
    opacity var(--md-sys-motion-duration-effects-default) var(--md-sys-motion-spring-effects-default);
}

.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: currentColor;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--md-sys-motion-duration-effects-default) var(--md-sys-motion-spring-effects-default);
}

.btn:hover:not(:disabled)::before {
  opacity: 0.08;
}

.btn:focus-visible::before {
  opacity: 0.12;
}

.btn:active:not(:disabled)::before {
  opacity: 0.16;
}

.btn:active:not(:disabled) {
  transform: scale(0.96);
  border-radius: var(--md-sys-shape-corner-large);
}

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

.btn--filled {
  background: var(--md-sys-gradient-btn-sheen);
  color: var(--md-sys-color-on-primary);
}

.btn--tonal {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.btn--outlined {
  background: transparent;
  color: var(--md-sys-color-primary);
  border: 1px solid var(--md-sys-color-outline);
}

.btn--danger {
  background: var(--md-sys-color-error);
  color: var(--md-sys-color-on-error);
}

.btn--large {
  min-height: 56px;
  padding: 0 32px;
  font: var(--md-sys-typescale-title-medium);
  flex: 1;
}

.btn--loading {
  position: relative;
  pointer-events: none;
}

.btn--loading::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  padding: 2px;
  background: var(--md-sys-gradient-ring);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  animation: ring 1200ms linear infinite;
}

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

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

.tab {
  appearance: none;
  border: none;
  background: none;
  cursor: pointer;
  flex: 0 0 auto;
  min-height: 52px;
  padding: 12px 16px;
  white-space: nowrap;
  scroll-snap-align: start;
  color: var(--md-sys-color-on-surface-variant);
  font: var(--md-sys-typescale-label-large);
  border-bottom: 3px solid transparent;
  border-radius: var(--md-sys-shape-corner-extra-small) var(--md-sys-shape-corner-extra-small) 0 0;
  transition:
    color var(--md-sys-motion-duration-effects-default) var(--md-sys-motion-easing-emphasized),
    background-color var(--md-sys-motion-duration-effects-default) var(--md-sys-motion-easing-emphasized);
}

.tab:hover {
  background: var(--md-sys-color-surface-container-high);
}

.tab[aria-selected="true"] {
  color: var(--md-sys-color-primary);
  border-bottom-color: var(--md-sys-color-primary);
  font: var(--md-sys-typescale-label-large-emphasized);
}

.panel {
  outline-offset: 2px;
}

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 140px;
  justify-content: center;
  padding: 28px 16px;
  border-radius: var(--md-sys-shape-corner-medium);
  border: 1.5px dashed var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface-variant);
  text-align: center;
  cursor: pointer;
  transition:
    border-color var(--md-sys-motion-duration-effects-default) var(--md-sys-motion-easing-emphasized),
    background-color var(--md-sys-motion-duration-effects-default) var(--md-sys-motion-easing-emphasized);
}

.drop .icon--lg {
  color: var(--md-sys-color-primary);
  margin-bottom: 4px;
}

.drop strong {
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-title-medium);
}

.drop[data-hover="true"] {
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-surface-container-high);
}

.drop span {
  font: var(--md-sys-typescale-body-medium);
}

.preview {
  display: flex;
  justify-content: center;
  padding: clamp(10px, 3vw, 20px);
  background: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--md-sys-shape-corner-medium);
  border: 1px solid var(--md-sys-color-outline-variant);
  overflow: auto;
}

.preview[data-empty="true"] {
  display: none;
}

.preview:has(canvas[width="0"]) {
  display: none;
}

.preview canvas {
  max-width: 100%;
  height: auto;
  background: #FFFFFF;
  border-radius: var(--md-sys-shape-corner-extra-small);
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.18),
    0 1px 2px rgba(0, 0, 0, 0.12);  image-rendering: pixelated;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  gap: 16px;
  align-items: start;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  font: var(--md-sys-typescale-label-large);
  color: var(--md-sys-color-on-surface-variant);
}

.field > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field output {
  color: var(--md-sys-color-primary);
  font: var(--md-sys-typescale-label-large-emphasized);
  font-variant-numeric: tabular-nums;
}

.form-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border-radius: var(--md-sys-shape-corner-medium);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-low);
}

.form-block h3 {
  color: var(--md-sys-color-on-surface);
}

.presets__row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.presets__row .field {
  flex: 1 1 200px;
}

.presets__row .btn {
  flex: 0 0 auto;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  font: var(--md-sys-typescale-label-large);
  color: var(--md-sys-color-on-surface-variant);
}

.check input[type="checkbox"] {
  accent-color: var(--md-sys-color-primary);
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  cursor: pointer;
  font: var(--md-sys-typescale-label-large);
  color: var(--md-sys-color-on-surface-variant);
}

.switch input {
  appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 52px;
  height: 32px;
  margin: 0;
  border: 2px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-surface-container-highest);
  cursor: pointer;
  transition:
    background-color var(--md-sys-motion-duration-effects-default) var(--md-sys-motion-easing-emphasized),
    border-color var(--md-sys-motion-duration-effects-default) var(--md-sys-motion-easing-emphasized);
}

.switch input::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 7px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--md-sys-color-outline);
  transform: translateY(-50%);
  transition:
    left var(--md-sys-motion-duration-spatial-fast) var(--md-sys-motion-spring-spatial-fast),
    width var(--md-sys-motion-duration-spatial-fast) var(--md-sys-motion-spring-spatial-fast),
    height var(--md-sys-motion-duration-spatial-fast) var(--md-sys-motion-spring-spatial-fast),
    background-color var(--md-sys-motion-duration-effects-default) var(--md-sys-motion-easing-emphasized);
}

.switch input:checked {
  background: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
}

.switch input:checked::before {
  left: calc(100% - 5px);
  width: 24px;
  height: 24px;
  background: var(--md-sys-color-on-primary);
  transform: translate(-100%, -50%);
}

input[type="range"] {
  accent-color: var(--md-sys-color-primary);
  width: 100%;
  min-height: 44px;
}

input[type="text"],
input[type="number"],
input[type="url"],
input[type="tel"],
input[type="email"],
input[type="date"],
select,
textarea {
  font: var(--md-sys-typescale-body-large);
  color: var(--md-sys-color-on-surface);
  background-color: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-small);
  padding: 10px 12px;
  width: 100%;
  min-height: 44px;
}

select {
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6' fill='none' stroke='%2374777F' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px 18px;
}

textarea {
  resize: vertical;
  min-height: 96px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
summary:focus-visible,
a:focus-visible,
video:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--md-sys-color-brand-accent);
  outline-offset: 2px;
}

.segmented {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.segmented::-webkit-scrollbar {
  display: none;
}

.segment,
.segmented > button,
.segmented > label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--md-sys-shape-corner-full);
  border: 1px solid var(--md-sys-color-outline);
  background: transparent;
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-label-large);
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--md-sys-motion-duration-effects-default) var(--md-sys-motion-easing-emphasized),
    color var(--md-sys-motion-duration-effects-default) var(--md-sys-motion-easing-emphasized);
}

.segment[aria-pressed="true"],
.segment[aria-selected="true"],
.segmented > button[aria-pressed="true"] {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: transparent;
}

.segment:not([aria-pressed="true"]):hover,
.segmented > button:not([aria-pressed="true"]):hover,
.chip-toggle:hover {
  background: var(--md-sys-color-surface-container-high);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--md-sys-shape-corner-full);
  border: 1px solid var(--md-sys-color-outline);
  background: transparent;
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-label-large);
  cursor: pointer;
  transition:
    background-color var(--md-sys-motion-duration-effects-default) var(--md-sys-motion-easing-emphasized),
    color var(--md-sys-motion-duration-effects-default) var(--md-sys-motion-easing-emphasized);
}

.chip-toggle:has(input:checked) {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: transparent;
}

.chip-toggle input {
  accent-color: var(--md-sys-color-primary);
  width: 18px;
  height: 18px;
}

.gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.gallery > * {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  min-height: 44px;
  padding: 14px;
  text-align: left;
  overflow-wrap: anywhere;
  border-radius: var(--md-sys-shape-corner-medium);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-body-medium);
  cursor: pointer;
}

.gallery > *:hover {
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-surface-container-high);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
}

.table {
  width: 100%;
  min-width: 340px;
  border-collapse: collapse;
  font: var(--md-sys-typescale-body-medium);
}

.table th,
.table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  white-space: nowrap;
}

.table thead th {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
  font: var(--md-sys-typescale-label-large);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

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

.list > li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--md-sys-shape-corner-medium);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-low);
  font: var(--md-sys-typescale-body-medium);
  overflow-wrap: anywhere;
}

.list--ordered {
  list-style: none;
  counter-reset: cc-block;
}

.list--ordered > li {
  counter-increment: cc-block;
}

.notice {
  padding: 12px 14px;
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font: var(--md-sys-typescale-body-medium);
}

.notice[data-state="ok"] {
  background: var(--md-sys-color-tertiary-container);
  color: var(--md-sys-color-on-tertiary-container);
}

.notice[data-state="error"] {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
}

.result-box {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-radius: var(--md-sys-shape-corner-medium);
  border: 1px dashed var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface-variant);
  font-family: var(--md-sys-font-code);
  font-size: 14px;
  line-height: 20px;
  word-break: break-all;
}

.video {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--md-sys-shape-corner-large);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: #000000;
}

.video video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.settings {
  padding: 0;
  overflow: hidden;
}

.settings__summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 8px 20px;
  cursor: pointer;
  list-style: none;
}

.settings__summary::-webkit-details-marker {
  display: none;
}

.settings__summary h2 {
  flex: 1 1 auto;
}

.settings__chevron {
  flex: 0 0 auto;
  color: var(--md-sys-color-on-surface-variant);
  transition: transform var(--md-sys-motion-duration-spatial-fast) var(--md-sys-motion-spring-spatial-fast);
}

.settings[open] .settings__chevron {
  transform: rotate(180deg);
}

.settings__body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 4px 20px 20px;
}

.log-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log-output {
  margin: 0;
  max-height: 260px;
  overflow: auto;
  padding: 12px 14px;
  border-radius: var(--md-sys-shape-corner-medium);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface-variant);
  font-family: var(--md-sys-font-code);
  font-size: 13px;
  line-height: 20px;
  white-space: pre-wrap;
  word-break: break-word;
}

.print-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 0 clamp(10px, 3vw, 24px) calc(10px + env(safe-area-inset-bottom));
  pointer-events: none;
}

.print-bar__panel {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: var(--cc-content-max);
  margin: 0 auto;
  padding: 12px;
  border-radius: var(--md-sys-shape-corner-extra-large);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: color-mix(in srgb, var(--md-sys-color-surface-container-high) 94%, transparent);
  backdrop-filter: blur(16px);
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.18);
}

.print-bar__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.print-bar__status {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--md-sys-color-on-surface-variant);
  font: var(--md-sys-typescale-body-medium);
}

.print-bar__percent {
  flex: 0 0 auto;
  color: var(--md-sys-color-primary);
  font: var(--md-sys-typescale-label-large-emphasized);
  font-variant-numeric: tabular-nums;
}

.print-bar__actions {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 8px;
}

.print-bar__actions #print {
  flex: 1 1 auto;
  min-width: 0;
}

.print-bar__actions #stop {
  flex: 0 0 auto;
}

.print-bar__options {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
}

progress {
  width: 100%;
  height: 8px;
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  overflow: hidden;
  appearance: none;
  background: var(--md-sys-color-surface-container-highest);
}

progress::-webkit-progress-bar {
  background: var(--md-sys-color-surface-container-highest);
}

progress::-webkit-progress-value {
  background: var(--md-sys-gradient-brand);
}

progress::-moz-progress-bar {
  background: var(--md-sys-gradient-brand);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + var(--cc-print-bar-space));
  z-index: 40;
  max-width: min(92vw, 440px);
  padding: 12px 18px;
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-inverse-surface);
  color: var(--md-sys-color-inverse-on-surface);
  font: var(--md-sys-typescale-body-medium);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  transform: translate(-50%, 10px);
  opacity: 0;
  transition:
    opacity var(--md-sys-motion-duration-effects-default) var(--md-sys-motion-easing-emphasized),
    transform var(--md-sys-motion-duration-spatial-fast) var(--md-sys-motion-spring-spatial-default);
}

.toast[data-visible="true"] {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (min-width: 640px) {
  .gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .row-actions .btn {
    flex: 0 1 auto;
  }
  .toolbar .btn {
    flex: 0 1 auto;
  }
}

@media (min-width: 1000px) {
  .gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .grid {
    grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  }
}

@media (min-width: 1024px) {
  main {
    padding-top: 24px;
  }
  .card {
    padding: 24px;
  }
  .settings__body {
    padding: 4px 24px 24px;
  }
}

@property --cc-ring-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

@keyframes ring {
  to {
    --cc-ring-angle: 1turn;
  }
}

@keyframes pulse {
  from {
    opacity: 0.5;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
  .btn,
  .btn::before,
  .tab,
  .icon-btn,
  .switch input,
  .switch input::before,
  .settings__chevron,
  .skip-link,
  .toast {
    transition-duration: 120ms;
    transition-timing-function: var(--md-sys-motion-easing-emphasized);
  }
}
