/* 字型改由 ./fonts/fonts.css 載入 (cn-font-split 分包 woff2, unicode-range 按需下載) */

:root {
  color-scheme: dark;
  --bg: #001a35;
  --bg2: #27292d;
  --paper: #1a2735;
  --ink: #eff1f4;
  --muted: #b4b9c2;
  --line: #273048;
  --accent: #00b8ff;
  --accent-dark: #73c2ff;
  --teal: #01b96b;
  --danger: #fc6369;
  --surface: rgba(26, 39, 53, 0.86);
  --surface2: rgba(47, 35, 59, 0.82);
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.32);
  font-family:
    Inter, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui,
    sans-serif;
}

* {
  box-sizing: border-box;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(180, 185, 194, 0.34) rgba(255, 255, 255, 0.08);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  border: 3px solid rgba(0, 26, 53, 0.66);
  border-radius: 999px;
  background: rgba(180, 185, 194, 0.34);
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(180, 185, 194, 0.58);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 78% 6%, rgba(0, 184, 255, 0.16), transparent 30%),
    linear-gradient(to bottom, #001a35 0%, #001a35 36%, #27292d 100%);
  color: var(--ink);
}

.font-preload-probe {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.probe-zihun {
  font-family: "Local Zihun Biantao";
}

.probe-genseki-h {
  font-family: "Local GenSeki File H";
  font-weight: 900;
}

.probe-genseki-m {
  font-family: "Local GenSeki File M";
  font-weight: 500;
}

.font-loader {
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 24px;
  color: #bdefff;
  font-size: 12px;
  font-weight: 900;
}

.font-loading .font-loader {
  display: flex;
}

.font-ready .font-loader {
  display: none;
}

.font-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(189, 239, 255, 0.26);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: font-spin 0.72s linear infinite;
}

.font-progress {
  overflow: hidden;
  width: 74px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.font-progress i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  transition: width 0.22s ease;
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) auto;
  gap: 22px;
  align-items: center;
  min-height: 96px;
  padding: 18px 24px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  background:
    linear-gradient(90deg, rgba(0, 15, 31, 0.95), rgba(26, 39, 53, 0.88)),
    radial-gradient(circle at 18% 0%, rgba(0, 184, 255, 0.12), transparent 32%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.header-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  display: grid;
  place-items: center;
  width: 132px;
  min-width: 132px;
  height: 46px;
}

.brand-logo img {
  display: block;
  width: 132px;
  height: auto;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  letter-spacing: 0;
  line-height: 1.05;
}

.brand-kicker {
  display: block;
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.brand p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
}

.steps {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  padding: 8px;
  border: 1px solid rgba(39, 48, 72, 0.92);
  border-radius: 999px;
  background: rgba(0, 15, 31, 0.72);
}

.steps span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid transparent;
  font-weight: 800;
}

.steps b {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  font-size: 11px;
}

.steps .done {
  color: var(--teal);
  background: rgba(1, 185, 107, 0.1);
  border-color: rgba(1, 185, 107, 0.28);
}

.steps .done b {
  background: rgba(1, 185, 107, 0.18);
}

.steps .active {
  color: var(--accent);
  background: rgba(0, 184, 255, 0.1);
  border-color: rgba(0, 184, 255, 0.36);
}

.steps .active b {
  background: rgba(0, 184, 255, 0.18);
}

.ghost,
.primary,
.secondary {
  border: 0;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.ghost {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.workspace {
  display: grid;
  grid-template-columns: 310px minmax(420px, 1fr) 360px;
  gap: 18px;
  margin-top: 18px;
  height: calc(100vh - 140px);
  min-height: 680px;
}

.panel,
.preview-wrap {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  overflow: auto;
}

.upload {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 118px;
  border: 2px dashed rgba(0, 184, 255, 0.28);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(0, 34, 71, 0.86), rgba(26, 39, 53, 0.82));
  text-align: center;
}

.upload input {
  display: none;
}

.upload strong {
  font-size: 18px;
}

.upload span {
  color: var(--muted);
  font-size: 13px;
}

.field {
  display: grid;
  gap: 8px;
}

.is-hidden {
  display: none !important;
}

.field label {
  color: #d7dbe3;
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 15, 31, 0.66);
  color: var(--ink);
  min-height: 44px;
  padding: 0 13px;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0, 184, 255, 0.12);
}

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

.field input[type="color"] {
  min-height: 38px;
  padding: 3px;
  cursor: pointer;
}

.color-control {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 5px 7px;
  align-items: center;
  min-width: 0;
}

.color-control input[type="color"] {
  height: 44px;
  width: 42px;
  min-width: 42px;
}

.color-code {
  min-height: 44px;
  width: 100%;
  min-width: 0;
  font-family: Consolas, "SFMono-Regular", monospace;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 12px;
  padding: 0 7px;
}

.color-code.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(252, 99, 105, 0.12);
}

.color-copy {
  grid-column: 2;
  justify-self: end;
  min-height: 18px;
  height: 18px;
  max-width: 44px;
  border: 1px solid rgba(0, 184, 255, 0.2);
  border-radius: 7px;
  background: rgba(0, 184, 255, 0.1);
  color: #9feeff;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0;
  padding: 0 6px;
  text-transform: uppercase;
}

.split .color-control {
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 4px 6px;
}

.split .color-control input[type="color"] {
  width: 40px;
  min-width: 40px;
}

.split .color-code {
  font-size: 11px;
  padding: 0 6px;
}

.color-copy:hover {
  background: rgba(0, 184, 255, 0.18);
  color: #d7f7ff;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  max-height: 244px;
  overflow: auto;
  padding-right: 4px;
}

.template,
.pos {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 15, 31, 0.54);
  min-height: 44px;
  color: var(--muted);
  font-weight: 800;
}

.template {
  min-height: 38px;
  padding: 0 10px;
  font-size: 13px;
  text-align: center;
}

.template.selected,
.pos.selected {
  border-color: var(--accent);
  background: rgba(0, 184, 255, 0.12);
  color: var(--accent);
}

.range-row {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.type-controls {
  gap: 9px;
}

.viral-controls {
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(0, 184, 255, 0.18);
  border-radius: 16px;
  background: rgba(0, 184, 255, 0.06);
}

.viral-controls .split {
  grid-template-columns: 1fr;
}

.type-row {
  display: grid;
  grid-template-columns: 74px 1fr;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.type-row span {
  font-weight: 800;
  color: #d7dbe3;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.toggles {
  gap: 10px;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 15, 31, 0.5);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.check input {
  width: 18px;
  height: 18px;
  min-height: 0;
  accent-color: var(--accent);
}

.primary {
  margin-top: auto;
  background: #c2c6ff;
  color: var(--bg);
}

.secondary {
  border: 1px solid var(--line);
  background: rgba(0, 184, 255, 0.1);
  color: var(--accent);
}

.preview-wrap {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.preview-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.preview-head h2 {
  margin-top: 4px;
  font-size: 24px;
}

.status {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(1, 185, 107, 0.12);
  color: var(--teal);
  font-weight: 900;
  white-space: nowrap;
}

.stage {
  display: grid;
  place-items: center;
  padding: 22px;
  overflow: hidden;
}

#mainCanvas {
  display: block;
  max-width: min(100%, 680px);
  max-height: calc(100vh - 250px);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  background:
    linear-gradient(45deg, rgba(255,255,255,.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,.08) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,.08) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.08) 75%);
  background-size: 28px 28px;
  background-position:
    0 0,
    0 14px,
    14px -14px,
    -14px 0;
  cursor: grab;
  touch-action: none;
}

#mainCanvas:active {
  cursor: grabbing;
}

.outputs {
  padding: 18px;
  overflow: auto;
}

.outputs-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin-bottom: 14px;
}

.format-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.format-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(0, 15, 31, 0.5);
  padding: 10px;
  text-align: left;
}

.format-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0, 184, 255, 0.12);
}

.format-card canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  background: transparent;
}

.format-card strong {
  display: block;
  margin-top: 8px;
  font-size: 14px;
}

.format-card span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1150px) {
  .topbar,
  .workspace {
    grid-template-columns: 1fr;
    height: auto;
  }

  .steps {
    justify-content: start;
    overflow: auto;
    width: 100%;
  }

  .workspace {
    min-height: 0;
  }

  #mainCanvas {
    max-height: 70vh;
  }
}
