:root {
  --ink: #082827;
  --ink-soft: #173e3c;
  --paper: #fffefa;
  --surface: #f4f2eb;
  --white: #ffffff;
  --line: #d7d5cc;
  --muted: #687471;
  --green: #2f865f;
  --green-soft: #e5f2e9;
  --coral: #e65b45;
  --coral-soft: #ffebe6;
  --amber: #e0ab43;
  --amber-soft: #fff2d5;
  --danger: #a53f33;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: Inter, "Noto Sans Thai", Tahoma, Arial, sans-serif;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--coral);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0;
}

.member-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 900;
}

.member-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  font-size: 20px;
  font-weight: 900;
  text-decoration: none;
}

.member-loading {
  display: grid;
  min-height: 100vh;
  place-items: center;
  align-content: center;
  gap: 16px;
  background: var(--ink);
  color: var(--paper);
}

.member-loading strong {
  font-size: 14px;
}

.auth-view {
  min-height: 100vh;
  grid-template-columns: minmax(360px, 0.9fr) minmax(480px, 1.1fr);
}

.auth-view:not([hidden]) {
  display: grid;
}

.auth-intro {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  justify-content: space-between;
  padding: 46px 54px;
  background: var(--ink);
  color: var(--paper);
}

.auth-intro .eyebrow {
  color: var(--amber);
}

.auth-intro h1 {
  margin: 0;
  font-size: 52px;
  line-height: 1.12;
  letter-spacing: 0;
}

.auth-intro p:not(.eyebrow) {
  max-width: 560px;
  margin: 20px 0 0;
  color: rgba(255, 254, 250, 0.72);
  font-size: 16px;
  line-height: 1.8;
}

.back-home {
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.auth-panel {
  display: flex;
  width: min(620px, 100%);
  flex-direction: column;
  justify-content: center;
  padding: 64px 72px;
  background: var(--paper);
}

.auth-heading h2 {
  margin: 0;
  font-size: 34px;
  letter-spacing: 0;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin-top: 28px;
  border-bottom: 1px solid var(--line);
}

.auth-tabs button {
  min-height: 44px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.auth-tabs button.is-active {
  border-bottom-color: var(--coral);
  color: var(--ink);
}

.line-login-wrap {
  margin-top: 22px;
}

.line-login-button {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 0;
  border-radius: 4px;
  background: #06c755;
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
}

.line-login-button span {
  border-right: 1px solid rgba(255, 255, 255, 0.45);
  padding-right: 12px;
  font-size: 10px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 10px;
}

.auth-divider::before,
.auth-divider::after {
  height: 1px;
  flex: 1;
  background: var(--line);
  content: "";
}

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

.auth-form label,
.campaign-create-form label,
.member-checkout-form > label,
.draft-review-form > label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.auth-form input,
.campaign-create-form input,
.campaign-create-form select,
.campaign-create-form textarea,
.member-checkout-form input,
.member-checkout-form select,
.draft-review-form input,
.draft-review-form textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 10px 11px;
  background: var(--white);
  color: var(--ink);
  outline-color: var(--coral);
}

.auth-form .full-field,
.campaign-create-form .full-field {
  grid-column: 1 / -1;
}

.asset-note {
  color: var(--green);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.5;
}

.campaign-progress {
  width: 110px;
  height: 6px;
  margin-bottom: 5px;
  overflow: hidden;
  background: var(--line);
}

.campaign-progress span {
  display: block;
  height: 100%;
  background: var(--green);
}

.progress-add {
  margin-top: 7px;
  border: 1px solid var(--green);
  padding: 5px 7px;
  background: transparent;
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
}

.auth-form > button {
  grid-column: 1 / -1;
  min-height: 48px;
  border: 0;
  background: var(--coral);
  color: var(--white);
  font-size: 13px;
  font-weight: 900;
}

.auth-form button:disabled,
.campaign-create-form button:disabled,
.checkout-confirm:disabled {
  cursor: wait;
  opacity: 0.65;
}

.auth-feedback,
.form-feedback {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
}

.member-app:not([hidden]) {
  display: block;
}

.member-sidebar {
  position: fixed;
  z-index: 4;
  inset: 0 auto 0 0;
  display: flex;
  width: 228px;
  flex-direction: column;
  padding: 28px 22px;
  background: var(--ink);
  color: var(--paper);
}

.member-sidebar nav {
  display: grid;
  gap: 5px;
  margin-top: 50px;
}

.member-sidebar nav a {
  min-height: 40px;
  padding: 11px 12px;
  color: rgba(255, 254, 250, 0.66);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.member-sidebar nav a:hover,
.member-sidebar nav a.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--paper);
}

.member-identity {
  display: grid;
  gap: 4px;
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding-top: 18px;
}

.member-identity strong {
  font-size: 13px;
}

.member-identity span {
  overflow: hidden;
  color: rgba(255, 254, 250, 0.58);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-identity button {
  justify-self: start;
  margin-top: 10px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--amber);
  font-size: 11px;
  font-weight: 800;
}

.member-main {
  min-height: 100vh;
  margin-left: 228px;
  padding: 34px 38px 72px;
}

.member-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.member-topbar h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-actions a {
  border-bottom: 1px solid var(--coral);
  padding: 6px 0;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
}

.topbar-actions button {
  display: none;
  border: 0;
  padding: 6px 0;
  background: transparent;
  color: var(--coral);
  font-size: 11px;
  font-weight: 800;
}

.member-section {
  margin-top: 42px;
  scroll-margin-top: 24px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.section-heading h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.section-heading > span {
  max-width: 420px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  text-align: right;
}

.member-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.member-stats article {
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 18px;
  background: var(--paper);
}

.member-stats span,
.member-stats strong,
.member-stats small {
  display: block;
}

.member-stats span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.member-stats strong {
  margin-top: 12px;
  font-size: 22px;
  line-height: 1.15;
}

.member-stats small {
  margin-top: 9px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.plan-band {
  display: flex;
  min-height: 112px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 12px;
  padding: 24px 28px;
  background: var(--amber-soft);
}

.plan-band.is-active {
  background: var(--green-soft);
}

.plan-band h3 {
  margin: 0;
  font-size: 20px;
}

.plan-band a {
  min-height: 40px;
  border: 1px solid var(--ink);
  padding: 10px 16px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 900;
  text-decoration: none;
}

.campaign-section,
.draft-section,
.billing-section,
.order-section {
  border: 1px solid var(--line);
  padding: 26px;
  background: var(--paper);
}

.campaign-create-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
  margin-top: 24px;
}

.campaign-create-form textarea {
  min-height: 150px;
  resize: vertical;
}

.campaign-create-form input[type="file"] {
  padding: 8px;
}

.permission-control {
  display: flex !important;
  align-items: flex-start;
  grid-template-columns: none !important;
  gap: 10px !important;
  border: 1px solid #bdd7c7;
  padding: 13px;
  background: #f0f8f3;
  color: var(--ink) !important;
  font-size: 11px !important;
  line-height: 1.6;
}

.permission-control input {
  width: 17px;
  min-height: 17px;
  flex: 0 0 17px;
  margin-top: 1px;
  accent-color: var(--green);
}

.campaign-create-form > button {
  min-height: 46px;
  justify-self: start;
  border: 0;
  padding: 10px 18px;
  background: var(--coral);
  color: var(--white);
  font-size: 12px;
  font-weight: 900;
}

.campaign-table-wrap {
  overflow-x: auto;
  margin-top: 26px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

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

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

td strong,
td small {
  display: block;
}

td strong {
  color: var(--ink);
  font-size: 11px;
}

td small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.status-pill {
  display: inline-block;
  padding: 5px 8px;
  background: var(--amber-soft);
  color: #8a5a09;
  font-size: 9px;
  font-weight: 900;
}

.status-paid,
.status-active,
.status-approved,
.status-published {
  background: var(--green-soft);
  color: #246c4a;
}

.status-expired,
.status-gateway_error,
.status-canceled,
.status-ai_error,
.status-rejected,
.status-revision_requested,
.status-quota_exceeded {
  background: var(--coral-soft);
  color: var(--danger);
}

.draft-list {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.draft-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px 112px;
  gap: 18px;
  align-items: center;
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  padding: 16px 18px;
  background: var(--white);
}

.draft-card.is-approved {
  border-left-color: var(--green);
}

.draft-card.is-rejected {
  border-left-color: var(--coral);
}

.draft-card strong,
.draft-card span,
.draft-card small {
  display: block;
}

.draft-card strong {
  font-size: 14px;
  line-height: 1.4;
}

.draft-card span,
.draft-card small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.draft-card button {
  min-height: 38px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-size: 10px;
  font-weight: 900;
}

.draft-dialog {
  width: min(840px, calc(100% - 30px));
}

.draft-review-form {
  display: grid;
  gap: 15px;
}

.draft-review-form textarea {
  min-height: 360px;
  resize: vertical;
  line-height: 1.65;
}

.draft-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  border: 1px solid var(--line);
  padding: 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 10px;
}

.draft-dialog-actions {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
}

.draft-dialog-actions button {
  min-height: 44px;
  border: 0;
  padding: 9px 14px;
  font-size: 11px;
  font-weight: 900;
}

.draft-reject {
  background: var(--coral-soft);
  color: var(--danger);
}

.draft-save {
  background: var(--ink);
  color: var(--white);
}

.draft-approve {
  background: var(--green);
  color: var(--white);
}

.empty-row {
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.member-plan-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.member-plan {
  display: flex;
  min-height: 320px;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 20px;
  background: var(--white);
}

.member-plan.is-featured {
  border-top: 5px solid var(--coral);
}

.member-plan h3 {
  margin: 4px 0 0;
  font-size: 20px;
}

.member-plan > p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.member-plan .plan-price {
  margin-top: 14px;
  color: var(--ink);
  font-size: 28px;
  font-weight: 900;
}

.member-plan .plan-price small {
  color: var(--muted);
  font-size: 10px;
}

.member-plan ul {
  display: grid;
  gap: 7px;
  margin: 16px 0 22px;
  padding: 0;
  color: var(--muted);
  font-size: 10px;
  list-style: none;
}

.member-plan li::before {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 8px;
  background: var(--green);
  content: "";
}

.member-plan button {
  min-height: 42px;
  margin-top: auto;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-size: 11px;
  font-weight: 900;
}

.member-plan button:disabled {
  cursor: not-allowed;
  border-color: var(--line);
  background: var(--surface);
  color: var(--muted);
}

.member-checkout-dialog {
  width: min(560px, calc(100% - 30px));
  max-height: calc(100% - 30px);
  overflow: auto;
  border: 0;
  border-radius: 4px;
  padding: 0;
  background: var(--paper);
  box-shadow: 0 24px 70px rgba(8, 40, 39, 0.32);
}

.member-checkout-dialog::backdrop {
  background: rgba(8, 40, 39, 0.72);
}

.member-checkout-form {
  position: relative;
  padding: 34px;
}

.member-checkout-form h2 {
  margin: 0;
  font-size: 28px;
}

.member-checkout-form > p:not(.eyebrow):not(.form-feedback) {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.dialog-close {
  position: absolute;
  top: 13px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #ece9e1;
  color: var(--ink);
  font-size: 22px;
}

.checkout-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin: 24px 0 18px;
  padding: 14px;
  background: var(--surface);
}

.checkout-summary span,
.checkout-summary strong {
  display: block;
}

.checkout-summary span,
.checkout-summary label {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

.checkout-summary strong {
  margin-top: 5px;
  font-size: 12px;
}

.checkout-summary select {
  min-height: 28px;
  margin-top: 3px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
}

.checkout-confirm {
  width: 100%;
  min-height: 48px;
  margin-top: 18px;
  border: 0;
  background: var(--coral);
  color: var(--white);
  font-size: 12px;
  font-weight: 900;
}

@media (max-width: 1080px) {
  .member-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .member-plan-grid {
    grid-template-columns: 1fr;
  }

  .draft-card {
    grid-template-columns: 1fr;
  }

  .member-plan {
    min-height: auto;
  }
}

@media (max-width: 760px) {
  .auth-view {
    grid-template-columns: 1fr;
  }

  .auth-intro {
    min-height: 360px;
    padding: 28px 22px;
  }

  .auth-intro h1 {
    font-size: 38px;
  }

  .auth-intro p:not(.eyebrow) {
    font-size: 14px;
  }

  .auth-panel {
    width: 100%;
    padding: 42px 22px 60px;
  }

  .auth-form,
  .campaign-create-form {
    grid-template-columns: 1fr;
  }

  .auth-form .full-field,
  .campaign-create-form .full-field,
  .auth-form > button {
    grid-column: auto;
  }

  .member-sidebar {
    position: static;
    width: 100%;
    padding: 16px 20px;
  }

  .member-sidebar nav {
    display: flex;
    overflow-x: auto;
    gap: 3px;
    margin-top: 14px;
    padding-bottom: 3px;
  }

  .member-sidebar nav a {
    flex: 0 0 auto;
  }

  .member-identity {
    display: none;
  }

  .member-main {
    margin-left: 0;
    padding: 26px 18px 54px;
  }

  .member-topbar,
  .section-heading,
  .plan-band {
    display: block;
  }

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

  .topbar-actions {
    margin-top: 15px;
  }

  .topbar-actions a,
  .topbar-actions button {
    display: inline-block;
  }

  .section-heading > span {
    display: block;
    margin-top: 8px;
    text-align: left;
  }

  .member-stats {
    grid-template-columns: 1fr;
  }

  .plan-band a {
    display: inline-flex;
    margin-top: 18px;
  }

  .campaign-section,
  .draft-section,
  .billing-section,
  .order-section {
    padding: 20px;
  }

  .checkout-summary {
    grid-template-columns: 1fr;
  }

  .member-checkout-form {
    padding: 32px 21px 24px;
  }

  .draft-review-form textarea {
    min-height: 300px;
  }

  .draft-dialog-actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
