:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --paper: #fffdf8;
  --ink: #202124;
  --muted: #6c655d;
  --line: #ddd3c5;
  --accent: #256f5b;
  --accent-dark: #174a3d;
  --danger: #b23b3b;
  --gold: #c2832b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px clamp(18px, 4vw, 56px);
  background: rgba(255, 253, 248, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent-dark);
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 15px;
}

main {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.hero {
  min-height: 260px;
  display: grid;
  align-items: end;
  padding: clamp(32px, 7vw, 72px);
  color: white;
  background:
    linear-gradient(90deg, rgba(23, 74, 61, 0.9), rgba(23, 74, 61, 0.35)),
    url("https://images.unsplash.com/photo-1551218808-94e220e084d2?auto=format&fit=crop&w=1600&q=80") center/cover;
  border-radius: 8px;
}

.hero h1 {
  margin: 6px 0 10px;
  font-size: clamp(40px, 7vw, 74px);
  line-height: 1;
}

.hero p {
  max-width: 620px;
  margin: 0;
  font-size: 18px;
}

.eyebrow,
.card-meta {
  color: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.chip {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
}

.chip.active,
.button,
button {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.menu-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.menu-column,
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.menu-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.menu-column header {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
  background: #f3efe7;
}

.menu-column header h2 {
  margin: 4px 0 0;
  color: var(--accent-dark);
  font-size: 24px;
}

.menu-list {
  display: grid;
  gap: 0;
}

.menu-other {
  margin-top: 18px;
}

.menu-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.menu-row:last-child {
  border-bottom: 0;
}

.menu-row h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.menu-row p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.menu-row strong {
  color: var(--accent-dark);
  font-size: 18px;
  white-space: nowrap;
}

.column-empty {
  margin: 0;
  padding: 18px;
  color: var(--muted);
}

.placeholder {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--accent-dark);
  font-size: 28px;
  font-weight: 800;
}

.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--gold);
  color: white;
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  color: white;
  font-size: 13px;
  font-weight: 700;
}

.status-pill.is-active {
  background: var(--accent);
}

.status-pill.is-inactive {
  background: var(--danger);
}

.preview-info .status-pill,
.preview-text-row .status-pill {
  color: white;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.toolbar h1,
.panel h1 {
  margin: 0 0 8px;
}

.toolbar p {
  margin: 0;
  color: var(--muted);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 24px 0 12px;
}

.section-heading h2 {
  margin: 0;
  color: var(--accent-dark);
}

.panel {
  padding: 22px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.tab {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  color: var(--muted);
  font-weight: 800;
}

.tab.active {
  margin-bottom: -1px;
  border-color: var(--line);
  background: var(--paper);
  color: var(--accent-dark);
}

.preview-screens {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.preview-screen {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fffaf0;
}

.preview-screen header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #f3efe7;
}

.preview-screen h2 {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 20px;
}

.preview-screen header span,
.preview-info span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

.preview-sort-form {
  display: grid;
  gap: 12px;
}

.helper-text {
  margin: -6px 0 10px;
  color: var(--muted);
  font-size: 14px;
}

.preview-slot {
  min-height: 220px;
}

.preview-slot.drop-target {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 8px;
}

.preview-slot.dragging {
  opacity: 0.45;
}

.preview-slot-locked {
  position: relative;
}

.preview-card {
  min-height: 220px;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.preview-draggable {
  cursor: grab;
}

.preview-draggable:active {
  cursor: grabbing;
}

.preview-locked-card {
  background: #f6f0e5;
}

.preview-lock-note {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(32, 33, 36, 0.7);
  color: white;
  font-size: 12px;
  font-weight: 800;
}

.preview-empty-cell {
  display: grid;
  place-items: center;
  border-style: dashed;
  background: #faf7f0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.preview-image {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #eadfce;
}

.preview-image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.preview-placeholder {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.preview-text-card {
  display: grid;
  align-content: start;
}

.preview-text-list {
  display: grid;
  gap: 8px;
}

.preview-text-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.preview-text-row:last-child {
  border-bottom: 0;
}

.preview-text-row span {
  min-width: 0;
  font-weight: 800;
}

.preview-text-row strong {
  color: var(--accent-dark);
  white-space: nowrap;
}

.preview-info {
  display: grid;
  gap: 4px;
  padding: 10px;
}

.preview-info h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
}

.preview-info strong {
  color: var(--accent-dark);
  font-size: 16px;
}

.preview-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ad-preview {
  min-height: 420px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff8ed;
  overflow: hidden;
}

.ad-preview-text {
  padding: clamp(28px, 6vw, 72px);
  color: var(--accent-dark);
  font-size: clamp(42px, 7vw, 84px);
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  white-space: pre-line;
}

.ad-preview-image img,
.ad-preview-logo img {
  max-width: 100%;
  max-height: 70vh;
  display: block;
  object-fit: contain;
}

.ad-preview-logo {
  background: white;
}

.embedded-ad-preview {
  min-height: 220px;
  height: 100%;
  border-radius: 8px;
}

.embedded-ad-preview.ad-preview-text {
  padding: 18px;
  font-size: clamp(24px, 4vw, 42px);
}

.embedded-ad-preview.ad-preview-image img,
.embedded-ad-preview.ad-preview-logo img {
  max-height: 100%;
}

.narrow {
  max-width: 440px;
  margin: 44px auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 13px;
}

.sort-link {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  color: var(--accent-dark);
  font-weight: 800;
}

.sort-link:hover {
  text-decoration: underline;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 7px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font: inherit;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 10px 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.ghost {
  background: transparent;
  color: var(--accent-dark);
}

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

.actions,
.form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.stack {
  display: grid;
  gap: 16px;
}

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

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

.check {
  display: flex;
  gap: 8px;
  align-items: center;
}

.check input {
  width: auto;
  margin: 0;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr 140px auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 20px;
}

.notice,
.empty {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #b9d9cc;
  border-radius: 6px;
  background: #e9f6f0;
  color: var(--accent-dark);
}

.sql-box {
  max-height: 60vh;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #171b1f;
  color: #f2f0ea;
  font-size: 13px;
  line-height: 1.55;
}

@media (max-width: 720px) {
  .topbar,
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid-form,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .menu-columns {
    grid-template-columns: 1fr;
  }

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

  .actions {
    flex-wrap: wrap;
  }

  table {
    display: block;
    overflow-x: auto;
  }
}
