:root {
  --ink: #17202a;
  --muted: #64707d;
  --line: #d8e0e4;
  --paper: #f7f8f5;
  --panel: #ffffff;
  --teal: #0f766e;
  --teal-dark: #0b4f49;
  --red: #b83b2f;
  --gold: #d99a2b;
  --navy: #243b53;
  --green: #2f6f5e;
  --shadow: 0 18px 50px rgba(23, 32, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Noto Sans Thai", "Tahoma", "Arial", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar,
.form-panel,
.output-panel,
.prompt-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 26px;
  border-radius: 8px;
}

.topbar h1,
.panel-heading h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 34px;
  line-height: 1.1;
}

.lead {
  max-width: 740px;
  margin: 10px 0 0;
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-btn,
.secondary-btn,
.icon-btn,
.platform-tab,
.copy-btn {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
}

.primary-btn {
  color: #fff;
  background: var(--teal);
}

.secondary-btn {
  color: var(--teal-dark);
  border-color: #9fcac3;
  background: #e9f5f2;
}

.icon-btn {
  width: 42px;
  padding: 0;
  color: var(--navy);
  border-color: var(--line);
  background: #fff;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(420px, 0.92fr) minmax(440px, 1.08fr);
  gap: 18px;
  margin-top: 18px;
}

.form-panel,
.output-panel,
.prompt-panel {
  border-radius: 8px;
  padding: 20px;
}

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

.panel-heading h2 {
  font-size: 21px;
  line-height: 1.25;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  color: var(--teal-dark);
  background: #e9f5f2;
  font-size: 12px;
  font-weight: 800;
}

.field-grid,
.spec-row {
  display: grid;
  gap: 12px;
}

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

.spec-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 12px 0;
}

label {
  display: grid;
  gap: 6px;
  color: #34414c;
  font-size: 13px;
  font-weight: 800;
}

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

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.upload-box {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  border: 1px dashed #9fcac3;
  border-radius: 8px;
  padding: 14px;
  background: #f2faf8;
}

.upload-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.brief-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
}

.brief-box h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.brief-box p {
  margin: 5px 0;
  color: var(--muted);
}

.brief-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.brief-item {
  border-left: 4px solid var(--teal);
  padding: 8px 10px;
  background: #eef7f4;
}

.brief-item strong {
  display: block;
  margin-bottom: 2px;
  color: var(--teal-dark);
  font-size: 12px;
}

.preview-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 16px 0 14px;
}

.platform-tab {
  color: var(--navy);
  border-color: var(--line);
  background: #fff;
}

.platform-tab.active {
  color: #fff;
  border-color: var(--navy);
  background: var(--navy);
}

.preview-stage {
  display: grid;
  place-items: center;
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #edf2f1;
  overflow: auto;
}

.ad-preview {
  display: grid;
  width: min(100%, 430px);
  overflow: hidden;
  border: 8px solid #fff;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 45px rgba(23, 32, 42, 0.2);
}

.ad-preview.facebook {
  aspect-ratio: 4 / 5;
}

.ad-preview.story {
  width: min(100%, 330px);
  aspect-ratio: 9 / 16;
}

.ad-preview.line {
  width: min(100%, 560px);
  aspect-ratio: 16 / 9;
  grid-template-columns: 58% 42%;
}

.ad-photo {
  position: relative;
  min-height: 0;
  background: #ccd8d4;
}

.ad-photo img {
  width: 100%;
  height: 100%;
  min-height: 210px;
  display: block;
  object-fit: cover;
}

.story .ad-photo img {
  min-height: 380px;
}

.line .ad-photo img {
  min-height: 100%;
}

.goal-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  border-radius: 8px;
  padding: 7px 11px;
  color: #fff;
  background: var(--red);
  font-size: 18px;
  font-weight: 900;
}

.ad-content {
  display: grid;
  gap: 8px;
  padding: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f4f7f1 100%);
}

.story .ad-content {
  align-content: end;
  padding: 14px;
}

.line .ad-content {
  align-content: center;
}

.ad-headline {
  margin: 0;
  color: var(--navy);
  font-size: 28px;
  font-weight: 950;
  line-height: 1.16;
}

.story .ad-headline {
  font-size: 25px;
}

.line .ad-headline {
  font-size: 22px;
}

.ad-location {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

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

.feature-list span {
  min-height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #cbd9d4;
  border-radius: 8px;
  color: var(--teal-dark);
  background: #e8f3ef;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 8px;
  padding: 10px;
  color: #fff;
  background: var(--teal-dark);
}

.price-row strong {
  color: #ffe7a5;
  font-size: 24px;
  line-height: 1.1;
}

.price-row span {
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.prompt-panel {
  margin-top: 18px;
}

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

.prompt-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.prompt-card h3 {
  margin: 0;
  font-size: 16px;
}

.prompt-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.prompt-card textarea {
  min-height: 210px;
  color: #283542;
  font-size: 13px;
  line-height: 1.55;
}

.copy-btn {
  color: var(--teal-dark);
  border-color: #9fcac3;
  background: #eff8f5;
}

.empty-state {
  grid-column: 1 / -1;
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  background: #fbfcfa;
}

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

  .preview-stage {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 10px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 18px;
  }

  .topbar h1 {
    font-size: 28px;
  }

  .topbar-actions,
  .field-grid,
  .spec-row,
  .brief-list {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    display: grid;
  }

  .ad-preview.line {
    grid-template-columns: 1fr;
    aspect-ratio: 4 / 5;
  }

  .price-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .price-row span {
    text-align: left;
  }
}
