:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-soft: #fbfaf7;
  --ink: #202322;
  --muted: #70766f;
  --faint: #e7e2d8;
  --line: #d9d4ca;
  --accent: #1d7f68;
  --accent-dark: #155c4c;
  --blue: #3267c9;
  --green: #06c755;
  --threads: #1b1b1b;
  --dcard: #2f80ed;
  --warning: #a65f00;
  --error: #b42318;
  --shadow: 0 18px 45px rgba(50, 45, 34, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.75), rgba(246, 244, 239, 0) 280px),
    var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto;
  padding: 30px 0 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
  letter-spacing: 0;
}

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

.subhead {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.topbar-actions {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding-top: 16px;
}

.primary-button,
.ghost-button,
.case-card,
.segment {
  min-height: 42px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0 18px;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.primary-button {
  background: var(--accent);
  color: white;
  box-shadow: 0 10px 24px rgba(29, 127, 104, 0.22);
}

.primary-button:hover {
  background: var(--accent-dark);
}

.ghost-button,
.case-card {
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  border-color: var(--line);
}

.ghost-button:hover,
.case-card:hover {
  background: #fff;
  border-color: #bfb8aa;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 20px;
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto 48px;
}

.editor-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mode-card,
.warnings-card,
.matrix-card {
  min-width: 0;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(217, 212, 202, 0.9);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.mode-card {
  padding: 18px;
}

.editor-panel {
  position: sticky;
  top: 18px;
  align-self: start;
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding-right: 2px;
}

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

.pill,
.dirty-state {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: #eef6f2;
  color: var(--accent-dark);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
}

.dirty-state {
  background: #f3efe6;
  color: var(--muted);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: #eee9df;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}

.segmented.compact {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(84px, 1fr));
}

.segment {
  min-height: 36px;
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 0 12px;
  font-weight: 700;
}

.segment.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 6px 16px rgba(48, 43, 34, 0.1);
}

.hidden {
  display: none !important;
}

label {
  display: block;
  margin: 14px 0 7px;
  color: #414641;
  font-size: 13px;
  font-weight: 740;
}

input,
textarea,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus,
button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 127, 104, 0.15);
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.section-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.inline-action {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.case-grid {
  display: grid;
  gap: 8px;
}

.case-card {
  display: grid;
  gap: 4px;
  border-radius: 14px;
  min-height: 78px;
  padding: 12px;
  text-align: left;
}

.case-card.active {
  border-color: rgba(29, 127, 104, 0.45);
  background: #f1faf6;
  box-shadow: inset 0 0 0 1px rgba(29, 127, 104, 0.16);
}

.case-label {
  color: var(--ink);
  font-size: 14px;
  font-weight: 840;
}

.case-summary {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.template-guidance {
  display: grid;
  gap: 10px;
}

.guidance-intent {
  margin-bottom: 2px;
  color: #414641;
  font-size: 13px;
  font-weight: 720;
  line-height: 1.5;
}

.guidance-item {
  border: 1px solid #eee8dd;
  border-radius: 12px;
  background: #fffdf9;
  padding: 10px 11px;
}

.guidance-label {
  display: block;
  margin-bottom: 4px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.guidance-copy {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.guidance-source {
  margin: 0;
  color: #9a9287;
  font-size: 11px;
  line-height: 1.4;
}

.preview-panel {
  min-width: 0;
}

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

.notice {
  border: 1px solid #d7caa7;
  background: #fff8e5;
  color: #69501a;
  border-radius: 16px;
  padding: 13px 15px;
  margin-bottom: 14px;
  font-size: 13px;
  line-height: 1.45;
}

.warnings-card,
.matrix-card {
  padding: 16px;
  margin-bottom: 14px;
}

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

.warning-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px;
  align-items: start;
  color: var(--muted);
  font-size: 13px;
}

.warning-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  margin-top: 5px;
  background: var(--accent);
}

.warning-item.error .warning-dot {
  background: var(--error);
}

.warning-item.warning .warning-dot {
  background: var(--warning);
}

.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.preview-grid.mobile-sim {
  grid-template-columns: 1fr;
  max-width: 430px;
}

.preview-grid.mobile-sim .platform-shell.mobile-hidden {
  display: none;
}

.platform-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.platform-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid #ece7dd;
}

.platform-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 820;
}

.platform-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: #fff;
  font-size: 12px;
  font-weight: 850;
}

.platform-icon.facebook {
  background: var(--blue);
}

.platform-icon.line {
  background: var(--green);
}

.platform-icon.threads {
  background: var(--threads);
}

.platform-icon.dcard {
  background: var(--dcard);
}

.confidence {
  border-radius: 999px;
  background: #f3efe6;
  color: var(--muted);
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 760;
  white-space: nowrap;
}

.platform-body {
  padding: 16px;
}

.native-context {
  border-radius: 16px;
  background: var(--surface-soft);
  padding: 14px;
}

.facebook-card {
  overflow: hidden;
  border: 1px solid #dddfe2;
  border-radius: 8px;
  background: #fff;
  font-family: Arial, Helvetica, sans-serif;
}

.facebook-card.thumbnail {
  display: grid;
  grid-template-columns: 126px 1fr;
}

.preview-image {
  display: block;
  width: 100%;
  min-height: 130px;
  object-fit: cover;
  background: linear-gradient(135deg, #dfe6da, #f7f2e8);
}

.facebook-card.large .preview-image {
  aspect-ratio: 1.91 / 1;
  min-height: 0;
}

.facebook-card.thumbnail .preview-image {
  height: 126px;
  min-height: 126px;
}

.image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 130px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
  background: repeating-linear-gradient(45deg, #f6f1e8, #f6f1e8 12px, #eee7db 12px, #eee7db 24px);
}

.facebook-card.text-only .card-copy,
.line-bubble.text-only .card-copy,
.dcard-row.text-only {
  border: 0;
}

.facebook-card.text-only {
  border-left: 4px solid #d8dde5;
}

.line-bubble.text-only {
  overflow: visible;
}

.threads-card.text-only {
  grid-template-columns: 1fr;
}

.dcard-row.text-only {
  grid-template-columns: 1fr;
}

.no-card-note {
  border: 1px dashed #d8d8d8;
  border-radius: 12px;
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  background: #fafafa;
}

.card-copy {
  padding: 12px;
  min-width: 0;
}

.source-line {
  color: #606770;
  font-size: 12px;
  text-transform: uppercase;
}

.card-title {
  display: -webkit-box;
  overflow: hidden;
  margin: 5px 0 3px;
  color: #1d2129;
  font-size: 16px;
  font-weight: 720;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.card-description {
  display: -webkit-box;
  overflow: hidden;
  color: #606770;
  font-size: 13px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.line-chat {
  background: #8fb8da;
  border-radius: 18px;
  padding: 16px;
}

.line-bubble {
  max-width: 330px;
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
}

.line-bubble .preview-image {
  aspect-ratio: 1.91 / 1;
  min-height: 0;
}

.line-bubble .card-title {
  font-size: 14px;
}

.threads-post {
  border: 1px solid #e5e5e5;
  border-radius: 18px;
  background: #fff;
  padding: 14px;
  color: #111;
  font-family: Arial, Helvetica, sans-serif;
}

.threads-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1d7f68, #a7d7c5);
}

.post-text {
  margin-bottom: 12px;
  color: #222;
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.threads-card {
  display: grid;
  grid-template-columns: 96px 1fr;
  overflow: hidden;
  border: 1px solid #d8d8d8;
  border-radius: 12px;
}

.threads-card .preview-image {
  height: 96px;
  min-height: 96px;
}

.threads-card .card-copy {
  padding: 9px;
}

.threads-card .card-title {
  font-size: 13px;
  -webkit-line-clamp: 2;
}

.dcard-row {
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 12px;
  padding: 14px;
  border: 1px solid #dbe6f4;
  border-radius: 14px;
  background: #fff;
  font-family: Arial, Helvetica, sans-serif;
}

.dcard-row .preview-image,
.dcard-row .image-placeholder {
  width: 112px;
  height: 84px;
  min-height: 84px;
  border-radius: 10px;
}

.dcard-board {
  margin-bottom: 6px;
  color: var(--dcard);
  font-size: 12px;
  font-weight: 800;
}

.platform-caveat {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.platform-warnings {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.mini-warning {
  border-radius: 999px;
  background: #f7efe2;
  color: #755118;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 720;
}

.matrix {
  overflow-x: auto;
}

.matrix table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
  font-size: 13px;
}

.matrix th,
.matrix td {
  border-bottom: 1px solid #eee8dd;
  padding: 10px 8px;
  text-align: left;
}

.matrix th {
  color: var(--muted);
  font-size: 12px;
}

.used {
  color: var(--accent-dark);
  font-weight: 850;
}

.ignored {
  color: #b6aca0;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  border-radius: 999px;
  background: #17201c;
  color: #fff;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

.mobile-platform-tabs.segmented {
  display: none;
  margin-bottom: 12px;
}

.mobile-platform-tabs.segmented.active {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-radius: 16px;
}

.mobile-platform-tabs .segment {
  border-radius: 12px;
  min-width: 0;
  padding: 0 6px;
  font-size: 12px;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .editor-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 760px) {
  .topbar {
    display: block;
    width: calc(100% - 28px);
    max-width: 1480px;
  }

  .topbar-actions {
    flex-wrap: wrap;
    padding-top: 18px;
  }

  .workspace {
    width: calc(100% - 28px);
    max-width: 1480px;
  }

  .preview-panel {
    order: -1;
  }

  .panel-intro {
    align-items: flex-start;
    flex-direction: column;
  }

  .field-pair,
  .inline-action,
  .case-grid {
    grid-template-columns: 1fr;
  }

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