/* Material Design 3 components in plain CSS. Uses only the tokens in tokens.css. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-body-large);
}
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--md-sys-color-primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Top app bar */
.md-top-app-bar {
  display: flex; align-items: center; gap: 12px;
  min-height: 64px; padding: 8px 16px;
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
}
.md-top-app-bar__title { font: var(--md-sys-typescale-title-large); margin: 0; }
.md-top-app-bar__spacer { flex: 1; }

/* Buttons */
.md-button {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 24px; border: 0; border-radius: var(--md-sys-shape-corner-full);
  font: var(--md-sys-typescale-label-large); letter-spacing: 0.1px; text-decoration: none;
  cursor: pointer; user-select: none; background: transparent; color: var(--md-sys-color-primary);
  transition: box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}
/* 48px touch target around a 40px button */
.md-button::after { content: ""; position: absolute; inset: -4px 0; }
.md-button::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: currentColor; opacity: 0;
  transition: opacity var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}
.md-button:hover::before { opacity: var(--md-sys-state-hover-opacity); }
.md-button:active::before { opacity: var(--md-sys-state-pressed-opacity); }
.md-button:disabled { cursor: default; color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent); background: color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent); box-shadow: none; }
.md-button:disabled::before { display: none; }
.md-button--filled { background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); }
.md-button--filled:hover { box-shadow: var(--md-sys-elevation-level1); }
.md-button--tonal { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.md-button--outlined { border: 1px solid var(--md-sys-color-outline); color: var(--md-sys-color-primary); }
.md-button--outlined:disabled { background: transparent; }
.md-button--text { padding: 0 12px; color: var(--md-sys-color-primary); }
.md-button--text:disabled { background: transparent; }
.md-button--error { color: var(--md-sys-color-error); }

.md-icon-button {
  position: relative; display: inline-grid; place-items: center;
  width: 40px; height: 40px; margin: 4px; padding: 0; border: 0; border-radius: var(--md-sys-shape-corner-full);
  background: transparent; color: var(--md-sys-color-on-surface-variant); cursor: pointer;
  font: var(--md-sys-typescale-title-medium);
}
.md-icon-button::after { content: ""; position: absolute; inset: -4px; }
.md-icon-button:hover { background: color-mix(in srgb, var(--md-sys-color-on-surface-variant) 8%, transparent); }
.md-icon-button:active { background: color-mix(in srgb, var(--md-sys-color-on-surface-variant) 12%, transparent); }
.md-icon-button:disabled { cursor: default; color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent); background: transparent; }
.md-icon-button svg { width: 24px; height: 24px; fill: currentColor; }

/* Cards */
.md-card { border-radius: var(--md-sys-shape-corner-medium); background: var(--md-sys-color-surface-container-low); color: var(--md-sys-color-on-surface); padding: 16px; }
.md-card--elevated { box-shadow: var(--md-sys-elevation-level1); }
.md-card--outlined { background: var(--md-sys-color-surface); border: 1px solid var(--md-sys-color-outline-variant); }
.md-card--filled { background: var(--md-sys-color-surface-container-highest); }

/* Outlined text field. Markup: <label class="md-text-field"><span>Label</span><input></label> */
.md-text-field { display: block; margin: 0; }
.md-text-field > span { display: block; margin: 0 0 4px 4px; font: var(--md-sys-typescale-body-small); color: var(--md-sys-color-on-surface-variant); }
.md-text-field > input, .md-text-field > textarea {
  display: block; width: 100%; min-height: 48px; padding: 12px 16px;
  border: 1px solid var(--md-sys-color-outline); border-radius: var(--md-sys-shape-corner-extra-small);
  background: var(--md-sys-color-surface-container-lowest); color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-body-large); caret-color: var(--md-sys-color-primary);
}
.md-text-field > textarea { resize: vertical; min-height: 96px; }
.md-text-field > input:hover, .md-text-field > textarea:hover { border-color: var(--md-sys-color-on-surface); }
.md-text-field > input:focus, .md-text-field > textarea:focus { outline: 2px solid var(--md-sys-color-primary); outline-offset: -2px; border-color: transparent; }
.md-text-field:focus-within > span { color: var(--md-sys-color-primary); }
.md-text-field > small { display: block; margin: 4px 16px 0; font: var(--md-sys-typescale-body-small); color: var(--md-sys-color-on-surface-variant); }

/* Chips */
.md-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 16px;
  border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--md-sys-shape-corner-small);
  background: transparent; color: var(--md-sys-color-on-surface-variant); font: var(--md-sys-typescale-label-large);
}
.md-chip--warning { border-color: transparent; background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); }

/* Dialog. Use on a native <dialog> element. */
.md-dialog {
  width: min(560px, calc(100vw - 48px)); padding: 24px; border: 0;
  border-radius: var(--md-sys-shape-corner-extra-large);
  background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface);
  box-shadow: var(--md-sys-elevation-level3);
}
.md-dialog--wide { width: min(720px, calc(100vw - 48px)); max-height: calc(100vh - 48px); overflow-y: auto; }
.md-dialog::backdrop { background: var(--md-sys-color-scrim); }
.md-dialog__headline { font: var(--md-sys-typescale-headline-small); margin: 0 0 16px; }
.md-dialog__body { font: var(--md-sys-typescale-body-medium); color: var(--md-sys-color-on-surface-variant); margin: 0 0 24px; }
.md-dialog__actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Snackbar */
.md-snackbar {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  min-width: 288px; max-width: calc(100vw - 32px); padding: 14px 16px;
  border-radius: var(--md-sys-shape-corner-extra-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: var(--md-sys-elevation-level3);
}

/* List and divider */
.md-list { list-style: none; margin: 0; padding: 8px 0; }
.md-list > li { display: flex; align-items: center; gap: 16px; min-height: 56px; padding: 8px 16px; font: var(--md-sys-typescale-body-large); }
.md-divider { height: 1px; margin: 0; border: 0; background: var(--md-sys-color-outline-variant); }

/* Segmented buttons. Markup: <div class="md-segmented" role="radiogroup"><button role="radio" aria-checked="true">A</button>...</div> */
.md-segmented { display: inline-flex; border: 1px solid var(--md-sys-color-outline); border-radius: var(--md-sys-shape-corner-full); overflow: hidden; }
.md-segmented > button {
  min-height: 40px; padding: 0 16px; border: 0; border-left: 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;
}
.md-segmented > button:first-child { border-left: 0; }
.md-segmented > button:hover { background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent); }
.md-segmented > button[aria-checked="true"] { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.md-segmented > button:focus-visible { outline-offset: -3px; }

/* Slider. Markup: <label class="md-slider"><span>Label</span><input type="range"></label> */
.md-slider { display: block; }
.md-slider > span { display: block; margin: 0 0 4px 4px; font: var(--md-sys-typescale-body-small); color: var(--md-sys-color-on-surface-variant); }
.md-slider > input[type="range"] { display: block; width: 100%; height: 32px; margin: 0; accent-color: var(--md-sys-color-primary); cursor: pointer; }
