/* Material You (Material Design 3) Color Tokens - Default Dark & Optional Light */
:root,
[data-theme="dark"] {
  --md-sys-color-primary: #9ecaFF;
  --md-sys-color-on-primary: #003258;
  --md-sys-color-primary-container: #00497d;
  --md-sys-color-on-primary-container: #d1e4ff;

  --md-sys-color-secondary: #bbc7db;
  --md-sys-color-on-secondary: #253140;
  --md-sys-color-secondary-container: #3b4858;
  --md-sys-color-on-secondary-container: #d7e3f7;

  --md-sys-color-tertiary: #d6bee4;
  --md-sys-color-on-tertiary: #3b2948;
  --md-sys-color-tertiary-container: #523f5f;
  --md-sys-color-on-tertiary-container: #f2daff;

  --md-sys-color-surface: #111318;
  --md-sys-color-surface-container-low: #191c20;
  --md-sys-color-surface-container: #1d2024;
  --md-sys-color-surface-container-high: #282a2f;
  --md-sys-color-surface-container-highest: #33353a;

  --md-sys-color-on-surface: #e2e2e9;
  --md-sys-color-on-surface-variant: #c3c7cf;
  --md-sys-color-outline: #8d9199;
  --md-sys-color-outline-variant: #43474e;

  --md-sys-color-error: #ffb4ab;
  --md-sys-color-error-container: #93000a;
  --md-sys-color-on-error-container: #ffdad6;

  --md-sys-color-inverse-surface: #e2e2e9;
  --md-sys-color-inverse-on-surface: #2e3135;

  --shape-corner-small: 8px;
  --shape-corner-medium: 12px;
  --shape-corner-large: 16px;
  --shape-corner-full: 9999px;
}

[data-theme="light"] {
  --md-sys-color-primary: #0061a4;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #d1e4ff;
  --md-sys-color-on-primary-container: #001d36;

  --md-sys-color-secondary: #535f70;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #d7e3f7;
  --md-sys-color-on-secondary-container: #101c2b;

  --md-sys-color-tertiary: #6b5778;
  --md-sys-color-on-tertiary: #ffffff;
  --md-sys-color-tertiary-container: #f2daff;
  --md-sys-color-on-tertiary-container: #251431;

  --md-sys-color-surface: #f8f9ff;
  --md-sys-color-surface-container-low: #f2f3fa;
  --md-sys-color-surface-container: #eceef4;
  --md-sys-color-surface-container-high: #e6e8ee;
  --md-sys-color-surface-container-highest: #e1e2e8;

  --md-sys-color-on-surface: #191c20;
  --md-sys-color-on-surface-variant: #43474e;
  --md-sys-color-outline: #73777f;
  --md-sys-color-outline-variant: #c3c7cf;

  --md-sys-color-error: #ba1a1a;
  --md-sys-color-error-container: #ffdad6;
  --md-sys-color-on-error-container: #410002;

  --md-sys-color-inverse-surface: #2e3135;
  --md-sys-color-inverse-on-surface: #eff0f7;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Roboto', system-ui, -apple-system, sans-serif;
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.app-shell {
  max-width: 880px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top App Bar */
.top-app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 4px 20px;
}

.top-app-bar__title-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.top-app-bar__icon {
  font-size: 32px;
  color: var(--md-sys-color-on-primary-container);
  background: var(--md-sys-color-primary-container);
  padding: 10px;
  border-radius: var(--shape-corner-large);
  flex-shrink: 0;
}

.top-app-bar__title {
  font-size: 22px;
  font-weight: 500;
  line-height: 28px;
  color: var(--md-sys-color-on-surface);
}

.top-app-bar__subtitle {
  font-size: 12.5px;
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 2px;
}

.top-app-bar__subtitle a {
  color: var(--md-sys-color-primary);
  font-weight: 500;
  text-decoration: none;
}

.top-app-bar__subtitle a:hover {
  text-decoration: underline;
}

.top-app-bar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* M3 Buttons */
.m3-outlined-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border-radius: var(--shape-corner-full);
  border: 1px solid var(--md-sys-color-outline);
  background: transparent;
  color: var(--md-sys-color-primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease;
  white-space: nowrap;
}

.m3-outlined-button:hover {
  background-color: rgba(158, 202, 255, 0.12);
}

.m3-filled-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 20px;
  border-radius: var(--shape-corner-full);
  border: none;
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: box-shadow 0.15s ease, opacity 0.15s ease;
}

.m3-filled-button:hover {
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  opacity: 0.94;
}

.m3-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--shape-corner-full);
  border: none;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  flex-shrink: 0;
}

.m3-icon-button--outlined {
  width: 40px;
  height: 40px;
  border: 1px solid var(--md-sys-color-outline);
  color: var(--md-sys-color-on-surface);
}

.m3-icon-button:hover {
  background-color: rgba(226, 226, 233, 0.1);
}

/* M3 Primary Tabs */
.m3-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background-color: var(--md-sys-color-surface-container);
  border-radius: var(--shape-corner-full);
  padding: 4px;
  margin-bottom: 20px;
}

.m3-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  border: none;
  border-radius: var(--shape-corner-full);
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.m3-tab--active {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

/* M3 Cards */
.m3-card {
  border-radius: var(--shape-corner-large);
  padding: 20px;
  margin-bottom: 16px;
}

.m3-card--elevated {
  background-color: var(--md-sys-color-surface-container-low);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 1px 3px 1px rgba(0, 0, 0, 0.12);
}

.m3-card--outlined {
  background-color: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.m3-card--filled {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

/* Unified M3 Input Box */
.m3-field {
  display: flex;
  flex-direction: column;
  position: relative;
}

.m3-field__label,
.section-caption {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

.m3-input-box {
  display: flex;
  align-items: center;
  height: 48px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--shape-corner-small);
  background-color: var(--md-sys-color-surface-container-high);
  padding: 0 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

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

.m3-input-box--error {
  background-color: var(--md-sys-color-error-container);
  border-color: var(--md-sys-color-error);
}

.m3-input-box--error .m3-input {
  color: var(--md-sys-color-on-error-container);
}

.m3-input-box--error .m3-icon-button {
  color: var(--md-sys-color-on-error-container);
}

.m3-input {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  font-weight: 400;
  color: var(--md-sys-color-on-surface);
  outline: none;
}

.m3-input::placeholder {
  color: var(--md-sys-color-on-surface-variant);
  opacity: 0.6;
}

.m3-input--mono {
  font-family: 'Roboto Mono', monospace;
  font-size: 18px;
  font-weight: 700;
}

select.m3-input {
  cursor: pointer;
}

select.m3-input option {
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
}

/* Multi-select Dropdown */
.m3-multiselect {
  position: relative;
}

.m3-multiselect__trigger {
  width: 100%;
  height: 48px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--shape-corner-small);
  background-color: var(--md-sys-color-surface-container-high);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: inherit;
  font-size: 15px;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.m3-multiselect__trigger:focus,
.m3-multiselect--open .m3-multiselect__trigger {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 1px var(--md-sys-color-primary);
  outline: none;
}

.m3-multiselect__value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.m3-multiselect__value--placeholder {
  color: var(--md-sys-color-on-surface-variant);
  opacity: 0.7;
}

.m3-multiselect__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 280px;
  max-height: 260px;
  overflow-y: auto;
  background-color: var(--md-sys-color-surface-container-highest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--shape-corner-medium);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  padding: 6px;
  z-index: 40;
  display: none;
}

.m3-multiselect--open .m3-multiselect__menu {
  display: block;
}

.m3-multiselect__option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--shape-corner-small);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.35;
  color: var(--md-sys-color-on-surface);
}

.m3-multiselect__option:hover {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.m3-multiselect__option input[type="checkbox"] {
  margin-top: 2px;
  accent-color: var(--md-sys-color-primary);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.m3-multiselect__opt-code {
  font-family: 'Roboto Mono', monospace;
  font-weight: 700;
  color: var(--md-sys-color-primary);
}

/* M3 Assist Chips */
.chips-section {
  margin-top: 16px;
}

.chips-section__label {
  display: block;
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 8px;
}

.chips-section__label--warning {
  color: var(--md-sys-color-error);
  font-weight: 500;
}

.m3-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.m3-chip {
  min-height: 32px;
  padding: 4px 12px;
  border-radius: var(--shape-corner-small);
  border: 1px solid var(--md-sys-color-outline-variant);
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.m3-chip__code {
  font-family: 'Roboto Mono', monospace;
  font-weight: 700;
  color: var(--md-sys-color-primary);
}

.m3-chip:hover {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: transparent;
}

/* Basic Traits Filter (Špatné / Dobré) */
.trait-filter-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.trait-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--shape-corner-medium);
  background-color: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.trait-row__label {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
}

.trait-row__sub {
  display: block;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--md-sys-color-on-surface-variant);
}

.trait-row__toggles {
  display: inline-flex;
  border-radius: var(--shape-corner-full);
  border: 1px solid var(--md-sys-color-outline);
  overflow: hidden;
  flex-shrink: 0;
}

.trait-toggle-btn {
  height: 30px;
  padding: 0 11px;
  border: none;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.trait-toggle-btn + .trait-toggle-btn {
  border-left: 1px solid var(--md-sys-color-outline);
}

.trait-toggle-btn--bad-active {
  background-color: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
}

.trait-toggle-btn--good-active {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.trait-matches {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.trait-match-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--shape-corner-medium);
  background-color: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.trait-match-card__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.trait-match-card__title {
  font-size: 14px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
}

.trait-match-card__code {
  font-family: 'Roboto Mono', monospace;
  font-weight: 700;
  color: var(--md-sys-color-primary);
  margin-right: 6px;
}

.trait-match-card__desc {
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
}

.trait-match-card__btn {
  height: 34px;
  padding: 0 14px;
  border-radius: var(--shape-corner-full);
  border: 1px solid var(--md-sys-color-primary);
  background: transparent;
  color: var(--md-sys-color-primary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.trait-match-card__btn:hover {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.empty-criteria-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--shape-corner-medium);
  background-color: var(--md-sys-color-surface-container);
  border: 1px dashed var(--md-sys-color-outline);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 13.5px;
}

/* Interactive & Static Thermometer Control */
.thermo-control-box {
  grid-column: 1 / -1;
  padding: 14px 16px;
  border-radius: var(--shape-corner-medium);
  background-color: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.thermo-control-box__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.thermo-control-box__value {
  font-family: 'Roboto Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--md-sys-color-primary);
}

.thermo-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.thermo-pill {
  height: 30px;
  padding: 0 11px;
  border-radius: var(--shape-corner-full);
  border: 1px solid var(--md-sys-color-outline-variant);
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  font-family: 'Roboto Mono', monospace;
  font-size: 12px;
  cursor: pointer;
}

.thermo-pill--active {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border-color: var(--md-sys-color-primary);
  font-weight: 700;
}

.thermo-svg-wrap {
  width: 100%;
  overflow-x: auto;
}

.thermo-svg {
  width: 100%;
  min-width: 300px;
  max-height: 76px;
  display: block;
}

/* Form Grid in Generator */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.form-grid--spaced {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
}

/* Result Banner */
.result-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.result-banner__caption {
  display: block;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  opacity: 0.85;
}

.result-banner__code {
  font-family: 'Roboto Mono', monospace;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* Token Badges & Breakdown (Human-readable) */
.token-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.token-badge {
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  border-radius: var(--shape-corner-medium);
  background-color: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.token-badge--primary {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border-color: transparent;
}

.token-badge--secondary {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: transparent;
}

.token-badge--tertiary {
  background-color: var(--md-sys-color-tertiary-container);
  color: var(--md-sys-color-on-tertiary-container);
  border-color: transparent;
}

.token-badge__title {
  font-size: 13.5px;
  font-weight: 700;
}

.token-badge__sub {
  font-family: 'Roboto Mono', monospace;
  font-size: 11.5px;
  margin-top: 2px;
  opacity: 0.85;
}

.spec-list {
  list-style: none;
  display: grid;
  gap: 10px;
}

.spec-list__item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 10px 14px;
  border-radius: var(--shape-corner-small);
  background-color: var(--md-sys-color-surface-container);
  font-size: 14px;
}

.spec-list__key {
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 500;
  flex-shrink: 0;
}

.spec-list__val {
  color: var(--md-sys-color-on-surface);
  font-weight: 500;
  text-align: right;
}

.error-card {
  background-color: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
  border-radius: var(--shape-corner-large);
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.hidden {
  display: none !important;
}

.main-content {
  flex: 1;
}

/* Footer & AI Badge */
.app-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 0 16px;
  gap: 10px;
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
}

.app-footer__disclaimer {
  max-width: 720px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--md-sys-color-on-surface-variant);
  background-color: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--shape-corner-medium);
  padding: 10px 14px;
}

.eu-ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--shape-corner-small);
  background-color: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
}

.eu-ai-badge__icon {
  font-size: 16px;
  color: var(--md-sys-color-primary);
}

.eu-ai-badge__text {
  font-family: 'Roboto Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--md-sys-color-on-surface);
}

.app-footer__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
}

.app-footer__links a,
.app-footer__credit a {
  color: var(--md-sys-color-primary);
  font-weight: 500;
  text-decoration: none;
}

.app-footer__links a:hover,
.app-footer__credit a:hover {
  text-decoration: underline;
}

.app-footer__credit {
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
}

/* M3 Snackbar */
.m3-snackbar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background-color: var(--md-sys-color-inverse-surface);
  color: var(--md-sys-color-inverse-on-surface);
  padding: 12px 20px;
  border-radius: var(--shape-corner-small);
  font-size: 14px;
  box-shadow: 0 3px 6px rgba(0,0,0,0.3);
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
  pointer-events: none;
  z-index: 100;
}

.m3-snackbar--visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

@media (max-width: 600px) {
  .top-app-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  .m3-tab {
    font-size: 13px;
    padding: 0 8px;
  }
  .spec-list__item {
    flex-direction: column;
    gap: 2px;
  }
  .spec-list__val {
    text-align: left;
  }
  .trait-match-card {
    flex-direction: column;
    align-items: flex-start;
  }
}
