:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-strong: #eef2f5;
  --text: #1b1f24;
  --muted: #66717f;
  --line: #d7dde4;
  --primary: #1769aa;
  --primary-dark: #0d4f84;
  --danger: #b3261e;
  --danger-dark: #8c1d18;
  --shadow: 0 18px 55px rgba(20, 31, 43, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: "Microsoft JhengHei", "PingFang TC", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
  min-height: 100vh;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 24px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.title-block {
  margin-bottom: 4px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 20px;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.field span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fbfcfd;
  font-weight: 600;
  outline: none;
}

input,
select {
  height: 42px;
  padding: 0 11px;
}

textarea {
  min-height: 104px;
  padding: 11px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.13);
}

input[type="range"] {
  padding: 0;
  accent-color: var(--primary);
}

input[type="color"] {
  height: 44px;
  padding: 5px;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.button-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.wide-button {
  grid-column: 1 / -1;
}

.button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  color: #ffffff;
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.primary {
  background: var(--primary);
}

.primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.secondary {
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.danger {
  background: var(--danger);
}

.danger:hover:not(:disabled) {
  background: var(--danger-dark);
}

.status {
  min-height: 38px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfd;
  font-size: 13px;
  line-height: 1.35;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) minmax(190px, 28vh);
  gap: 20px;
  min-width: 0;
  padding: 28px;
}

.preview-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.specs {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.preview-frame {
  display: grid;
  min-height: 0;
  place-items: center;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, #e8edf2 25%, transparent 25%),
    linear-gradient(-45deg, #e8edf2 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8edf2 75%),
    linear-gradient(-45deg, transparent 75%, #e8edf2 75%);
  background-color: #f8fafc;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.stage {
  position: relative;
  width: 640px;
  height: 360px;
  max-width: 100%;
  overflow: hidden;
  background: #050505;
  box-shadow: var(--shadow);
}

.marquee-track {
  position: absolute;
  left: 0;
  top: var(--marquee-y, 50%);
  display: inline-block;
  white-space: nowrap;
  color: #ffffff;
  font-size: 42px;
  font-weight: 700;
  line-height: 1;
  transform: translateY(-50%);
  animation: marquee-left 10s linear infinite;
  will-change: transform;
}

.marquee-track.is-paused {
  animation-play-state: paused;
}

@keyframes marquee-left {
  from {
    transform: translateX(var(--start-x)) translateY(-50%);
  }
  to {
    transform: translateX(var(--end-x)) translateY(-50%);
  }
}

@keyframes marquee-right {
  from {
    transform: translateX(var(--end-x)) translateY(-50%);
  }
  to {
    transform: translateX(var(--start-x)) translateY(-50%);
  }
}

.output-panel {
  display: grid;
  grid-template-rows: auto minmax(90px, 1fr);
  gap: 10px;
  min-height: 0;
}

.output-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

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

#embedCode {
  min-height: 0;
  height: 100%;
  font-family: "Courier New", monospace;
  font-size: 13px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .controls {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace {
    min-height: 720px;
    padding: 22px;
  }
}

@media (max-width: 560px) {
  .controls,
  .workspace {
    padding: 18px;
  }

  .grid-2,
  .button-row {
    grid-template-columns: 1fr;
  }

  .preview-header,
  .output-title {
    align-items: start;
    flex-direction: column;
  }

  .specs {
    white-space: normal;
  }
}
