@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

:root {
  /* Conservice Brand Colors */
  --c-green: #77bc1f;
  --c-dark-green: #4f9400;
  --c-blue: #2b7bb9;
  --c-slate: #243746;
  --c-slate-light: #435b6f;

  /* Material 3 Mapped to Conservice */
  --md-sys-color-primary: var(--c-dark-green);
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: var(--c-green);
  --md-sys-color-on-primary-container: #ffffff;

  --md-sys-color-secondary: var(--c-blue);
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #c4e4ff;
  --md-sys-color-on-secondary-container: #001d35;

  --md-sys-color-surface: #f9fafc;
  --md-sys-color-on-surface: var(--c-slate);
  --md-sys-color-surface-variant: #e0e6eb;
  --md-sys-color-on-surface-variant: var(--c-slate-light);

  --md-sys-color-outline: #757575;
  --md-sys-color-outline-variant: #c4c7c5;

  --md-sys-color-surface-container-lowest: #ffffff;
  --md-sys-color-surface-container-low: #f4f6f8;
  --md-sys-color-surface-container: #eaedf1;
  --md-sys-color-surface-container-high: #e2e6eb;
  --md-sys-color-surface-container-highest: #dde2e8;

  /* Shapes */
  --md-sys-shape-corner-medium: 8px;
  /* Conservice is slightly less rounded than M3 */
  --md-sys-shape-corner-large: 12px;
  --md-sys-shape-corner-extra-large: 16px;
  --md-sys-shape-corner-full: 9999px;

  /* Shadows (Elevation) */
  --md-sys-elevation-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.1), 0 1px 3px 1px rgba(0, 0, 0, 0.05);
  --md-sys-elevation-md: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 3px 8px 2px rgba(0, 0, 0, 0.05);
  --md-sys-elevation-lg: 0 4px 8px 3px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.05);

  --md-sys-motion-easing: cubic-bezier(0.2, 0, 0, 1);
  --md-sys-motion-duration: 250ms;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --md-sys-color-primary: var(--c-green);
  --md-sys-color-on-primary: #121c24;
  --md-sys-color-primary-container: var(--c-dark-green);
  --md-sys-color-on-primary-container: #ffffff;

  --md-sys-color-secondary: var(--c-blue);
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #1b4b73;
  --md-sys-color-on-secondary-container: #c4e4ff;

  --md-sys-color-surface: #0a1014;
  --md-sys-color-on-surface: #e5eceb;
  --md-sys-color-surface-variant: #243440;
  --md-sys-color-on-surface-variant: #b0c0ce;

  --md-sys-color-outline: #46484a;

  --md-sys-color-surface-container-lowest: #06090c;
  --md-sys-color-surface-container-low: #0f151b;
  --md-sys-color-surface-container: #131b21;
  --md-sys-color-surface-container-high: #18232b;
  --md-sys-color-surface-container-highest: #1f2b34;

  color-scheme: dark;
}

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

body {
  font-family: 'Roboto', sans-serif;
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--md-sys-motion-duration) var(--md-sys-motion-easing),
    color var(--md-sys-motion-duration) var(--md-sys-motion-easing);
}

/* App Bar */
.app-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background-color: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 2px solid var(--c-green);
  transition: background-color var(--md-sys-motion-duration) var(--md-sys-motion-easing);
  box-shadow: var(--md-sys-elevation-sm);
}

:root[data-theme="dark"] .app-bar {
  background-color: var(--md-sys-color-surface-container);
}

.title {
  font-size: 20px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
  letter-spacing: 0;
}

.app-bar .theme-toggle {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
  background-color: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface-variant);
}

:root[data-theme="dark"] .app-bar .theme-toggle {
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
}

.app-bar .theme-toggle:hover:not(.active) {
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
}

:root[data-theme="dark"] .app-bar .theme-toggle:hover:not(.active) {
  background-color: var(--md-sys-color-surface-container-highest);
}

.actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Icon Button (Toggle) */
.theme-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--md-sys-color-on-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: var(--md-sys-shape-corner-full);
  transition: background-color 0.2s ease, transform 0.2s;
}

.theme-toggle:hover {
  background-color: var(--md-sys-color-surface-variant);
  transform: scale(1.05);
}

.theme-toggle:active {
  background-color: color-mix(in srgb, var(--md-sys-color-surface-variant) 80%, black);
}

.theme-toggle.active {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.theme-toggle.active:hover {
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 85%, black);
}

:root[data-theme="dark"] .theme-toggle.active:hover {
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 85%, white);
}

/* Main Container */
.container {
  display: flex;
  flex-direction: row;
  padding: 32px 24px;
  gap: 24px;
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 800px) {
  .container {
    flex-direction: column;
    padding: 16px;
  }
}

/* Cards */
.card {
  background-color: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--md-sys-shape-corner-extra-large);
  padding: 24px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 400px;
  box-shadow: var(--md-sys-elevation-md);
  border: 1px solid var(--md-sys-color-surface-variant);
  transition: background-color var(--md-sys-motion-duration) var(--md-sys-motion-easing), box-shadow 0.2s;
}

.card:hover {
  box-shadow: var(--md-sys-elevation-lg);
}

:root[data-theme="dark"] .card {
  background-color: var(--md-sys-color-surface-container);
  border-color: transparent;
  box-shadow: var(--md-sys-elevation-sm);
}

.card-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}

.card-header h2 {
  font-size: 20px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
}

.space-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  color: var(--md-sys-color-on-surface-variant);
}

.space-toggle-label {
  font-size: 14px;
  font-weight: 500;
}

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

.switch {
  position: relative;
  width: 52px;
  height: 32px;
  flex-shrink: 0;
  border-radius: var(--md-sys-shape-corner-full);
  background-color: var(--md-sys-color-surface-container-highest);
  border: 2px solid var(--md-sys-color-outline);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 6px;
  width: 16px;
  height: 16px;
  border-radius: var(--md-sys-shape-corner-full);
  background-color: var(--md-sys-color-outline);
  transform: translateY(-50%);
  transition: left 0.2s var(--md-sys-motion-easing), width 0.2s var(--md-sys-motion-easing),
    height 0.2s var(--md-sys-motion-easing), background-color 0.2s ease;
}

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

.space-toggle-input:checked + .switch::after {
  left: 22px;
  width: 24px;
  height: 24px;
  background-color: var(--md-sys-color-on-primary);
}

.space-toggle-input:focus-visible + .switch {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

.space-toggle:hover .switch {
  background-color: color-mix(in srgb, var(--md-sys-color-surface-container-highest) 80%, var(--md-sys-color-on-surface));
}

.space-toggle:hover .space-toggle-input:checked + .switch {
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 85%, black);
  border-color: color-mix(in srgb, var(--md-sys-color-primary) 85%, black);
}

:root[data-theme="dark"] .space-toggle:hover .space-toggle-input:checked + .switch {
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 85%, white);
  border-color: color-mix(in srgb, var(--md-sys-color-primary) 85%, white);
}

.card-header .icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 16%, var(--md-sys-color-surface-container));
  color: var(--md-sys-color-primary);
}

:root[data-theme="dark"] .card-header .icon {
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 18%, var(--md-sys-color-surface-container-high));
}

.card-header .icon .material-symbols-outlined {
  font-size: 22px;
  line-height: 1;
  width: 22px;
  height: 22px;
  display: block;
  text-align: center;
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

.subtitle {
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 24px;
}

/* Textareas */
.textarea-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
}

textarea {
  width: 100%;
  flex: 1;
  background-color: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  padding: 16px;
  font-family: 'Roboto Mono', monospace;
  font-size: 16px;
  line-height: 1.5;
  color: var(--md-sys-color-on-surface);
  resize: none;
  transition: border-color var(--md-sys-motion-duration) var(--md-sys-motion-easing),
    box-shadow var(--md-sys-motion-duration) var(--md-sys-motion-easing);
  min-height: 300px;
}

textarea:focus {
  outline: none;
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--md-sys-color-primary) 30%, transparent);
}

:root[data-theme="dark"] textarea {
  background-color: var(--md-sys-color-surface-container-highest);
  border-color: var(--md-sys-color-outline);
}

textarea::placeholder {
  color: var(--md-sys-color-outline);
}

.output-section {
  container-type: inline-size;
}

.output-section textarea {
  background-color: var(--md-sys-color-surface-container);
  border-color: transparent;
}

.bill-output {
  background-color: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-corner-large);
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

:root[data-theme="dark"] .bill-output {
  background-color: var(--md-sys-color-surface-container-highest);
  border: 1px solid var(--md-sys-color-outline);
}

@container (max-width: 460px) {
  .space-toggle {
    flex: 1 0 100%;
    margin-left: 0;
    justify-content: space-between;
  }
}

.output-section textarea:focus {
  border-color: var(--md-sys-color-primary);
}

/* FAB */
.fab {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: var(--md-sys-shape-corner-full);
  /* Circular like most traditional FABs */
  border: none;
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--md-sys-elevation-md);
  transition: box-shadow var(--md-sys-motion-duration) var(--md-sys-motion-easing),
    background-color 0.2s,
    transform 0.1s;
}

.fab .material-symbols-outlined {
  font-size: 28px;
}

.fab:hover {
  box-shadow: var(--md-sys-elevation-lg);
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 85%, black);
  transform: translateY(-2px);
}

:root[data-theme="dark"] .fab:hover {
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 85%, white);
}

.fab:active {
  box-shadow: var(--md-sys-elevation-sm);
  transform: translateY(0);
}

/* Snackbar */
.snackbar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background-color: var(--md-sys-color-on-surface);
  color: var(--md-sys-color-surface);
  padding: 14px 20px;
  border-radius: var(--md-sys-shape-corner-medium);
  font-size: 15px;
  font-weight: 500;
  box-shadow: var(--md-sys-elevation-md);
  transition: transform var(--md-sys-motion-duration) var(--md-sys-motion-easing), opacity var(--md-sys-motion-duration) var(--md-sys-motion-easing);
  opacity: 0;
  z-index: 100;
  display: flex;
  align-items: center;
}

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

/* Animations */
@keyframes spin {
  0% {
    transform: rotate(0deg) scale(1);
    opacity: 0.5;
  }

  50% {
    transform: rotate(180deg) scale(1.3);
    opacity: 1;
  }

  100% {
    transform: rotate(360deg) scale(1);
    opacity: 1;
  }
}

.animate-spin {
  animation: spin 0.4s var(--md-sys-motion-easing);
}

@keyframes pop {
  0% {
    transform: scale(1);
  }

  40% {
    transform: scale(1.15);
  }

  80% {
    transform: scale(0.95);
  }

  100% {
    transform: scale(1);
  }
}

.animate-pop {
  animation: pop 0.4s var(--md-sys-motion-easing);
}

/* Flyover Menu */
.app-bar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: var(--md-sys-color-on-surface);
  z-index: 200;
  opacity: 0.3;
  transition: opacity 0.3s ease;
}

.nav-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.flyover-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 320px;
  max-width: 86vw;
  height: 100vh;
  background-color: var(--md-sys-color-surface-container-lowest);
  z-index: 210;
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.3s var(--md-sys-motion-easing);
  box-shadow: var(--md-sys-elevation-lg);
  border-right: 1px solid var(--md-sys-color-surface-variant);
}

:root[data-theme="dark"] .flyover-menu {
  background-color: var(--md-sys-color-surface-container);
  border-right-color: transparent;
}

.flyover-menu.hidden {
  transform: translateX(-100%);
}

.flyover-header {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 20px;
  border-bottom: 2px solid var(--c-green);
}

.flyover-header .theme-toggle {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
  background-color: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface-variant);
}

:root[data-theme="dark"] .flyover-header .theme-toggle {
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
}

.flyover-header .theme-toggle:hover {
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
}

:root[data-theme="dark"] .flyover-header .theme-toggle:hover {
  background-color: var(--md-sys-color-surface-container-highest);
}

.flyover-title {
  font-size: 20px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
}

.flyover-content {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 10px;
  text-decoration: none;
  color: var(--md-sys-color-on-surface);
  border-radius: 14px;
  font-size: 15px;
  font-weight: 500;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.nav-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 16%, var(--md-sys-color-surface-container));
  color: var(--md-sys-color-primary);
}

:root[data-theme="dark"] .nav-icon {
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 18%, var(--md-sys-color-surface-container-high));
}

.nav-icon .material-symbols-outlined {
  font-size: 20px;
  line-height: 1;
  width: 20px;
  height: 20px;
  display: block;
  text-align: center;
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

.nav-label {
  min-width: 0;
  line-height: 1.3;
}

.nav-external {
  margin-left: auto;
  font-size: 16px;
  width: 16px;
  height: 16px;
  line-height: 1;
  color: var(--md-sys-color-outline);
}

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

:root[data-theme="dark"] .nav-item:hover {
  background-color: var(--md-sys-color-surface-container-high);
}

.nav-item.active {
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 12%, var(--md-sys-color-surface-container-lowest));
}

:root[data-theme="dark"] .nav-item.active {
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 16%, var(--md-sys-color-surface-container-high));
}

.nav-item.active .nav-icon {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.flyover-footer {
  padding: 20px;
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
  text-align: left;
  border-top: 1px solid var(--md-sys-color-surface-variant);
}

:root[data-theme="dark"] .flyover-footer {
  border-top-color: var(--md-sys-color-surface-container-high);
}

.flyover-footer p {
  margin-bottom: 4px;
}

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

.changelog-container {
  flex-direction: column;
  max-width: 800px;
}

.changelog-card {
  min-height: 0;
}

.release {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.release + .release {
  margin-top: 28px;
  padding-top: 28px;
  border-top: 1px solid var(--md-sys-color-surface-variant);
}

.release-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.release-meta h3 {
  font-size: 22px;
  font-weight: 700;
}

.release time,
.release-credit {
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
}

.release h4 {
  font-size: 16px;
  font-weight: 700;
  margin-top: 4px;
}

.release p,
.release li {
  font-size: 15px;
  line-height: 1.55;
}

.release ul {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-left: 20px;
}

.release code {
  font-family: 'Roboto Mono', ui-monospace, monospace;
  font-size: 13px;
  background-color: var(--md-sys-color-surface-container);
  padding: 2px 6px;
  border-radius: 4px;
}

/* DNA Converter Specifics */
.manual-generate {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  transition: all 0.2s ease;
}
.manual-generate:hover {
  background-color: color-mix(in srgb, var(--md-sys-color-primary-container) 85%, black);
}

.output-links {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.output-links a {
  display: flex;
  align-items: center;
  color: var(--md-sys-color-secondary);
  text-decoration: none;
  word-break: break-all;
  font-family: 'Roboto Mono', monospace;
  font-size: 14px;
  padding: 14px 16px;
  background-color: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  transition: all 0.2s;
  box-shadow: var(--md-sys-elevation-sm);
}

.output-links a:hover {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: var(--md-sys-color-primary);
  box-shadow: var(--md-sys-elevation-md);
  transform: translateY(-1px);
}

.output-links .error {
  color: #ba1a1a;
  background-color: #ffdad6; 
  padding: 14px 16px;
  border-radius: var(--md-sys-shape-corner-medium);
  font-size: 14px;
  border: 1px solid #ffb4ab;
}

:root[data-theme="dark"] .output-links .error {
  background-color: #93000a;
  color: #ffdad6;
  border-color: #690005;
}

/* Entrata XML Parser */
.xml-container {
  flex-direction: column;
  max-width: 1400px;
}

.xml-controls {
  min-height: 0;
  flex: 0 0 auto;
  border-color: transparent;
}

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

.xml-upload {
  width: 100%;
  border: 2px dashed var(--md-sys-color-surface-container-highest);
  background-color: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-sys-shape-corner-large);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--md-sys-color-on-surface);
  font-family: inherit;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.xml-upload .material-symbols-outlined {
  font-size: 40px;
  color: var(--md-sys-color-primary);
}

.xml-upload-title {
  font-weight: 500;
  font-size: 16px;
}

.xml-upload-hint {
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
}

.xml-upload:hover,
.xml-upload.dragover,
.xml-upload:focus-visible {
  background-color: var(--md-sys-color-surface-container-high);
  border-color: var(--md-sys-color-primary);
  outline: none;
}

.xml-filters {
  display: flex;
  gap: 16px;
  width: 100%;
  margin-top: 20px;
}

.xml-search,
.xml-select {
  position: relative;
  display: flex;
  align-items: center;
}

.xml-search {
  flex: 2;
}

.xml-select {
  flex: 1;
  min-width: 220px;
}

.xml-search .material-symbols-outlined,
.xml-select .material-symbols-outlined {
  position: absolute;
  left: 16px;
  color: var(--md-sys-color-outline);
  pointer-events: none;
}

.xml-select-chevron {
  left: auto !important;
  right: 14px;
}

.xml-search-input,
.xml-property-select {
  width: 100%;
  height: 52px;
  padding: 0 16px 0 48px;
  background-color: var(--md-sys-color-surface-container);
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  font-family: inherit;
  font-size: 16px;
  color: var(--md-sys-color-on-surface);
  outline: none;
  box-sizing: border-box;
}

.xml-property-select {
  appearance: none;
  padding-right: 44px;
  cursor: pointer;
}

.xml-search-input:focus,
.xml-property-select:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--md-sys-color-primary) 30%, transparent);
}

.xml-search-input:disabled,
.xml-property-select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.xml-unmapped-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  height: 52px;
  padding: 0 16px;
  border-radius: var(--md-sys-shape-corner-full);
  background-color: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.xml-unmapped-toggle[hidden] {
  display: none;
}

.xml-unmapped-toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--md-sys-color-primary);
  cursor: pointer;
}

.xml-status {
  display: none;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--md-sys-shape-corner-medium);
  font-size: 14px;
}

.xml-status.success,
.xml-status.error {
  display: flex;
}

.xml-status.success {
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 16%, var(--md-sys-color-surface-container-low));
  color: var(--md-sys-color-on-surface);
  border: none;
}

.xml-status.error {
  color: #ba1a1a;
  background-color: #ffdad6;
  border: 1px solid #ffb4ab;
}

:root[data-theme="dark"] .xml-status.error {
  background-color: #93000a;
  color: #ffdad6;
  border-color: #690005;
}

.xml-tabs {
  display: none;
  gap: 8px;
  flex-wrap: wrap;
}

.xml-tabs.visible {
  display: flex;
}

.xml-tab {
  background: none;
  border: none;
  color: var(--md-sys-color-on-surface-variant);
  padding: 12px 18px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  border-radius: var(--md-sys-shape-corner-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.xml-tab .material-symbols-outlined {
  font-size: 20px;
}

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

.xml-tab.active {
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 12%, transparent);
  color: var(--md-sys-color-primary);
  font-weight: 700;
}

.xml-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
  gap: 20px;
  width: 100%;
}

.xml-results.xml-hidden {
  display: none;
}

.xml-results-title {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.xml-card {
  background-color: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--md-sys-shape-corner-extra-large);
  padding: 20px;
  border: none;
  box-shadow: var(--md-sys-elevation-md);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.xml-card:hover {
  box-shadow: var(--md-sys-elevation-lg);
}

.xml-card-name {
  font-size: 18px;
  font-weight: 500;
  line-height: 1.3;
}

.xml-pills,
.xml-properties {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.xml-pill {
  background-color: var(--md-sys-color-surface-container);
  border: none;
  border-radius: var(--md-sys-shape-corner-medium);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.xml-pill b {
  color: var(--md-sys-color-on-surface);
  font-weight: 500;
  text-align: right;
  word-break: break-word;
}

.xml-properties-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--md-sys-color-primary);
}

.xml-properties-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 120px;
  overflow-y: auto;
}

.xml-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  font-size: 12px;
  padding: 4px 10px;
}

.xml-chip-id {
  color: var(--md-sys-color-primary);
  font-weight: 700;
}

.xml-button-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.xml-copy-btn {
  flex: 1;
  min-width: 140px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  border: none;
  padding: 12px 14px;
  border-radius: var(--md-sys-shape-corner-full);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.xml-copy-btn .material-symbols-outlined {
  font-size: 18px;
}

.xml-copy-btn:hover {
  background-color: var(--md-sys-color-surface-container-highest);
}

.xml-copy-btn:active {
  transform: scale(0.97);
}

.xml-copy-btn.copied,
.xml-copy-btn.copied:hover {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.xml-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 32px 16px;
  color: var(--md-sys-color-outline);
  font-size: 16px;
}

.xml-loading {
  position: fixed;
  inset: 0;
  background-color: color-mix(in srgb, var(--md-sys-color-surface) 88%, transparent);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 300;
  gap: 16px;
}

.xml-loading[hidden] {
  display: none;
}

.xml-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--md-sys-color-surface-container-high);
  border-top-color: var(--md-sys-color-primary);
  border-radius: 50%;
  animation: xml-spin 0.8s linear infinite;
}

.xml-loading-text {
  font-size: 16px;
  font-weight: 500;
}

@keyframes xml-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 800px) {
  .xml-filters {
    flex-direction: column;
  }

  .xml-select {
    min-width: 0;
  }
}

:root[data-theme="dark"] .xml-controls,
:root[data-theme="dark"] .xml-card {
  background-color: var(--md-sys-color-surface-container);
}

:root[data-theme="dark"] .xml-upload {
  background-color: var(--md-sys-color-surface-container-low);
  border-color: var(--md-sys-color-surface-variant);
}

:root[data-theme="dark"] .xml-upload:hover,
:root[data-theme="dark"] .xml-upload.dragover,
:root[data-theme="dark"] .xml-upload:focus-visible {
  background-color: var(--md-sys-color-surface-container-high);
}

:root[data-theme="dark"] .xml-search-input,
:root[data-theme="dark"] .xml-property-select {
  background-color: var(--md-sys-color-surface-container-highest);
  box-shadow: inset 0 0 0 1px var(--md-sys-color-outline);
}

:root[data-theme="dark"] .xml-pill,
:root[data-theme="dark"] .xml-chip {
  background-color: var(--md-sys-color-surface-container-high);
}

:root[data-theme="dark"] .xml-copy-btn {
  background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 10%, var(--md-sys-color-surface-container-high));
}

:root[data-theme="dark"] .xml-copy-btn:hover {
  background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 16%, var(--md-sys-color-surface-container-high));
}

:root[data-theme="dark"] .xml-copy-btn.copied,
:root[data-theme="dark"] .xml-copy-btn.copied:hover {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

/* MRI URL Builder */
.mri-container {
  flex-direction: column;
  max-width: 1000px;
}

.mri-card {
  min-height: 0;
  flex: 0 0 auto;
}

.mri-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.mri-field {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mri-field-wide {
  grid-column: 1 / -1;
}

.mri-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  transition: color 0.2s ease;
}

.mri-field input,
.mri-field select,
.mri-output textarea {
  width: 100%;
  background-color: var(--md-sys-color-surface-container);
  background-image: linear-gradient(var(--md-sys-color-primary), var(--md-sys-color-primary));
  background-size: 0% 2px;
  background-position: center bottom;
  background-repeat: no-repeat;
  border: none;
  border-bottom: 1px solid var(--md-sys-color-on-surface-variant);
  border-radius: 4px 4px 0 0;
  color: var(--md-sys-color-on-surface);
  font-family: inherit;
  font-size: 16px;
  outline: none;
  box-shadow: none;
  transition: background-color 0.2s ease, background-size 0.3s ease, border-color 0.2s ease;
}

.mri-field input,
.mri-field select {
  height: 52px;
  padding: 0 16px;
}

.mri-field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 44px;
  cursor: pointer;
  color-scheme: light;
  background-image: none;
  background-color: #eaedf1;
  color: #243746;
}

:root[data-theme="dark"] .mri-field input,
:root[data-theme="dark"] .mri-output textarea {
  background-color: var(--md-sys-color-surface-container-highest);
}

:root[data-theme="dark"] .mri-field select {
  color-scheme: dark;
  background-color: #1f2b34;
  color: #e5eceb;
}

.mri-field select option {
  background-color: #eaedf1;
  color: #243746;
}

:root[data-theme="dark"] .mri-field select option {
  background-color: #131b21;
  color: #e5eceb;
}

.mri-field select option:disabled {
  color: #435b6f;
}

:root[data-theme="dark"] .mri-field select option:disabled {
  color: #b0c0ce;
}

.mri-field select option:checked {
  background-color: #d7edc0;
  color: #243746;
}

:root[data-theme="dark"] .mri-field select option:checked {
  background-color: #1f2b34;
  color: #e5eceb;
}

.mri-field:has(select)::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background-color: var(--md-sys-color-primary);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.3s ease;
  pointer-events: none;
}

.mri-field:has(select):focus-within::after,
.mri-field.error:has(select)::after {
  transform: scaleX(1);
}

.mri-field.error:has(select)::after {
  background-color: #e37a73;
}

:root[data-theme="dark"] .mri-field.error:has(select)::after {
  background-color: #f2b8b5;
}

.mri-chevron {
  position: absolute;
  right: 14px;
  bottom: 14px;
  color: var(--md-sys-color-on-surface-variant);
  pointer-events: none;
  transition: color 0.2s ease;
}

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

.mri-field input:focus,
.mri-field select:focus,
.mri-output textarea:focus {
  background-size: 100% 2px;
  border-bottom-color: transparent;
  box-shadow: none;
}

.mri-field.error label,
.mri-field.error .mri-chevron {
  color: #8c1d18;
}

.mri-field.error input,
.mri-field.error input:focus {
  background-color: rgba(140, 29, 24, 0.08);
  background-image: linear-gradient(#e37a73, #e37a73);
  background-size: 100% 2px;
  border-bottom-color: transparent;
  box-shadow: none;
  color: var(--md-sys-color-on-surface);
}

:root[data-theme="dark"] .mri-field.error label,
:root[data-theme="dark"] .mri-field.error .mri-chevron {
  color: #f2b8b5;
}

:root[data-theme="dark"] .mri-field.error input,
:root[data-theme="dark"] .mri-field.error input:focus {
  background-color: rgba(140, 29, 24, 0.2);
  background-image: linear-gradient(#f2b8b5, #f2b8b5);
  background-size: 100% 2px;
  border-bottom-color: transparent;
  box-shadow: none;
  color: var(--md-sys-color-on-surface);
}

.mri-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

.mri-generate {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 12px 24px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.mri-generate:hover {
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 85%, black);
}

:root[data-theme="dark"] .mri-generate:hover {
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 85%, white);
}

.mri-generate:active {
  transform: scale(0.97);
}

.mri-output {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--md-sys-color-surface-variant);
}

.mri-output[hidden] {
  display: none;
}

.mri-output h3 {
  font-size: 16px;
  font-weight: 500;
}

.mri-output-row {
  display: flex;
  align-items: stretch;
  gap: 12px;
}

.mri-output-row .mri-field {
  flex: 1;
}

.mri-output textarea {
  min-height: 72px;
  flex: none;
  padding: 14px 16px;
  resize: none;
  overflow: hidden;
  line-height: 1.5;
}

.mri-copy {
  flex: 0 0 auto;
  align-self: flex-end;
  min-width: 160px;
  height: 52px;
}

/* Home */
.home-container {
  flex-direction: column;
  max-width: 1280px;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
}

@media (max-width: 1100px) {
  .home-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .home-grid {
    grid-template-columns: 1fr;
  }
}

.home-tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 104px;
  padding: 18px 20px;
  text-decoration: none;
  color: var(--md-sys-color-on-surface);
  background-color: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-surface-variant);
  border-radius: var(--md-sys-shape-corner-extra-large);
  box-shadow: var(--md-sys-elevation-sm);
  transition: background-color var(--md-sys-motion-duration) var(--md-sys-motion-easing),
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

:root[data-theme="dark"] .home-tile {
  background-color: var(--md-sys-color-surface-container);
  border-color: transparent;
}

.home-tile-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 16%, var(--md-sys-color-surface-container));
  color: var(--md-sys-color-primary);
}

.home-tile-icon .material-symbols-outlined {
  font-size: 24px;
  line-height: 1;
  width: 24px;
  height: 24px;
  display: block;
  text-align: center;
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

:root[data-theme="dark"] .home-tile-icon {
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 18%, var(--md-sys-color-surface-container-high));
}

.home-tile-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding-right: 18px;
}

.home-tile-name {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.3;
}

.home-tile-detail {
  font-size: 13px;
  line-height: 1.4;
  color: var(--md-sys-color-on-surface-variant);
}

.home-tile-external {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 16px;
  color: var(--md-sys-color-outline);
}

.home-tile:hover {
  box-shadow: var(--md-sys-elevation-md);
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--md-sys-color-primary) 45%, var(--md-sys-color-surface-variant));
}

:root[data-theme="dark"] .home-tile:hover {
  background-color: var(--md-sys-color-surface-container-high);
  border-color: transparent;
}

.home-tile:active {
  transform: translateY(0);
}

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