/* MaterialYou (Material 3 baseline scheme). Roboto, tonal surfaces, state layers, pill buttons. */

:root {
  --md-sys-color-primary: #6750a4;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #eaddff;
  --md-sys-color-secondary: #625b71;
  --md-sys-color-secondary-container: #e8def8;
  --md-sys-color-on-secondary-container: #1d192b;
  --md-sys-color-surface: #fef7ff;
  --md-sys-color-surface-container-low: #f7f2fa;
  --md-sys-color-surface-container-highest: #e6e0e9;
  --md-sys-color-on-surface: #1d1b20;
  --md-sys-color-on-surface-variant: #49454f;
  --md-sys-color-outline: #79747e;
  --md-sys-color-outline-variant: #cac4d0;
  --md-sys-color-inverse-surface: #322f35;
  --md-sys-color-inverse-on-surface: #f5eff7;
  --md-sys-color-inverse-primary: #d0bcff;

  --md-elevation-1: 0 1px 2px 0 rgb(0 0 0 / 0.3), 0 1px 3px 1px rgb(0 0 0 / 0.15);
  --md-elevation-3: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 4px 8px 3px rgb(0 0 0 / 0.15);
  --md-easing: cubic-bezier(0.2, 0, 0, 1);

  --icon-size: 18px;
  --icon-stroke: 2;
  --row-gap: 8px;
  --chevron-mask: var(--mask-caret);
  --chevron-size: 24px;
  --chevron-right: 12px;
  --chevron-color: var(--md-sys-color-on-surface-variant);

  --name-buttons: "Common buttons · Icon button";
  --name-form: "Outlined text field · Select · Checkbox";
  --name-switch: "Switch";
  --name-meters: "Slider · Linear progress";
  --name-tabs: "Primary tabs";
  --name-profile: "Elevated card · Badge";
  --name-filters: "Filter chip · Radio button";
  --name-toast: "Snackbar";
}

:root[data-theme="dark"] {
  --md-sys-color-primary: #d0bcff;
  --md-sys-color-on-primary: #381e72;
  --md-sys-color-primary-container: #4f378b;
  --md-sys-color-secondary: #ccc2dc;
  --md-sys-color-secondary-container: #4a4458;
  --md-sys-color-on-secondary-container: #e8def8;
  --md-sys-color-surface: #141218;
  --md-sys-color-surface-container-low: #1d1b20;
  --md-sys-color-surface-container-highest: #36343b;
  --md-sys-color-on-surface: #e6e0e9;
  --md-sys-color-on-surface-variant: #cac4d0;
  --md-sys-color-outline: #938f99;
  --md-sys-color-outline-variant: #49454f;
  --md-sys-color-inverse-surface: #e6e0e9;
  --md-sys-color-inverse-on-surface: #322f35;
  --md-sys-color-inverse-primary: #6750a4;
}

body {
  color: var(--md-sys-color-on-surface);
  font: 400 14px/20px Roboto, system-ui, sans-serif;
  letter-spacing: 0.25px;
}

/* State layers: an inset tint of the content colour, 8% on hover, 10% when pressed or focused. */
.btn,
.icon-btn,
.chip,
.toast__action {
  --state: 0%;
  box-shadow: inset 0 0 0 100vmax color-mix(in srgb, currentColor var(--state), transparent);
  transition: box-shadow 0.2s var(--md-easing), background-color 0.2s var(--md-easing);
}

:is(.btn, .icon-btn, .chip, .toast__action):hover {
  --state: 8%;
}

:is(.btn, .icon-btn, .chip, .toast__action):is(:active, :focus-visible) {
  --state: 10%;
}

:focus-visible {
  outline: 3px solid var(--md-sys-color-secondary);
  outline-offset: 2px;
}

.card {
  padding: 16px;
  border-radius: 12px;
  background: var(--md-sys-color-surface-container-low);
  box-shadow: var(--md-elevation-1);
}

.card > * + * {
  margin-top: 16px;
}

.card--flush {
  padding: 0;
}

.title {
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
  letter-spacing: 0.15px;
}

.meta {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0.4px;
}

/* ---------- Buttons ---------- */

.btn {
  gap: 8px;
  height: 40px;
  padding: 0 24px;
  border: 0;
  border-radius: 20px;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: 0.1px;
}

.btn:has(.icon) {
  padding-left: 16px;
}

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

.btn--primary:hover {
  box-shadow:
    inset 0 0 0 100vmax color-mix(in srgb, currentColor var(--state), transparent),
    var(--md-elevation-1);
}

.btn--secondary {
  outline: 1px solid var(--md-sys-color-outline);
  outline-offset: -1px;
  color: var(--md-sys-color-primary);
}

.btn--secondary:focus-visible {
  outline: 3px solid var(--md-sys-color-secondary);
  outline-offset: 2px;
}

.btn--secondary[aria-pressed="true"] {
  outline-color: transparent;
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.btn--ghost {
  padding: 0 12px;
  color: var(--md-sys-color-primary);
}

.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  --icon-size: 24px;
}

.icon-btn[aria-pressed="true"] {
  color: var(--md-sys-color-primary);
}

.icon-btn[aria-pressed="true"] .icon {
  fill: currentColor;
}

/* ---------- Switch ---------- */

.list-row {
  min-height: 48px;
  font-size: 16px;
  line-height: 24px;
  letter-spacing: 0.5px;
}

.card > .list-row + .list-row {
  margin-top: 4px;
}

.switch {
  width: 52px;
  height: 32px;
  border: 2px solid var(--md-sys-color-outline);
  border-radius: 16px;
  background: var(--md-sys-color-surface-container-highest);
  transition: background-color 0.2s var(--md-easing), border-color 0.2s var(--md-easing);
}

/* Handle */
.switch::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 14px;
  z-index: 1;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--md-sys-color-outline);
  translate: -50% -50%;
  transition: left 0.3s var(--md-easing), width 0.2s var(--md-easing), height 0.2s var(--md-easing), background-color 0.2s;
}

/* State layer */
.switch::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 14px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--md-sys-color-on-surface);
  opacity: 0;
  translate: -50% -50%;
  transition: left 0.3s var(--md-easing), opacity 0.2s;
}

.switch:hover::before {
  background: var(--md-sys-color-on-surface-variant);
}

.switch:hover::after {
  opacity: 0.08;
}

.switch:active::before {
  width: 28px;
  height: 28px;
}

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

.switch:checked::before,
.switch:checked::after {
  left: 34px;
}

.switch:checked::before {
  width: 24px;
  height: 24px;
  background: var(--md-sys-color-on-primary);
}

.switch:checked:hover::before {
  background: var(--md-sys-color-primary-container);
}

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

.switch:checked:active::before {
  width: 28px;
  height: 28px;
}

/* ---------- Outlined text field + select ---------- */

.field {
  position: relative;
}

.field__label {
  position: absolute;
  top: 0;
  left: 12px;
  z-index: 1;
  padding: 0 4px;
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0.4px;
  translate: 0 -50%;
}

.field:focus-within .field__label {
  color: var(--md-sys-color-primary);
}

.input,
.select select {
  width: 100%;
  height: 56px;
  padding: 0 16px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: 4px;
  outline: 0;
  background: transparent;
  font-size: 16px;
  line-height: 24px;
  letter-spacing: 0.5px;
}

.select select {
  padding-right: 48px;
}

.input:hover,
.select select:hover {
  border-color: var(--md-sys-color-on-surface);
}

.input:focus,
.select select:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: inset 0 0 0 1px var(--md-sys-color-primary);
}

/* ---------- Checkbox + radio, with 40px state layers ---------- */

.check {
  gap: 14px;
  min-height: 40px;
  padding-left: 11px;
  font-size: 16px;
  line-height: 24px;
  letter-spacing: 0.5px;
}

.card > .check {
  margin-top: 4px;
}

.checkbox {
  width: 18px;
  height: 18px;
  border: 2px solid var(--md-sys-color-on-surface-variant);
  border-radius: 2px;
}

.radio {
  width: 20px;
  height: 20px;
  margin-left: -1px;
  border: 2px solid var(--md-sys-color-on-surface-variant);
  border-radius: 50%;
}

.checkbox::after,
.radio::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--md-sys-color-on-surface);
  opacity: 0;
  translate: -50% -50%;
  transition: opacity 0.2s;
}

:is(.checkbox, .radio):hover::after {
  opacity: 0.08;
}

:is(.checkbox, .radio):checked::after {
  background: var(--md-sys-color-primary);
}

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

.checkbox:checked::before {
  content: "";
  position: absolute;
  inset: -2px;
  background: var(--md-sys-color-on-primary);
  mask: var(--mask-check) center / 14px no-repeat;
}

.radio:checked {
  border-color: var(--md-sys-color-primary);
  background: radial-gradient(circle, var(--md-sys-color-primary) 0 4.6px, transparent 5px);
}

/* ---------- Filter chips + radio group ---------- */

.chip {
  gap: 8px;
  height: 32px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  outline: 1px solid var(--md-sys-color-outline-variant);
  outline-offset: -1px;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: 0.1px;
}

.chip[aria-pressed="true"] {
  padding-left: 8px;
  outline-color: transparent;
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.chip[aria-pressed="true"]::before {
  content: "";
  width: 18px;
  height: 18px;
  background: currentColor;
  mask: var(--mask-check-thin) center / contain no-repeat;
}

.group__label {
  margin-bottom: 4px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: 0.1px;
}

/* ---------- Slider + linear progress ---------- */

.meter {
  gap: 4px;
}

.meter__label {
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: 0.1px;
}

.slider {
  height: 40px;
}

.slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--md-sys-color-primary) var(--val), var(--md-sys-color-surface-container-highest) var(--val));
}

.slider::-webkit-slider-thumb {
  width: 20px;
  height: 20px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--md-sys-color-primary);
  -webkit-appearance: none;
  transition: box-shadow 0.2s;
}

.slider:hover::-webkit-slider-thumb {
  box-shadow: 0 0 0 10px color-mix(in srgb, var(--md-sys-color-primary) 8%, transparent);
}

.slider::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--md-sys-color-surface-container-highest);
}

.slider::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--md-sys-color-primary);
}

.slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: var(--md-sys-color-primary);
}

.progress {
  height: 4px;
  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-color-primary);
}

.progress::-moz-progress-bar {
  background: var(--md-sys-color-primary);
}

/* ---------- Primary tabs ---------- */

.tabs {
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.tab {
  --state: 0%;
  flex: 1;
  height: 48px;
  padding: 0 16px;
  border: 0;
  background: transparent;
  box-shadow: inset 0 0 0 100vmax color-mix(in srgb, currentColor var(--state), transparent);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: 0.1px;
}

.tab:first-child {
  border-top-left-radius: 12px;
}

.tab:last-child {
  border-top-right-radius: 12px;
}

.tab:hover {
  --state: 8%;
}

.tab:focus-visible {
  outline-offset: -3px;
}

.tab span {
  position: relative;
  display: inline-block;
}

.tab[aria-selected="true"] {
  color: var(--md-sys-color-primary);
}

.tab[aria-selected="true"] span::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -14px;
  left: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--md-sys-color-primary);
}

.tabpanel {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.token__chip {
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--md-sys-color-outline-variant);
}

.token__chip[data-token="primary"] { background: var(--md-sys-color-primary); }
.token__chip[data-token="surface"] { background: var(--md-sys-color-surface); }
.token__chip[data-token="outline"] { background: var(--md-sys-color-outline); }
code[data-token="primary"]::before { content: "--md-sys-color-primary"; }
code[data-token="surface"]::before { content: "--md-sys-color-surface"; }
code[data-token="outline"]::before { content: "--md-sys-color-outline"; }

.type-sample {
  font-size: 36px;
  line-height: 44px;
}

[data-type-name]::before {
  content: "Roboto · Body large 16/24";
}

.shape-sample {
  width: 72px;
  height: 48px;
  border-radius: 12px;
  background: var(--md-sys-color-primary-container);
}

[data-shape-name]::before {
  content: "Corner medium · 12dp";
}

/* ---------- Card, avatar, badge ---------- */

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.badge {
  height: 24px;
  padding: 0 8px;
  border-radius: 8px;
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  letter-spacing: 0.5px;
}

.badge--subtle {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface-variant);
}

/* ---------- Snackbar ---------- */

.toast {
  min-height: 48px;
  padding: 4px 8px 4px 16px;
  border-radius: 4px;
  background: var(--md-sys-color-inverse-surface);
  box-shadow: var(--md-elevation-3);
  color: var(--md-sys-color-inverse-on-surface);
}

.toast__action {
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 20px;
  background: transparent;
  color: var(--md-sys-color-inverse-primary);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
}
