@layer components {
  .az-button {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 13px;
    border: 1px solid rgba(41, 57, 85, .14);
    border-radius: var(--az-radius-control);
    background: rgba(255, 255, 255, .58);
    color: #253249;
    box-shadow: 0 1px 2px rgba(44, 57, 81, .04);
    font-size: 12px;
    font-weight: 650;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--az-motion-fast), border-color var(--az-motion-fast), transform var(--az-motion-fast), box-shadow var(--az-motion-fast);
  }

  .az-button:hover { background: rgba(255, 255, 255, .88); border-color: rgba(41, 57, 85, .20); box-shadow: 0 5px 14px rgba(44, 57, 81, .08); }
  .az-button:active { transform: translateY(1px); }
  .az-button-primary { border-color: rgba(73, 88, 196, .30); background: linear-gradient(180deg, #5868d5, #4f60ca); color: white; box-shadow: 0 7px 18px rgba(73, 87, 190, .22); }
  .az-button-primary:hover { background: linear-gradient(180deg, #5d6dd8, #5667cf); border-color: rgba(73, 88, 196, .36); }
  .az-button-teal { border-color: rgba(45, 135, 145, .28); background: rgba(45, 135, 145, .10); color: #245f67; }
  .az-button-danger { border-color: rgba(210, 87, 87, .24); background: rgba(210, 87, 87, .08); color: #9d3f3f; }

  .az-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: max(70px, 9vh) 18px 18px;
    background: rgba(41, 52, 75, .18);
    backdrop-filter: blur(14px) saturate(115%);
    -webkit-backdrop-filter: blur(14px) saturate(115%);
  }

  .az-overlay.is-open { display: flex; }

  .az-dialog {
    width: min(690px, 100%);
    max-height: min(740px, calc(100dvh - 110px));
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, .82);
    border-radius: var(--az-radius-dialog);
    background: rgba(249, 251, 255, .88);
    color: var(--az-text);
    box-shadow: 0 34px 100px rgba(37, 50, 76, .26), inset 0 1px rgba(255, 255, 255, .85);
    backdrop-filter: blur(36px) saturate(145%);
    -webkit-backdrop-filter: blur(36px) saturate(145%);
  }

  .az-window-menu-dialog { width: min(430px, 100%); }
  .az-dialog-header { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 9px 10px 9px 17px; border-bottom: 1px solid rgba(43, 58, 83, .09); }
  .az-dialog-header > div { display: grid; gap: 2px; }
  .az-dialog-header strong { font-size: 15px; font-weight: 700; }
  .az-dialog-body { min-height: 0; overflow: auto; padding: 15px; }
  .az-icon-button { width: 40px; height: 40px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 11px; background: transparent; color: #5c687a; cursor: pointer; }
  .az-icon-button:hover { background: rgba(62, 77, 102, .08); color: #29364b; }

  .az-command { width: min(760px, 100%); }
  .az-command-search { display: flex; align-items: center; gap: 11px; padding: 15px; border-bottom: 1px solid rgba(43, 58, 83, .08); }
  .az-command-search svg { flex: 0 0 20px; color: var(--az-accent); }
  .az-command-search input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: #1c2940; font-size: 18px; font-weight: 530; }
  .az-command-search input::placeholder { color: #68768a; }
  .az-key { padding: 5px 7px; border: 1px solid rgba(45, 60, 86, .12); border-radius: 7px; background: rgba(255, 255, 255, .46); color: #607084; font: 11px/1 var(--az-font-mono); }
  .az-command-results { max-height: min(520px, 60dvh); overflow: auto; padding: 8px; }
  .az-command-group { padding: 9px 9px 5px; color: #607084; font: 700 11px/1.2 var(--az-font-mono); letter-spacing: .08em; text-transform: uppercase; }
  .az-command-row { width: 100%; min-height: 52px; display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 8px 10px; border: 0; border-radius: 12px; background: transparent; color: #223048; text-align: left; cursor: pointer; }
  .az-command-row:hover, .az-command-row.is-selected { background: rgba(79, 96, 202, .10); }
  .az-command-row img { width: 29px; height: 29px; }
  .az-command-row strong { display: block; font-size: 13px; }
  .az-command-row small { display: block; color: #607084; font-size: 11px; }
  .az-command-row .az-command-kind { color: #607084; font: 11px/1 var(--az-font-mono); text-transform: uppercase; }
  .az-command-empty { padding: 30px 18px; text-align: center; color: #607084; }

  .az-launchpad-overlay {
    align-items: center;
    padding: 44px 28px 92px;
    background: rgba(209, 220, 239, .30);
    backdrop-filter: blur(38px) saturate(130%);
    -webkit-backdrop-filter: blur(38px) saturate(130%);
  }

  .az-launchpad {
    width: min(1040px, 100%);
    max-height: min(780px, calc(100dvh - 116px));
    border-radius: 26px;
    background: rgba(247, 250, 255, .68);
    box-shadow: 0 38px 120px rgba(39, 52, 80, .28), inset 0 1px rgba(255, 255, 255, .88);
  }

  .az-launchpad .az-dialog-header { min-height: 52px; background: rgba(255, 255, 255, .16); }
  .az-launchpad .az-dialog-body { padding: 18px 24px 30px; }
  .az-switcher-list { display: grid; gap: 22px; }

  #az-switcher-overlay:not(.az-launchpad-overlay) .az-dialog {
    width: min(520px, 100%);
    max-height: min(600px, calc(100dvh - 118px));
  }
  #az-switcher-overlay:not(.az-launchpad-overlay) .az-dialog-body {
    padding: 10px;
  }
  #az-switcher-overlay:not(.az-launchpad-overlay) .az-switcher-list {
    gap: 7px;
  }
  .az-switcher-item {
    width: 100%;
    min-height: 70px;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: transparent;
    color: #26344a;
    text-align: left;
    cursor: pointer;
    transition: background var(--az-motion-fast), border-color var(--az-motion-fast), transform var(--az-motion-fast), box-shadow var(--az-motion-fast);
  }
  .az-switcher-item:hover,
  .az-switcher-item:focus-visible {
    border-color: rgba(79, 96, 202, .14);
    background: rgba(255, 255, 255, .72);
    box-shadow: 0 8px 22px rgba(47, 61, 89, .08);
    transform: translateY(-1px);
  }
  .az-switcher-item > img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    padding: 6px;
    border: 1px solid rgba(255, 255, 255, .84);
    border-radius: 14px;
    background: linear-gradient(145deg, rgba(255, 255, 255, .94), rgba(230, 237, 248, .78));
    box-shadow: 0 7px 18px rgba(50, 65, 91, .12), inset 0 1px rgba(255, 255, 255, .9);
  }
  .az-switcher-item > span {
    min-width: 0;
    display: grid;
    gap: 4px;
  }
  .az-switcher-item strong {
    overflow: hidden;
    color: #253249;
    font-size: 13px;
    font-weight: 720;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .az-switcher-item small {
    color: #6a768a;
    font-size: 11px;
  }

  .az-launchpad-search {
    position: sticky;
    top: 0;
    z-index: 2;
    width: min(500px, 100%);
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0 auto 4px;
    padding: 7px 13px;
    border: 1px solid rgba(255, 255, 255, .8);
    border-radius: 14px;
    background: rgba(255, 255, 255, .54);
    box-shadow: 0 8px 22px rgba(47, 61, 89, .08), inset 0 1px rgba(255, 255, 255, .72);
    backdrop-filter: blur(18px);
  }

  .az-launchpad-search span { width: 18px; height: 18px; color: #5f6d80; }
  .az-launchpad-search svg { width: 18px; height: 18px; }
  .az-launchpad-search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: #1e2b42; font-size: 13px; }
  .az-launchpad-search input::placeholder { color: #607084; }

  .az-launchpad-group { display: grid; gap: 11px; }
  .az-launchpad-group h3 { margin: 0 4px; color: #5d6a7d; font-size: 11px; font-weight: 720; letter-spacing: .06em; text-transform: uppercase; }
  .az-launchpad-grid { display: grid; grid-template-columns: repeat(5, minmax(110px, 1fr)); gap: 10px; }
  .az-launchpad-worlds { grid-template-columns: repeat(3, minmax(160px, 1fr)); }

  .az-launchpad-item {
    min-width: 0;
    min-height: 118px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 12px 8px;
    border: 1px solid transparent;
    border-radius: 17px;
    background: transparent;
    color: #26334a;
    text-align: center;
    cursor: pointer;
    transition: transform var(--az-motion-fast), background var(--az-motion-fast), border-color var(--az-motion-fast);
  }

  .az-launchpad-item[hidden] { display: none; }
  .az-launchpad-item:hover { transform: translateY(-2px); background: rgba(255, 255, 255, .52); border-color: rgba(255, 255, 255, .72); }
  .az-launchpad-item.is-active { background: rgba(79, 96, 202, .08); }

  .az-launchpad-icon { width: 60px; height: 60px; display: grid; place-items: center; margin-bottom: 2px; border: 1px solid rgba(255, 255, 255, .84); border-radius: 18px; background: linear-gradient(145deg, rgba(255, 255, 255, .9), rgba(229, 237, 248, .72)); box-shadow: 0 10px 22px rgba(50, 65, 91, .13), inset 0 1px rgba(255, 255, 255, .82); }
  .az-launchpad-icon img { width: 38px; height: 38px; }
  .az-launchpad-world .az-launchpad-icon[data-accent="brass"] { background: linear-gradient(145deg, #fff0cf, #e4b56f); }
  .az-launchpad-world .az-launchpad-icon[data-accent="rust"] { background: linear-gradient(145deg, #ffe3da, #d9896e); }
  .az-launchpad-world .az-launchpad-icon[data-accent="teal"] { background: linear-gradient(145deg, #d9f5f2, #78c1bd); }
  .az-launchpad-item strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
  .az-launchpad-item small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #607084; font-size: 11px; }

  .az-window-menu-grid { grid-template-columns: 1fr 1fr; }
  .az-settings-grid { grid-template-columns: 1fr; }
  .az-setting-row { display: flex; align-items: center; gap: 10px; min-height: 44px; color: #344158; font-size: 12px; }
  .az-setting-row input { width: 18px; height: 18px; accent-color: var(--az-accent); }

  .az-toast-stack { position: fixed; z-index: 1500; right: 16px; top: 52px; width: min(360px, calc(100vw - 32px)); display: grid; gap: 8px; pointer-events: none; }
  .az-toast { pointer-events: auto; padding: 12px 14px; border: 1px solid rgba(255, 255, 255, .78); border-radius: 14px; background: rgba(249, 251, 255, .88); color: #26344a; box-shadow: var(--az-shadow-soft); animation: az-toast-in var(--az-motion) ease-out; backdrop-filter: blur(22px); }
  .az-toast strong { display: block; font-size: 12px; }
  .az-toast p { margin: 3px 0 0; color: #5f6d80; font-size: 11px; line-height: 1.45; }
  @keyframes az-toast-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }

  .az-empty-state { min-height: 260px; display: grid; place-items: center; padding: 32px; text-align: center; }
  .az-empty-state > div { max-width: 470px; }
  .az-empty-state h3 { margin: 0 0 8px; color: #26344a; font: 650 23px/1.15 var(--az-font-ui); letter-spacing: -.02em; }
  .az-empty-state p { margin: 0 0 18px; color: #5b6678; font-size: 13px; }

  .az-paper-surface { color: var(--az-ink); background: var(--az-paper); }
  .az-paper-surface :focus-visible { outline-color: #4b66dd; }
  .az-evidence { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 3px 8px; border-radius: 999px; border: 1px solid currentColor; font: 700 11px/1 var(--az-font-mono); text-transform: uppercase; letter-spacing: .05em; }
  .az-evidence::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
  .az-evidence[data-level="documented"] { color: #26727c; }
  .az-evidence[data-level="archaeological"] { color: #8b642e; }
  .az-evidence[data-level="inferred"] { color: #aa593f; }
  .az-evidence[data-level="atmospheric"] { color: #667181; }
  .az-evidence[data-level="disputed"] { color: #9b6d25; border-style: dashed; }
  .az-paper-surface .az-evidence[data-level="documented"] { color: #2f6660; }
  .az-paper-surface .az-evidence[data-level="archaeological"] { color: #75571f; }
  .az-paper-surface .az-evidence[data-level="inferred"] { color: #8b493b; }
  .az-paper-surface .az-evidence[data-level="atmospheric"] { color: #585e59; }
  .az-paper-surface .az-evidence[data-level="disputed"] { color: #71571f; }

  .az-simple-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
  .az-simple-card { min-height: 150px; padding: 16px; border: 1px solid rgba(43, 58, 83, .09); border-radius: 15px; background: rgba(255, 255, 255, .50); color: #27354b; }
  .az-simple-card h3 { margin: 0 0 7px; font: 650 18px/1.2 var(--az-font-ui); }
  .az-simple-card p { color: #5f6d80; font-size: 12px; }

  .az-error-page { min-height: 100dvh; }
  .az-error-logo { width: 58px; height: 58px; margin-bottom: 18px; }
  .az-error-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
  .az-noscript-card { max-width: 720px; margin: 12vh auto; padding: 24px; color: var(--az-text); background: rgba(255, 255, 255, .84); border: 1px solid rgba(255, 255, 255, .8); border-radius: 18px; font: 16px/1.6 var(--az-font-ui); box-shadow: var(--az-shadow-soft); }

  #az-boot { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; color: #253249; background: radial-gradient(60% 48% at 50% 36%, rgba(255, 255, 255, .72), transparent 72%), linear-gradient(145deg, #dcecff 0%, #efe7ff 50%, #f7ddcf 100%); transition: opacity 260ms ease, visibility 260ms ease; }
  #az-boot.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
  .az-boot-inner { display: flex; flex-direction: column; align-items: center; gap: 11px; text-align: center; }
  .az-boot-inner img { width: 66px; height: 66px; filter: drop-shadow(0 12px 24px rgba(49, 62, 91, .18)); }
  .az-boot-inner strong { font: 720 27px/1.1 var(--az-font-ui); letter-spacing: -.03em; }
  .az-boot-inner span { color: #5f6d80; font: 700 11px/1.3 var(--az-font-mono); letter-spacing: .08em; text-transform: uppercase; }
  .az-boot-progress { width: 126px; height: 4px; overflow: hidden; border-radius: 999px; background: rgba(55, 70, 98, .10); }
  .az-boot-progress::after { content: ""; display: block; width: 54%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #5d6dd8, #448cae, #c8765d); animation: az-boot-slide 650ms ease-in-out infinite alternate; }
  @keyframes az-boot-slide { from { transform: translateX(-55%); } to { transform: translateX(95%); } }

  @media (prefers-reduced-motion: reduce) {
    .az-toast, .az-boot-progress::after { animation: none !important; }
    .az-launchpad-item:hover { transform: none; }
    .az-switcher-item:hover { transform:none; }
  }
  body.az-reduce-motion .az-toast,
  body.az-reduce-motion .az-boot-progress::after { animation: none !important; }
  body.az-reduce-motion .az-launchpad-item:hover,
  body.az-reduce-motion .az-switcher-item:hover { transform: none; }

  @media (max-width: 899px) {
    .az-launchpad-grid { grid-template-columns: repeat(4, minmax(100px, 1fr)); }
    .az-launchpad-worlds { grid-template-columns: repeat(3, minmax(130px, 1fr)); }
  }

  @media (max-width: 599px), (max-height: 500px) and (max-width: 899px) {
    .az-button { min-height: 44px; }
    .az-icon-button { width: 44px; height: 44px; }
    .az-overlay { align-items: stretch; padding: 0; }
    .az-dialog { width: 100%; max-height: 100%; height: 100%; border: 0; border-radius: 0; }
    .az-dialog-header { min-height: 58px; padding-top: max(8px, env(safe-area-inset-top)); }
    .az-command { height: auto; margin-top: auto; max-height: 82dvh; border-radius: 22px 22px 0 0; border-top: 1px solid rgba(255, 255, 255, .8); }
    .az-command-results { max-height: 60dvh; }
    .az-launchpad-overlay { padding: 0; }
    .az-launchpad { max-height: 100%; border-radius: 0; }
    .az-launchpad .az-dialog-body { padding: 14px 12px 86px; }
    .az-launchpad-search { width: 100%; }
    .az-launchpad-grid, .az-launchpad-worlds { grid-template-columns: repeat(3, minmax(86px, 1fr)); gap: 6px; }
    .az-launchpad-item { min-height: 104px; padding: 9px 4px; }
    .az-launchpad-icon { width: 52px; height: 52px; border-radius: 15px; }
    .az-launchpad-icon img { width: 33px; height: 33px; }
    #az-switcher-overlay:not(.az-launchpad-overlay) .az-dialog { max-height:100%; }
    #az-switcher-overlay:not(.az-launchpad-overlay) .az-dialog-body { padding:10px 12px 86px; }
    .az-switcher-item { min-height:68px; }
    .az-switcher-item > img { width:44px; height:44px; }
    .az-window-menu-grid { grid-template-columns: 1fr; }
  }
}
