:root {
  color-scheme: light;
  --ink: #15171c;
  --coal: #060606;
  --muted: #657083;
  --line: #dfe5ee;
  --paper: #f4f7fb;
  --panel: #ffffff;
  --gold: #e3c46d;
  --gold-deep: #9f7621;
  --gold-soft: #fff3c8;
  --naver: #03c75a;
  --kakao: #fee500;
  --danger: #c73535;
  --success: #078b4b;
  --radius: 8px;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f7f1e5;
  --muted: #b7c0ce;
  --line: #303947;
  --paper: #101319;
  --panel: #171b22;
  --gold-soft: #3e3113;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

button,
input,
textarea {
  font: inherit;
}

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

.brand-mark {
  display: block;
  width: 54px;
  height: 62px;
  object-fit: contain;
  flex: 0 0 auto;
}

.admin-logo-lockup {
  display: block;
  flex: 0 0 auto;
}

.admin-logo {
  display: block;
  width: min(300px, 58vw);
  max-height: 74px;
  object-fit: contain;
  object-position: left center;
}

.admin-logo-dark {
  display: none;
}

html[data-theme="dark"] .admin-logo-light {
  display: none;
}

html[data-theme="dark"] .admin-logo-dark {
  display: block;
}

.customer-page {
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 22px) 16px calc(env(safe-area-inset-bottom) + 30px);
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 8%, rgb(227 196 109 / 24%) 0 46px, transparent 47px),
    radial-gradient(circle at 90% 20%, rgb(3 199 90 / 10%) 0 42px, transparent 43px),
    linear-gradient(180deg, #fbfcfe 0%, var(--paper) 100%);
}

.customer-shell {
  width: min(100%, 460px);
  margin: 0 auto;
}

.customer-shell.is-loading .promo-band,
.customer-shell.is-loading .customer-links,
.customer-shell.is-loading .customer-footer {
  display: none;
}

.customer-header {
  padding: 0 2px 18px;
}

.brand-logo-lockup {
  display: flex;
  align-items: center;
  min-height: 68px;
}

.customer-logo {
  display: block;
  width: min(270px, 76vw);
  max-height: 72px;
  object-fit: contain;
  object-position: left center;
}

.customer-logo-dark {
  display: none;
}

html[data-theme="dark"] .customer-logo-light {
  display: none;
}

html[data-theme="dark"] .customer-logo-dark {
  display: block;
}

.promo-band {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 126px;
  padding: 18px;
  overflow: hidden;
  color: #ffffff;
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 92% 8%, rgb(227 196 109 / 28%) 0 34px, transparent 35px),
    linear-gradient(135deg, #17191e 0%, var(--coal) 100%);
  box-shadow: 0 18px 34px rgb(18 24 33 / 18%);
}

.promo-copy {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.promo-eyebrow {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 10px;
  color: #2a210a;
  border-radius: 999px;
  background: linear-gradient(135deg, #fff4c8, var(--gold));
  font-size: 12px;
  font-weight: 900;
}

.promo-band h2 {
  margin: 12px 0 6px;
  color: #ffffff;
  font-size: 25px;
  line-height: 1.15;
  letter-spacing: 0;
}

.promo-band p {
  margin: 0;
  color: rgb(255 255 255 / 72%);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.promo-visual {
  position: relative;
  display: grid;
  width: 118px;
  height: 102px;
  place-items: end;
}

.promo-visual img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 3px solid rgb(227 196 109 / 72%);
  border-radius: var(--radius);
  box-shadow: 0 12px 22px rgb(0 0 0 / 28%);
}

.promo-badge {
  position: relative;
  display: inline-grid;
  min-width: 58px;
  min-height: 30px;
  place-items: center;
  padding: 0 9px;
  color: #1d1808;
  border-radius: 999px;
  background: var(--gold);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.customer-links {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.customer-link {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 18px;
  gap: 13px;
  align-items: center;
  width: 100%;
  min-height: 76px;
  padding: 12px 14px;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 12px 26px rgb(28 35 48 / 8%);
  cursor: pointer;
}

.customer-link:active {
  transform: scale(0.987);
}

.customer-link.is-disabled {
  color: #5f6978;
  background: #f8fafc;
}

.link-icon {
  display: inline-grid;
  width: 50px;
  height: 50px;
  place-items: center;
  overflow: hidden;
  color: #1e1a0d;
  border-radius: var(--radius);
  background: var(--gold-soft);
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
}

.link-icon.has-image {
  padding: 0;
  border: 1px solid var(--line);
  background: #ffffff;
}

.link-icon.has-image img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: calc(var(--radius) - 1px);
  object-fit: cover;
}

.link-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.link-copy strong {
  overflow-wrap: anywhere;
  font-size: 17px;
  line-height: 1.22;
}

.link-copy small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.link-arrow {
  color: #a3adbc;
  font-size: 28px;
  line-height: 1;
}

.tone-gold .link-icon {
  background: linear-gradient(150deg, #fff2bd, var(--gold));
}

.tone-kakao .link-icon {
  background: var(--kakao);
}

.tone-naver .link-icon,
.tone-store .link-icon {
  color: #ffffff;
  background: var(--naver);
}

.tone-mall .link-icon {
  color: var(--gold);
  background: #1c2028;
}

.not-ready-message {
  min-height: 36px;
  margin: 14px 0 0;
  padding: 9px 12px;
  color: #6a4c0d;
  border: 1px solid rgb(227 196 109 / 44%);
  border-radius: var(--radius);
  background: #fff9e8;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.customer-footer {
  display: grid;
  gap: 4px;
  margin-top: 24px;
  padding-top: 16px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
}

.theme-toggle {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 20;
  display: inline-grid;
  min-width: 72px;
  height: 40px;
  place-items: center;
  padding: 0 14px;
  color: #1c1a12;
  border: 1px solid rgb(227 196 109 / 48%);
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgb(24 30 42 / 16%);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

html[data-theme="dark"] .customer-page {
  background:
    radial-gradient(circle at 12% 7%, rgb(227 196 109 / 16%) 0 48px, transparent 49px),
    radial-gradient(circle at 92% 18%, rgb(3 199 90 / 9%) 0 42px, transparent 43px),
    linear-gradient(180deg, #0b0e13 0%, var(--paper) 100%);
}

html[data-theme="dark"] .promo-band {
  min-height: 140px;
  padding: 20px;
  border-color: rgb(227 196 109 / 26%);
  background:
    linear-gradient(135deg, rgb(255 255 255 / 7%) 0%, transparent 34%),
    linear-gradient(145deg, #171b22 0%, #090b0f 100%);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 8%),
    0 18px 36px rgb(0 0 0 / 32%);
}

html[data-theme="dark"] .promo-band::before {
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 3px;
  content: "";
  background: linear-gradient(90deg, var(--gold) 0%, #fff2b8 34%, rgb(3 199 90 / 72%) 100%);
}

html[data-theme="dark"] .promo-band::after {
  position: absolute;
  top: 0;
  right: 0;
  width: 36%;
  height: 100%;
  content: "";
  background:
    linear-gradient(135deg, rgb(227 196 109 / 20%) 0%, transparent 44%),
    repeating-linear-gradient(135deg, transparent 0 10px, rgb(255 255 255 / 4%) 10px 11px);
  clip-path: polygon(30% 0, 100% 0, 100% 100%, 0% 100%);
  opacity: 0.86;
}

html[data-theme="dark"] .promo-eyebrow {
  min-height: 28px;
  padding: 0 12px;
  color: #201704;
  background: linear-gradient(135deg, #fff2b8 0%, var(--gold) 100%);
  box-shadow: 0 8px 18px rgb(227 196 109 / 18%);
}

html[data-theme="dark"] .promo-band h2 {
  max-width: 310px;
  margin-top: 14px;
  color: #ffffff;
  font-size: 26px;
  line-height: 1.12;
  text-shadow: 0 2px 16px rgb(0 0 0 / 36%);
}

html[data-theme="dark"] .promo-band p {
  max-width: 310px;
  color: #d9e2ef;
  font-size: 13px;
  line-height: 1.5;
}

html[data-theme="dark"] .customer-link {
  color: var(--ink);
  border-color: var(--line);
  background: var(--panel);
  box-shadow: 0 12px 26px rgb(0 0 0 / 22%);
}

html[data-theme="dark"] .customer-link.is-disabled {
  color: #aeb8c7;
  background: #141820;
}

html[data-theme="dark"] .link-copy small,
html[data-theme="dark"] .customer-footer {
  color: var(--muted);
}

html[data-theme="dark"] .customer-footer {
  border-top-color: var(--line);
}

html[data-theme="dark"] .not-ready-message {
  color: #f4da8a;
  border-color: rgb(227 196 109 / 28%);
  background: #211b0c;
}

html[data-theme="dark"] .theme-toggle {
  color: #f7f1e5;
  border-color: rgb(227 196 109 / 46%);
  background: #1a1f27;
  box-shadow: 0 12px 28px rgb(0 0 0 / 34%);
}

.admin-page {
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 100% 0%, rgb(227 196 109 / 12%) 0 180px, transparent 181px),
    var(--paper);
}

.login-screen {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 20px;
}

.login-panel,
.settings-panel,
.stats-panel,
.preview-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 16px 32px rgb(31 41 55 / 8%);
}

.login-panel {
  display: grid;
  width: min(100%, 380px);
  gap: 16px;
  justify-items: start;
  padding: 28px;
}

.login-panel .brand-mark {
  width: 60px;
  height: 68px;
}

.login-panel h1,
.admin-topbar h1,
.form-section h2 {
  margin: 0;
  letter-spacing: 0;
}

.login-panel h1 {
  max-width: 300px;
  font-size: 24px;
  line-height: 1.22;
}

label {
  display: grid;
  gap: 7px;
  color: #485468;
  font-size: 13px;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid #ccd5e3;
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  outline: 0;
}

input {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 92px;
  padding: 12px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--gold-deep);
  box-shadow: 0 0 0 3px rgb(227 196 109 / 24%);
}

.primary-button,
.secondary-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}

.primary-button {
  color: #19160b;
  background: linear-gradient(135deg, #f7dc86, var(--gold));
}

.secondary-button {
  color: var(--ink);
  border-color: var(--line);
  background: #ffffff;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.form-message[data-tone="error"] {
  color: var(--danger);
}

.form-message[data-tone="success"] {
  color: var(--success);
}

.admin-shell {
  width: min(100% - 32px, 1440px);
  margin: 0 auto;
  padding: 20px 0 32px;
}

.admin-topbar {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 20px;
}

.admin-title-block {
  display: flex;
  gap: 18px;
  align-items: center;
  min-width: 0;
}

.admin-title-block .admin-logo {
  width: min(260px, 24vw);
  max-height: 58px;
}

.admin-topbar h1 {
  overflow-wrap: anywhere;
  font-size: 24px;
  line-height: 1.18;
}

.admin-topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.admin-theme-toggle {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  display: inline-grid;
  min-width: 74px;
  height: 40px;
  place-items: center;
  padding: 0 14px;
  color: #1c1a12;
  border: 1px solid rgb(227 196 109 / 48%);
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgb(24 30 42 / 16%);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.admin-grid {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.stats-panel,
.preview-panel,
.settings-panel {
  padding: 16px;
}

.stat-card {
  display: grid;
  gap: 5px;
  padding: 14px;
  border: 1px solid #eef2f7;
  border-radius: var(--radius);
  background: #fafbfd;
}

.stat-card + .stat-card,
.stats-list {
  margin-top: 10px;
}

.stat-card span,
.stats-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stat-card strong {
  font-size: 30px;
  line-height: 1;
}

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

.stats-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.stats-row strong {
  font-size: 16px;
}

.settings-panel {
  display: grid;
  gap: 18px;
}

.form-section {
  display: grid;
  gap: 14px;
}

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

.form-section h2 {
  font-size: 18px;
}

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

.link-editor {
  display: grid;
  gap: 12px;
}

.link-row {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: var(--radius);
  background: #ffffff;
}

.link-row.tone-gold {
  border-left-color: var(--gold);
}

.link-row.tone-kakao {
  border-left-color: var(--kakao);
}

.link-row.tone-naver,
.link-row.tone-store {
  border-left-color: var(--naver);
}

.link-row.tone-mall {
  border-left-color: var(--coal);
}

.link-row-head {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.link-row-head .link-icon {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
}

.link-row-head strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.link-order-actions {
  display: flex;
  gap: 4px;
}

.icon-button {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  padding: 0;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

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

.icon-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 10px;
  align-items: end;
  padding: 12px;
  border: 1px dashed #cfd7e4;
  border-radius: var(--radius);
  background: #fafbfd;
}

.icon-tools small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.file-field input {
  padding: 9px 10px;
  height: auto;
  background: #ffffff;
}

.color-field input[type="color"] {
  height: 42px;
  padding: 4px;
  cursor: pointer;
}

.color-field input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-field input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: calc(var(--radius) - 3px);
}

.compact-button {
  min-height: 42px;
}

.switch {
  position: relative;
  display: inline-block;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.switch span {
  display: block;
  width: 46px;
  height: 26px;
  padding: 3px;
  border-radius: 999px;
  background: #c9d2df;
  cursor: pointer;
  transition: background 0.15s ease;
}

.switch span::before {
  display: block;
  width: 20px;
  height: 20px;
  content: "";
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 5px rgb(20 28 40 / 22%);
  transition: transform 0.15s ease;
}

.switch input:checked + span {
  background: var(--naver);
}

.switch input:checked + span::before {
  transform: translateX(20px);
}

.phone-frame {
  width: 100%;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border: 10px solid #181b22;
  border-radius: 24px;
  background: #181b22;
}

.phone-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

html[data-theme="dark"] .admin-page {
  background:
    radial-gradient(circle at 100% 0%, rgb(227 196 109 / 10%) 0 180px, transparent 181px),
    linear-gradient(180deg, #0b0e13 0%, #101319 100%);
}

html[data-theme="dark"] .login-panel,
html[data-theme="dark"] .settings-panel,
html[data-theme="dark"] .stats-panel,
html[data-theme="dark"] .preview-panel {
  border-color: #303947;
  background: #171b22;
  box-shadow: 0 20px 42px rgb(0 0 0 / 30%);
}

html[data-theme="dark"] .admin-topbar p,
html[data-theme="dark"] .form-message,
html[data-theme="dark"] .stat-card span,
html[data-theme="dark"] .stats-row span,
html[data-theme="dark"] label,
html[data-theme="dark"] .icon-tools small {
  color: #b7c0ce;
}

html[data-theme="dark"] input,
html[data-theme="dark"] textarea {
  color: #f7f1e5;
  border-color: #384455;
  background: #10141b;
}

html[data-theme="dark"] input:focus,
html[data-theme="dark"] textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgb(227 196 109 / 18%);
}

html[data-theme="dark"] .secondary-button,
html[data-theme="dark"] .icon-button {
  color: #f7f1e5;
  border-color: #384455;
  background: #171d26;
}

html[data-theme="dark"] .secondary-button:hover,
html[data-theme="dark"] .icon-button:hover:not(:disabled) {
  border-color: rgb(227 196 109 / 42%);
}

html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .icon-tools {
  border-color: #2c3644;
  background: #121720;
}

html[data-theme="dark"] .stats-row {
  border-bottom-color: #303947;
}

html[data-theme="dark"] .link-row {
  border-color: #303947;
  background: #151a22;
}

html[data-theme="dark"] .link-row-head .link-icon,
html[data-theme="dark"] .link-icon.has-image {
  border-color: #303947;
}

html[data-theme="dark"] .file-field input {
  background: #10141b;
}

html[data-theme="dark"] .switch span {
  background: #3a4555;
}

html[data-theme="dark"] .switch input:checked + span {
  background: var(--naver);
}

html[data-theme="dark"] .admin-theme-toggle {
  color: #f7f1e5;
  border-color: rgb(227 196 109 / 46%);
  background: #1a1f27;
  box-shadow: 0 12px 28px rgb(0 0 0 / 34%);
}

@media (max-width: 1160px) {
  .admin-grid {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .preview-panel {
    grid-column: 1 / -1;
  }

  .phone-frame {
    max-width: 360px;
    margin: 0 auto;
  }
}

@media (max-width: 780px) {
  .admin-shell {
    width: min(100% - 20px, 720px);
  }

  .admin-topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-title-block {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-title-block .admin-logo {
    width: min(300px, 78vw);
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .admin-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .customer-page {
    padding-right: 12px;
    padding-left: 12px;
  }

  .customer-logo {
    width: min(250px, 74vw);
    max-height: 68px;
  }

  .promo-band {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .promo-band h2 {
    font-size: 23px;
  }

  .customer-link {
    grid-template-columns: 48px minmax(0, 1fr) 16px;
    padding: 11px;
  }

  .link-icon {
    width: 46px;
    height: 46px;
  }

  .icon-tools {
    grid-template-columns: 1fr;
  }

}
