:root {
  --app-font: "Avenir Next", Avenir, -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --preview-code-font: var(--app-font);
  --page-bg: #eef3f7;
  --panel-bg: #ffffff;
  --panel-border: #d7e0e8;
  --panel-text: #111827;
  --panel-muted: #637182;
  --sidebar-bg: #9bb6ce;
  --sidebar-bg-solid: #9bb6ce;
  --sidebar-text: #000000;
  --sidebar-muted: #394958;
  --sidebar-active: rgb(255 255 255 / 0.22);
  --content-bg: #366698;
  --content-bg-solid: #366698;
  --content-bg-edge: #366698;
  --content-text: #e5e5e5;
  --content-control-contrast: #101820;
  --content-muted: rgb(229 229 229 / 0.68);
  --content-card: rgb(255 255 255 / 0.16);
  --content-border: rgb(229 229 229 / 0.18);
  --content-field: rgb(255 255 255 / 0.2);
  --control-glass-base: #6080a0;
  --control-glass-bg: color-mix(in srgb, var(--control-glass-base) 66%, transparent);
  --control-glass-hover: color-mix(in srgb, var(--control-glass-base) 82%, transparent);
  --control-glass-border: color-mix(in srgb, var(--content-text) 18%, transparent);
  --control-glass-icon: var(--content-text);
  --control-primary-base: #1b68b0;
  --control-primary-bg: color-mix(in srgb, var(--control-primary-base) 84%, transparent);
  --control-primary-hover: color-mix(in srgb, var(--control-primary-base) 96%, transparent);
  --control-primary-icon: #ffffff;
  --floating-glass-bg: color-mix(in srgb, var(--sidebar-bg-solid) 78%, transparent);
  --floating-glass-border: color-mix(in srgb, var(--sidebar-text) 20%, transparent);
  --floating-glass-text: var(--sidebar-text);
  --floating-glass-muted: var(--sidebar-muted);
  --effect-ambient: none;
  --effect-stars: none;
  --effect-ambient-opacity: 0;
  --effect-stars-opacity: 0;
  --effect-ambient-animation: none;
  --effect-stars-animation: none;
  --accent: #0169cc;
  --ui-blue: #1f5f9f;
  --ui-blue-dark: #172554;
  --ui-blue-soft: #edf6ff;
  --ui-border-blue: #bdd5ec;
  --menu-weight: 700;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  color: var(--panel-text);
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.74), transparent 38%),
    var(--page-bg);
  font-family: var(--app-font);
  letter-spacing: 0;
  overflow: hidden;
}

button {
  font: inherit;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 330px) minmax(0, 1fr);
  gap: 14px;
  height: min(100vh, 860px);
  min-height: 0;
  max-height: 100vh;
  max-width: 1360px;
  margin: 0 auto;
  padding: 14px;
  overflow: hidden;
}

.control-pane,
.output-panel {
  min-width: 0;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}

.control-pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 28px);
  padding: 14px;
  overflow-y: auto;
}

.panel-header {
  display: grid;
  gap: 7px;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0;
  color: var(--panel-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 23px;
  line-height: 1.08;
}

h2 {
  margin-bottom: 0;
  font-size: 15px;
}

.status-line {
  min-height: 32px;
  color: #0b3f20;
  background: #e8f8ee;
  border: 1px solid #b7e6c7;
  border-radius: 8px;
  padding: 7px 9px;
  overflow: hidden;
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-section {
  display: grid;
  gap: 8px;
}

.command-section {
  flex: 0 0 auto;
}

.command-panel {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: #f8fafc;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}

.command-panel p {
  margin: 0;
  color: var(--panel-muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.command-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.command-panel code {
  display: block;
  min-width: 0;
  padding: 7px 8px;
  color: #263142;
  background: #ffffff;
  border: 1px solid #dfe6ef;
  border-radius: 7px;
  overflow: hidden;
  font-family: var(--preview-code-font);
  font-size: 11px;
  font-weight: 760;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-panel.is-online {
  background: #f4f8fc;
  border-color: var(--ui-border-blue);
}

.command-panel.is-online p,
.command-panel.is-online code {
  color: #1d3f5f;
}

.command-panel.is-offline {
  background: #f7f9fc;
  border-color: #cbd6e2;
}

.command-panel.is-offline p {
  color: #45556a;
}

.preset-section {
  min-height: 0;
  flex: 0 0 auto;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.section-head span {
  color: var(--panel-muted);
  font-size: 12px;
  font-weight: 800;
}

.theme-grid,
.button-grid {
  display: grid;
  gap: 7px;
}

.theme-grid {
  grid-template-columns: 1fr;
  min-height: 0;
  max-height: min(44vh, 360px);
  overflow: auto;
  padding-right: 2px;
}

.button-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.compact-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.theme-button,
.choice-button {
  min-width: 0;
  min-height: 40px;
  color: var(--panel-text);
  background: #f8fafc;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px;
  font-weight: 760;
}

.theme-button {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  text-align: left;
}

.theme-button strong,
.theme-button span {
  display: block;
}

.theme-button .theme-title-row {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.theme-button .theme-index {
  flex: 0 0 auto;
  color: #7b8797;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.1;
}

.theme-button strong {
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.15;
}

.theme-copy > span:last-child {
  margin-top: 2px;
  color: var(--panel-muted);
  font-size: 11px;
  line-height: 1.2;
}

.theme-button[aria-pressed="true"],
.choice-button[aria-pressed="true"] {
  border-color: var(--ui-blue);
  background: var(--ui-blue-soft);
  box-shadow: 0 0 0 3px rgb(1 105 204 / 0.14);
}

.empty-themes {
  min-height: 84px;
  color: var(--panel-muted);
  background: #f8fafc;
  border: 1px dashed var(--panel-border);
  border-radius: 8px;
  padding: 16px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.swatch {
  position: relative;
  display: grid;
  grid-template-columns: 32% 68%;
  overflow: hidden;
  width: 54px;
  height: 36px;
  background: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 8px;
  box-shadow:
    0 0 0 1px rgb(15 23 42 / 0.18),
    inset 0 0 0 1px rgb(255 255 255 / 0.2);
}

.swatch i {
  display: block;
  min-height: 100%;
}

.swatch-sidebar {
  border-right: 1px solid rgb(255 255 255 / 0.35);
}

.swatch .swatch-accent {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 15px;
  height: 15px;
  min-height: 0;
  border: 2px solid rgb(255 255 255 / 0.9);
  border-radius: 999px;
  box-shadow: 0 1px 5px rgb(0 0 0 / 0.28);
}

.primary-action,
.secondary-action {
  min-height: 38px;
  color: #ffffff;
  background: var(--ui-blue);
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  font-weight: 850;
}

.launch-action {
  background: var(--ui-blue-dark);
}

.primary-action:disabled,
.secondary-action:disabled {
  cursor: default;
  opacity: 0.72;
}

.secondary-action {
  min-height: 36px;
  color: #233246;
  background: #eaf0f6;
  border: 1px solid #d2dce8;
}

.reset-action {
  color: var(--panel-text);
  background: #e8eef3;
}

.header-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 8px;
}

.theme-toolbar {
  display: grid;
  gap: 8px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-button {
  min-height: 30px;
  color: var(--panel-muted);
  background: #f8fafc;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 850;
}

.filter-button[aria-pressed="true"] {
  color: var(--ui-blue);
  background: var(--ui-blue-soft);
  border-color: var(--ui-border-blue);
}

.theme-search {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: var(--panel-muted);
  background: #f8fafc;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 850;
}

.theme-search input {
  min-width: 0;
  height: 28px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--panel-text);
  font: inherit;
}

.compact-control-section .section-head {
  min-height: 22px;
}

.compact-control-section .choice-button {
  min-height: 34px;
  padding: 0 8px;
  font-size: 12px;
}

.preview-pane {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  min-width: 0;
  max-height: calc(100vh - 28px);
  overflow: hidden;
}

.preview-card {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  overflow: hidden;
  min-height: 0;
  height: 100%;
  border: 1px solid rgb(0 0 0 / 0.1);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgb(25 40 60 / 0.14);
}

.preview-card.is-applied {
  animation: applied-pulse 1.25s ease-out;
}

.preview-sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  color: var(--sidebar-text);
  background: var(--sidebar-bg);
  padding: 10px 8px;
  font-family: var(--app-font);
  font-weight: var(--menu-weight);
}

.settings-popover {
  position: absolute;
  left: 14px;
  bottom: 58px;
  display: grid;
  gap: 2px;
  width: 178px;
  color: var(--floating-glass-text);
  background: var(--content-card);
  background: var(--floating-glass-bg);
  border: 1px solid var(--floating-glass-border);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgb(15 23 42 / 0.16);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  backdrop-filter: blur(10px) saturate(120%);
  padding: 8px;
}

.settings-popover span {
  display: flex;
  align-items: center;
  min-height: 32px;
  color: var(--floating-glass-text);
  border-radius: 7px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 850;
}

.settings-popover span:nth-child(3) {
  background: var(--content-field);
}

.traffic-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 26px;
  padding: 0 6px;
}

.traffic {
  width: 13px;
  height: 13px;
  border-radius: 50%;
}

.traffic.red {
  background: #ff5f57;
}

.traffic.yellow {
  background: #febc2e;
}

.traffic.green {
  background: #28c840;
}

.preview-sidebar nav {
  display: grid;
  gap: 2px;
}

.preview-section {
  display: grid;
  gap: 2px;
}

.preview-section > span {
  display: block;
  margin: 8px 8px 4px;
  color: var(--sidebar-muted);
  font-size: 12px;
  font-weight: 900;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 30px;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 0 8px;
  text-align: left;
  font-weight: inherit;
}

.nav-item.active,
.nav-item:hover {
  background: var(--sidebar-active);
}

.preview-meta {
  display: grid;
  gap: 5px;
  margin-top: auto;
  color: var(--sidebar-muted);
  padding: 8px;
  font-size: 12px;
}

.preview-meta strong {
  color: var(--sidebar-text);
  font-size: 15px;
}

.preview-content {
  display: flex;
  min-width: 0;
  color: var(--content-text);
  background: var(--content-bg);
  flex-direction: column;
  font-family: var(--app-font);
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.preview-content::before,
.preview-content::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  mix-blend-mode: screen;
  transform: translate3d(0, 0, 0);
  will-change: transform, opacity;
}

.preview-content::before {
  background: var(--effect-ambient);
  opacity: var(--effect-ambient-opacity);
  animation: var(--effect-ambient-animation);
}

.preview-content::after {
  background: var(--effect-stars);
  opacity: var(--effect-stars-opacity);
  animation: var(--effect-stars-animation);
}

.preview-topbar,
.preview-thread,
.composer-row {
  position: relative;
  z-index: 1;
}

.preview-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  border-bottom: 1px solid var(--content-border);
  padding: 0 18px;
}

.preview-topbar h2 {
  margin: 0;
  flex: 1;
  color: var(--content-text);
  font-size: 15px;
  font-weight: 800;
}

.topbar-buttons {
  display: flex;
  gap: 12px;
}

.topbar-buttons span {
  width: 16px;
  height: 16px;
  border-radius: 8px;
  border: 1px solid var(--content-border);
}

.ghost-button {
  min-width: 34px;
  min-height: 32px;
  color: var(--content-text);
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-weight: 900;
}

.preview-thread {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 0;
  overflow: hidden;
  max-width: 720px;
  padding: 22px 24px 96px;
}

.assistant-block {
  display: grid;
  gap: 12px;
  max-width: 660px;
}

.worked-button {
  width: fit-content;
  min-height: 28px;
  color: var(--content-muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 0;
  font-weight: 800;
}

.hero-copy {
  max-width: 620px;
  margin-bottom: 0;
  color: var(--content-text);
  font-size: 18px;
  font-weight: 850;
  line-height: 1.32;
}

.sample-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  max-width: 360px;
  min-height: 32px;
  align-items: center;
  color: var(--content-text);
  background: var(--content-card);
  border: 1px solid var(--content-border);
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
}

.sample-row span {
  color: var(--content-muted);
}

.sample-row strong {
  min-width: 0;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.change-card {
  overflow: hidden;
  max-width: 660px;
  color: var(--content-text);
  background: var(--content-card);
  border: 1px solid var(--content-border);
  border-radius: 8px;
}

.change-main {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 68px;
  padding: 10px 12px;
}

.file-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: var(--content-text);
  background: var(--content-field);
  border-radius: 8px;
  font-size: 22px;
  font-weight: 900;
}

.change-main p {
  margin: 4px 0 0;
  color: var(--content-muted);
  font-size: 13px;
}

.change-main button {
  min-height: 34px;
  color: var(--content-text);
  background: var(--content-field);
  border: 1px solid var(--content-border);
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 850;
}

.change-footer {
  display: flex;
  justify-content: space-between;
  min-height: 40px;
  color: var(--content-text);
  border-top: 1px solid var(--content-border);
  padding: 10px 14px;
  font-weight: 800;
}

.code-sample {
  max-width: 660px;
  margin: 0;
  overflow: auto;
  color: var(--content-text);
  background: var(--content-card);
  border: 1px solid var(--content-border);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--preview-code-font);
  font-size: 13px;
  line-height: 1.55;
}

.composer-row {
  position: absolute;
  right: 24px;
  bottom: 16px;
  left: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  color: var(--content-muted);
  background: var(--content-field);
  border: 1px solid var(--content-border);
  border-radius: 18px;
  padding: 10px 12px 10px 14px;
  font-weight: 800;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--control-glass-icon);
  font-size: 12px;
}

.composer-main {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.preview-attachment {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 34px;
  overflow: visible;
  background: var(--control-glass-bg);
  border: 1px solid var(--control-glass-border);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.18);
}

.preview-attachment span {
  display: block;
  width: 100%;
  height: 100%;
  background:
    linear-gradient(135deg, rgb(255 255 255 / 0.42), transparent 52%),
    var(--content-bg);
  border-radius: 7px;
}

.composer-row button {
  width: 38px;
  height: 38px;
  color: var(--control-primary-icon);
  background: var(--control-primary-bg);
  border: 1px solid var(--control-glass-border);
  border-radius: 50%;
  padding: 0;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.22),
    0 6px 18px rgb(15 23 42 / 0.12);
  font-weight: 900;
}

.preview-attachment .attachment-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  color: var(--control-primary-icon);
  background: var(--control-primary-bg);
  border: 1px solid var(--control-glass-border);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.2),
    0 2px 8px rgb(15 23 42 / 0.18);
  font-size: 12px;
  line-height: 1;
}

.composer-tools span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
}

.composer-tools span:first-child {
  width: 28px;
  justify-content: center;
  padding: 0;
  color: var(--control-glass-icon);
  background: var(--control-glass-bg);
  border: 1px solid var(--control-glass-border);
}

.composer-tools span:nth-child(n + 2) {
  color: var(--control-primary-icon);
  background: var(--control-primary-bg);
  border: 1px solid var(--control-glass-border);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.22),
    0 6px 18px rgb(15 23 42 / 0.12);
}

.output-panel {
  display: grid;
  gap: 12px;
  max-height: 30vh;
  padding: 10px 12px;
  overflow: auto;
}

.output-panel summary {
  cursor: pointer;
  list-style: none;
}

.output-panel summary::-webkit-details-marker {
  display: none;
}

.output-panel pre {
  max-height: 260px;
  margin: 0;
  overflow: auto;
  color: #dbeafe;
  background: #111827;
  border-radius: 8px;
  padding: 14px;
  font-family: "SFMono-Regular", "JetBrains Mono", "SF Mono", Menlo, monospace;
  font-size: 12px;
  line-height: 1.55;
}

@keyframes applied-pulse {
  0% {
    box-shadow:
      0 0 0 0 rgb(1 105 204 / 0.55),
      0 24px 70px rgb(25 40 60 / 0.18);
  }
  42% {
    box-shadow:
      0 0 0 10px rgb(1 105 204 / 0.22),
      0 24px 70px rgb(25 40 60 / 0.18);
  }
  100% {
    box-shadow:
      0 0 0 0 rgb(1 105 204 / 0),
      0 24px 70px rgb(25 40 60 / 0.18);
  }
}

@keyframes night-drift {
  from {
    transform: translate3d(-0.8%, 0, 0) scale(1.02);
  }
  to {
    transform: translate3d(0.8%, -0.6%, 0) scale(1.04);
  }
}

@keyframes night-twinkle {
  0% {
    opacity: 0.52;
  }
  48% {
    opacity: 0.92;
  }
  100% {
    opacity: 0.62;
  }
}

@media (prefers-reduced-motion: reduce) {
  .preview-content::before,
  .preview-content::after {
    animation: none;
  }
}

@media (max-width: 920px) {
  body,
  .app-shell,
  .control-pane,
  .preview-pane {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  body {
    overflow: auto;
  }

  .app-shell,
  .preview-card {
    display: block;
  }

  .app-shell {
    max-width: none;
  }

  .preview-pane {
    display: block;
  }

  .preview-card,
  .output-panel {
    margin-top: 18px;
  }

  .preview-card {
    min-height: 720px;
  }

  .theme-grid,
  .button-grid,
  .compact-grid {
    grid-template-columns: 1fr;
  }
}
