:root {
  --bg: #050505;
  --panel: rgba(15, 15, 15, 0.94);
  --panel-soft: rgba(11, 11, 11, 0.84);
  --line: rgba(229, 196, 133, 0.22);
  --line-strong: rgba(236, 214, 168, 0.5);
  --gold: #d9b06a;
  --gold-soft: #f0ddb7;
  --text: #f5f1e8;
  --muted: rgba(245, 241, 232, 0.62);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.42);
  --model-bar-height: 46px;
}

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

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

body {
  min-width: 320px;
  overflow: hidden;
  font-family: "Avenir Next", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(170, 126, 58, 0.14), transparent 22%),
    radial-gradient(circle at bottom right, rgba(121, 83, 20, 0.2), transparent 28%),
    linear-gradient(135deg, #010101 0%, #0a0907 44%, #040404 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(circle at center, black 42%, transparent 94%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.ambient {
  position: fixed;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  filter: blur(110px);
  pointer-events: none;
  opacity: 0.16;
}

.ambient-one {
  top: -170px;
  left: 15%;
  background: #c58b32;
}

.ambient-two {
  right: -130px;
  bottom: -180px;
  background: #9f6b1f;
}

.page-shell {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: grid;
  grid-template-columns: minmax(190px, 224px) minmax(0, 1fr) minmax(250px, 292px);
  gap: 10px;
  padding: calc(10px + var(--model-bar-height)) 10px 10px;
}

.shell-panel {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(16, 16, 16, 0.92), rgba(8, 8, 8, 0.96));
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.language-panel,
.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  overflow: hidden;
}

.settings-panel {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(217, 176, 106, 0.35) transparent;
}

.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}

.panel-topline,
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.preview-header {
  flex: 0 0 auto;
}

.panel-tag {
  color: var(--gold-soft);
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.panel-mini {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.panel-copy h1 {
  margin-top: 8px;
  font-family: Baskerville, "Times New Roman", serif;
  font-size: clamp(24px, 2.2vw, 34px);
  line-height: 0.95;
}

.panel-copy p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.language-accordion {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(217, 176, 106, 0.35) transparent;
}

.language-section {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-soft);
  overflow: hidden;
}

.language-trigger {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 11px 12px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
}

.language-identity,
.language-actions {
  display: flex;
  align-items: center;
}

.language-identity {
  gap: 10px;
}

.language-actions {
  gap: 7px;
}

.flag {
  min-width: 25px;
  color: var(--gold-soft);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.language-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.language-text strong {
  font-size: 13px;
}

.language-text small {
  color: var(--muted);
  font-size: 10px;
}

.usage-badge {
  min-width: 22px;
  padding: 2px 6px;
  border: 1px solid rgba(236, 214, 168, 0.24);
  border-radius: 999px;
  background: rgba(216, 176, 106, 0.12);
  color: var(--gold-soft);
  font-size: 10px;
  line-height: 1.1;
  text-align: center;
}

.language-arrow {
  color: var(--gold-soft);
  font-size: 14px;
  transition: transform 160ms ease;
}

.language-section.is-open .language-arrow {
  transform: rotate(180deg);
}

.language-body {
  max-height: 0;
  overflow: hidden;
  visibility: hidden;
  transition: max-height 180ms ease, visibility 0s linear 180ms;
}

.language-section.is-open .language-body {
  max-height: 220px;
  visibility: visible;
  transition-delay: 0s;
}

.vip-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 0 10px 10px;
}

.vip-btn,
.model-btn,
.header-btn,
.micro-btn,
.dir-btn {
  border: 1px solid rgba(214, 176, 113, 0.22);
  background: linear-gradient(180deg, rgba(32, 32, 32, 0.92), rgba(14, 14, 14, 0.98));
  color: var(--text);
  cursor: pointer;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    border-color 150ms ease,
    background 150ms ease;
}

.vip-btn {
  padding: 9px 6px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
}

.vip-btn:hover,
.vip-btn.active,
.model-btn:hover,
.model-btn.active,
.header-btn:hover,
.micro-btn:hover,
.dir-btn:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background:
    radial-gradient(circle at top, rgba(255, 224, 165, 0.22), transparent 68%),
    linear-gradient(180deg, rgba(74, 57, 26, 0.95), rgba(23, 18, 10, 0.98));
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
}

.vip-btn:focus-visible,
.model-btn:focus-visible,
.header-btn:focus-visible,
.micro-btn:focus-visible,
.dir-btn:focus-visible,
.language-trigger:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(240, 221, 183, 0.72);
  outline-offset: 2px;
}

.language-footnote {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.preview-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.preview-copy strong {
  color: var(--gold-soft);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.global-model-bar {
  position: fixed;
  top: 8px;
  left: 50%;
  z-index: 30;
  width: min(808px, calc(100vw - 36px));
  display: flex;
  justify-content: center;
  pointer-events: none;
  transform: translateX(-50%);
}

.global-model-bar .model-switcher {
  pointer-events: auto;
}

.model-switcher {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  min-width: 0;
}

.model-btn {
  width: 104px;
  min-width: 104px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 7px;
  row-gap: 1px;
  padding: 7px 10px;
  border-radius: 999px;
  text-align: left;
}

.model-btn span {
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: rgba(240, 221, 183, 0.88);
  color: #17100a;
  font-size: 11px;
  font-weight: 850;
}

.model-btn strong {
  color: var(--text);
  font-size: 11px;
  line-height: 1.05;
}

.model-btn small {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.06em;
}

.model-btn.is-link small {
  color: var(--gold-soft);
}

.model-btn.is-empty:not(.active) {
  border-style: dashed;
  opacity: 0.72;
}

.model-btn.active span {
  background: linear-gradient(180deg, #fff1cc, #d9b06a);
}

.model-btn:hover,
.model-btn.active {
  transform: none;
}

.preview-actions {
  display: flex;
  gap: 8px;
}

.header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  border-radius: 14px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

.header-btn.primary {
  border-color: rgba(236, 208, 158, 0.24);
  background:
    radial-gradient(circle at top, rgba(255, 228, 173, 0.28), transparent 70%),
    linear-gradient(180deg, rgba(96, 68, 20, 0.96), rgba(35, 24, 7, 1));
  color: #fff7eb;
}

.canvas-shell {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(230, 199, 138, 0.16);
  border-radius: 22px;
  background:
    radial-gradient(circle at top, rgba(116, 85, 34, 0.16), transparent 34%),
    linear-gradient(180deg, rgba(10, 10, 10, 0.94), rgba(2, 2, 2, 0.98));
  overflow: hidden;
}

canvas {
  display: block;
  width: min(100%, calc((100vh - 150px) * 1.7778));
  max-height: calc(100vh - 150px);
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: 18px;
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.35);
}

.state-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(4, 4, 4, 0.72);
  backdrop-filter: blur(10px);
}

.hidden {
  display: none;
}

.state-card {
  min-width: 220px;
  max-width: 88%;
  padding: 22px 24px;
  border: 1px solid rgba(230, 199, 138, 0.18);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(24, 20, 15, 0.94), rgba(9, 9, 9, 0.98));
  text-align: center;
}

.state-card p {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.state-error h2 {
  font-family: Baskerville, "Times New Roman", serif;
  font-size: 28px;
  color: var(--gold-soft);
}

.state-error .header-btn {
  margin-top: 14px;
}

.spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto;
  border: 2px solid rgba(255, 227, 173, 0.16);
  border-top-color: rgba(255, 228, 173, 0.92);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.settings-group {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-soft);
}

.settings-group + .settings-group {
  margin-top: 0;
}

.settings-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.settings-heading strong {
  font-family: Baskerville, "Times New Roman", serif;
  font-size: 18px;
  color: var(--gold-soft);
}

.settings-heading span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.settings-note {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.settings-field {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}

.settings-field span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
}

input[type="text"],
textarea {
  width: 100%;
  border: 1px solid rgba(230, 199, 138, 0.16);
  border-radius: 12px;
  background: rgba(7, 7, 7, 0.84);
  color: var(--text);
  padding: 9px 11px;
  font-size: 13px;
}

textarea {
  min-height: 66px;
  resize: none;
  line-height: 1.4;
}

input::placeholder,
textarea::placeholder {
  color: rgba(245, 241, 232, 0.34);
}

input:disabled,
textarea:disabled {
  cursor: not-allowed;
  color: rgba(245, 232, 197, 0.52);
  background: rgba(9, 8, 6, 0.46);
  border-color: rgba(230, 199, 138, 0.09);
}

input:focus,
textarea:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(229, 198, 134, 0.08);
  outline: none;
}

.file-control {
  min-height: 50px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid rgba(230, 199, 138, 0.16);
  border-radius: 12px;
  background: rgba(7, 7, 7, 0.84);
  cursor: pointer;
}

.file-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.file-control span {
  flex: 0 0 auto;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(207, 169, 103, 0.18);
  color: var(--gold-soft);
  font-size: 11px;
}

.file-control small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.button-row,
.move-grid {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

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

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

.micro-btn,
.dir-btn {
  border-radius: 14px;
}

.micro-btn {
  padding: 8px;
  font-size: 11px;
}

.dir-btn {
  padding: 8px 0;
  font-size: 13px;
}

.full-width {
  width: 100%;
  margin-top: 8px;
}

.value-display {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.value-display span {
  padding: 4px 8px;
  border: 1px solid rgba(230, 199, 138, 0.12);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--muted);
  font-size: 11px;
}

.value-display strong {
  color: var(--gold-soft);
}

.coords {
  margin-top: auto;
  padding: 9px 11px;
  border: 1px solid rgba(230, 199, 138, 0.12);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.speed-cache {
  position: fixed;
  left: 50%;
  bottom: 10px;
  z-index: 5;
  width: min(520px, calc(100vw - 28px));
  min-height: 34px;
  display: grid;
  grid-template-columns: auto minmax(96px, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid rgba(230, 199, 138, 0.18);
  border-radius: 999px;
  background: rgba(5, 5, 5, 0.74);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(14px);
  color: var(--muted);
  font-size: 10px;
}

.speed-cache-copy {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.speed-cache-copy strong {
  color: var(--gold-soft);
  font-size: 10px;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.speed-cache-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.speed-cache-meter {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(236, 214, 168, 0.12);
}

.speed-cache-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8b6832, #e8d4b1, #e4c18c);
  transition: width 220ms ease;
}

.speed-cache-count {
  color: var(--gold-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.toast {
  position: fixed;
  left: 50%;
  top: 24px;
  z-index: 20;
  max-width: calc(100vw - 40px);
  padding: 10px 16px;
  border: 1px solid rgba(236, 214, 168, 0.28);
  border-radius: 999px;
  background: rgba(12, 10, 7, 0.94);
  color: var(--gold-soft);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.36);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1100px) {
  .page-shell {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .preview-header {
    grid-template-columns: 1fr auto;
  }

  .settings-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
  }

  .settings-panel > .panel-topline,
  .settings-panel > .coords {
    grid-column: 1 / -1;
  }

  body {
    overflow: auto;
  }

  .page-shell {
    height: auto;
    min-height: 100vh;
    padding-bottom: 58px;
  }
}

@media (max-width: 760px) {
  :root {
    --model-bar-height: 92px;
  }

  .page-shell {
    grid-template-columns: 1fr;
  }

  .language-panel,
  .preview-panel,
  .settings-panel {
    min-height: auto;
  }

  .language-panel {
    max-height: 620px;
  }

  .preview-panel {
    min-height: 420px;
  }

  .settings-panel {
    display: flex;
  }

  canvas {
    width: 100%;
    max-height: none;
  }

  .speed-cache {
    grid-template-columns: 1fr auto;
  }

  .speed-cache-meter {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

@media (max-width: 480px) {
  :root {
    --model-bar-height: 184px;
  }

  .preview-header {
    align-items: flex-start;
  }

  .model-switcher {
    gap: 5px;
  }

  .model-btn {
    width: calc(50% - 3px);
    min-width: calc(50% - 3px);
  }

  .preview-actions {
    gap: 5px;
  }

  .header-btn {
    padding: 8px 10px;
  }
}
