/* aoko client — faux Windows desktop + interactive GUI preview.
 * Loaded after style.css. Window theming is driven by --w-* custom properties
 * set on .aoko-window by preview.js (see AOKO_PREVIEW_DATA.palettes). */

.aoko-desktop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.28s ease;
  font-family: 'Segoe UI', var(--font-sans);
}
.aoko-desktop.open { opacity: 1; }
.aoko-desktop[hidden] { display: none; }
body.aoko-noscroll { overflow: hidden; }

/* wallpaper */
.aoko-wallpaper {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(140% 120% at 20% 0%, #1b2740 0%, #0d1526 45%, #070a12 100%);
  overflow: hidden;
}
.aoko-wallpaper::before {
  content: '';
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(closest-side, rgba(107,141,171,0.28), transparent 70%) 70% 22%/48% 48% no-repeat,
    radial-gradient(closest-side, rgba(43,58,134,0.22), transparent 70%) 22% 78%/42% 42% no-repeat;
  filter: blur(8px);
}
.aoko-wallpaper::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 44px 44px;
}

/* exit affordance */
.aoko-exit {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 5;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #cdd3dd;
  background: rgba(10,14,22,0.55);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 4px;
  padding: 7px 12px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.aoko-exit:hover { background: rgba(43,58,134,0.36); border-color: rgba(157,176,255,0.72); }
.aoko-exit:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* =====================================================================
 * WINDOW
 * ===================================================================== */
.aoko-window {
  /* palette defaults (Slate) — overridden inline by JS */
  --w-bg: #0A0B0F;
  --w-panel: #12141A;
  --w-line: #181B22;
  --w-accent: #7F9EFF;
  --w-text: #E8EAEE;
  --w-muted: rgba(232,234,238,0.60);
  --w-dim: rgba(232,234,238,0.40);
  --w-accent-soft: rgba(127,158,255,0.16);
  --w-hover: rgba(232,234,238,0.05);

  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  width: min(920px, 92vw);
  height: min(660px, 80vh);
  display: flex;
  flex-direction: column;
  background: var(--w-bg);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 10px;
  box-shadow: 0 40px 100px -20px rgba(0,0,0,0.75), 0 0 0 1px rgba(0,0,0,0.4);
  overflow: hidden;
  outline: none;
  opacity: 0;
  transition: opacity 0.28s ease, transform 0.28s ease;
}
.aoko-desktop.open .aoko-window { opacity: 1; }
.aoko-window.dragging { transition: none; user-select: none; cursor: grabbing; }
.aoko-window.minimized { display: none; }
.aoko-window.maximized {
  left: 0 !important;
  top: 0 !important;
  transform: none !important;
  width: 100% !important;
  height: calc(100% - 46px) !important;
  border-radius: 0;
  border: none;
}

/* title bar */
.aoko-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding-left: 14px;
  background: var(--w-panel);
  border-bottom: 1px solid var(--w-line);
  cursor: grab;
  flex: none;
}
.aoko-window.dragging .aoko-titlebar { cursor: grabbing; }
.aoko-title { display: flex; align-items: center; gap: 9px; pointer-events: none; }
.aoko-title-icon { color: var(--w-accent); font-size: 0.95rem; }
.aoko-title-text { color: var(--w-text); font-size: 0.82rem; font-weight: 500; }
.aoko-winbtns { display: flex; height: 100%; }
.aoko-winbtn {
  width: 46px;
  height: 100%;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  color: var(--w-muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.aoko-winbtn svg { width: 10px; height: 10px; fill: currentColor; }
.aoko-winbtn:hover { background: var(--w-hover); color: var(--w-text); }
.aoko-winbtn.close:hover { background: #e13b3b; color: #fff; }
.aoko-winbtn:focus-visible { outline: 1px solid var(--w-accent); outline-offset: -2px; }

/* body */
.aoko-body { flex: 1; display: flex; min-height: 0; padding: 14px; gap: 12px; }

/* left rail */
.aoko-rail {
  flex: none;
  width: 150px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--w-panel);
  border: 1px solid var(--w-line);
  border-radius: 8px;
  padding: 8px;
  overflow: auto;
}
.aoko-tab {
  min-height: 46px;
  border-radius: 8px;
  background: var(--w-line);
  border: 1px solid transparent;
  color: var(--w-muted);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.aoko-tab:hover { color: var(--w-text); border-color: var(--w-accent); }
.aoko-tab.active {
  background: color-mix(in srgb, var(--w-panel) 60%, #000);
  color: var(--w-text);
  border-color: var(--w-accent);
}
.aoko-tab:focus-visible { outline: 2px solid var(--w-accent); outline-offset: 1px; }

/* content */
.aoko-content {
  flex: 1;
  min-width: 0;
  background: var(--w-bg);
  border: 1px solid var(--w-line);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}
.aoko-panel { display: none; height: 100%; }
.aoko-panel.active { display: block; }
.aoko-scroll { height: 100%; overflow-y: auto; padding: 14px; }

/* cards */
.aoko-card {
  background: var(--w-panel);
  border: 1px solid var(--w-line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}
.aoko-card:last-child { margin-bottom: 0; }
.aoko-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.aoko-card-title { color: var(--w-text); font-size: 1.05rem; font-weight: 700; flex: 1; min-width: 0; }
.aoko-status { color: var(--w-accent); font-size: 0.78rem; margin-top: 4px; }

/* toggle switch */
.aoko-toggle {
  flex: none;
  width: 46px;
  height: 24px;
  border-radius: 13px;
  background: var(--w-line);
  border: 1px solid rgba(255,255,255,0.08);
  position: relative;
  cursor: pointer;
  transition: background 0.18s ease;
  padding: 0;
}
.aoko-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #d7dbe2;
  transition: transform 0.18s ease, background 0.18s ease;
}
.aoko-toggle.on { background: var(--w-accent); }
.aoko-toggle.on .aoko-toggle-knob { transform: translateX(22px); background: #fff; }
.aoko-toggle:focus-visible { outline: 2px solid var(--w-accent); outline-offset: 2px; }

/* generic control spacing */
.aoko-ctrl { margin-top: 12px; }
.aoko-card-head + .aoko-ctrl,
.aoko-status + .aoko-ctrl { margin-top: 12px; }
.aoko-ctrl.gated-off { opacity: 0.4; pointer-events: none; }

/* slider */
.aoko-slider-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.aoko-slider-label { color: var(--w-text); font-size: 0.82rem; }
.aoko-slider-val { color: var(--w-dim); font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.aoko-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 3px;
  background: linear-gradient(to right,
    var(--w-accent) var(--fill, 50%), var(--w-line) var(--fill, 50%));
  cursor: pointer;
  outline: none;
}
.aoko-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--w-accent);
  border: 2px solid var(--w-panel);
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
  cursor: grab;
}
.aoko-range::-moz-range-thumb {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--w-accent);
  border: 2px solid var(--w-panel);
  cursor: grab;
}
.aoko-range::-moz-range-track { height: 4px; border-radius: 3px; background: var(--w-line); }
.aoko-range::-moz-range-progress { height: 4px; border-radius: 3px; background: var(--w-accent); }
.aoko-range:focus-visible { outline: 2px solid var(--w-accent); outline-offset: 4px; }

/* checkboxes */
.aoko-checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.aoko-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  color: var(--w-text);
  font-size: 0.82rem;
}
.aoko-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.aoko-check-box {
  width: 16px; height: 16px;
  border-radius: 4px;
  border: 1px solid var(--w-dim);
  background: var(--w-bg);
  position: relative;
  flex: none;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.aoko-check input:checked + .aoko-check-box {
  background: var(--w-accent);
  border-color: var(--w-accent);
}
.aoko-check input:checked + .aoko-check-box::after {
  content: '';
  position: absolute;
  left: 5px; top: 1.5px;
  width: 4px; height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.aoko-check input:focus-visible + .aoko-check-box { outline: 2px solid var(--w-accent); outline-offset: 2px; }

/* switch row */
.aoko-switchrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.aoko-switchrow-label { color: var(--w-text); font-size: 0.86rem; font-weight: 500; }

/* select */
.aoko-selectrow { display: flex; flex-direction: column; gap: 5px; }
.aoko-select-label { color: var(--w-text); font-size: 0.82rem; }
.aoko-select {
  appearance: none;
  background: var(--w-bg);
  color: var(--w-text);
  border: 1px solid var(--w-line);
  border-radius: 5px;
  padding: 7px 10px;
  font-size: 0.82rem;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--w-muted) 50%),
                    linear-gradient(135deg, var(--w-muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.aoko-select:focus-visible { outline: 2px solid var(--w-accent); outline-offset: 1px; }

/* buttons */
.aoko-btn {
  background: var(--w-line);
  color: var(--w-text);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 5px;
  padding: 7px 16px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.aoko-btn:hover { background: var(--w-accent-soft); border-color: var(--w-accent); }
.aoko-btn:active { transform: translateY(1px); }
.aoko-btn:focus-visible { outline: 2px solid var(--w-accent); outline-offset: 2px; }
.aoko-btnrow { display: flex; flex-wrap: wrap; gap: 8px; }
.aoko-keybind-btn {
  flex: none;
  min-width: 7.5rem;
  padding: 4px 10px;
  font-size: 0.75rem;
}

/* note */
.aoko-note { color: var(--w-muted); font-size: 0.8rem; line-height: 1.55; margin-top: 10px; }
.aoko-note.warn { color: #f0a54a; }

/* keybinds grid */
.aoko-keybinds { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.aoko-keybind {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--w-line);
  color: var(--w-text);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 5px;
  padding: 7px 10px;
  font-size: 0.78rem;
  cursor: pointer;
}
.aoko-keybind em { color: var(--w-dim); font-style: normal; }
.aoko-keybind:hover { border-color: var(--w-accent); }
.aoko-keybind.listening { border-color: var(--w-accent); background: var(--w-accent-soft); }
.aoko-keybind.listening em { color: var(--w-accent); }
.aoko-keybind:focus-visible { outline: 2px solid var(--w-accent); outline-offset: 1px; }

/* palette swatches */
.aoko-palettes, .aoko-modstyles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.aoko-swatchcard, .aoko-modstyle {
  width: 150px;
  text-align: left;
  background: var(--w-line);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  padding: 10px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.aoko-swatchcard:hover, .aoko-modstyle:hover { border-color: var(--w-accent); }
.aoko-swatchcard.active, .aoko-modstyle.active { border-color: var(--w-accent); background: var(--w-accent-soft); }
.aoko-swatchcard-name, .aoko-modstyle-name {
  display: block;
  color: var(--w-text);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.aoko-swatches { display: flex; gap: 4px; }
.aoko-swatch { width: 30px; height: 12px; border-radius: 3px; border: 1px solid rgba(255,255,255,0.1); }

/* module-list style demos */
.aoko-modstyle-demo {
  display: block;
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 3px;
  color: #fff;
}
.ms-default { background: rgba(0,0,0,0.35); border-left: 3px solid var(--w-accent); }
.ms-minimal { background: rgba(0,0,0,0.2); color: var(--w-accent); text-align: right; border-right: 3px solid var(--w-accent); }
.ms-outlined { background: rgba(0,0,0,0.25); border: 1px solid var(--w-accent); color: var(--w-accent); }
.ms-glass { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.33); border-left: 3px solid rgba(255,255,255,0.7); }
.ms-bold { background: var(--w-accent); color: #fff; }

.aoko-current { color: var(--w-dim); font-size: 0.76rem; margin-top: 10px; }
.aoko-current b { color: var(--w-accent); font-weight: 600; }

/* =====================================================================
 * TASKBAR
 * ===================================================================== */
.aoko-taskbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  background: rgba(12,16,24,0.82);
  border-top: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 3;
}
.aoko-start {
  width: 40px; height: 34px;
  display: grid; place-items: center;
  background: transparent;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.aoko-start:hover, .aoko-start.active { background: rgba(255,255,255,0.1); }
.aoko-start-orb { display: grid; grid-template-columns: 9px 9px; gap: 2px; }
.aoko-start-orb i { width: 9px; height: 9px; border-radius: 2px; background: #6b8dab; display: block; }
.aoko-start-orb i:nth-child(1) { background: #7fa8cc; }
.aoko-start-orb i:nth-child(4) { background: #5b7a99; }
.aoko-taskapp {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px 0 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid transparent;
  border-radius: 5px;
  color: #dfe4ec;
  font-size: 0.78rem;
  cursor: pointer;
  position: relative;
  transition: background 0.12s ease;
}
.aoko-taskapp:hover { background: rgba(255,255,255,0.12); }
.aoko-taskapp.active { background: rgba(255,255,255,0.14); }
.aoko-taskapp.active::after {
  content: '';
  position: absolute;
  left: 12px; right: 12px; bottom: -1px;
  height: 2px;
  background: #6b8dab;
  border-radius: 2px;
}
.aoko-taskapp-icon { color: #9db0ff; }
.aoko-tray { margin-left: auto; }
.aoko-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  color: #dfe4ec;
  font-size: 0.72rem;
  line-height: 1.25;
  padding: 0 6px;
}
.aoko-clock .d { color: rgba(223,228,236,0.7); }

/* =====================================================================
 * RESPONSIVE
 * ===================================================================== */
@media (max-width: 760px) {
  .aoko-body { flex-direction: column; padding: 10px; gap: 10px; }
  .aoko-rail {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
  }
  .aoko-tab { min-height: 40px; flex: 1 0 auto; padding: 0 14px; }
  .aoko-titlebar { cursor: default; }
  .aoko-exit { top: 8px; right: 10px; }
}

/* =====================================================================
 * REDUCED MOTION
 * ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  .aoko-desktop, .aoko-window, .aoko-toggle, .aoko-toggle-knob { transition: none !important; }
}
