:root {
  color-scheme: light;
  --ink: #183329;
  --muted: #6f7f78;
  --paper: #f5f3ed;
  --card: #fffef9;
  --green: #176b4d;
  --green-dark: #0f5139;
  --green-soft: #dfece5;
  --line: #dedfd7;
  --red: #a64232;
  --shadow: 0 16px 40px rgba(21, 52, 40, 0.11);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13px;
}

html[data-font-size="medium"] { font-size: 14px; }
html[data-font-size="large"] { font-size: 16px; }

* { box-sizing: border-box; }
html { background: var(--paper); overscroll-behavior-y: none; }
body { margin: 0; color: var(--ink); background: var(--paper); overscroll-behavior-y: none; font-size: 1rem; }
button { font: inherit; }
input, textarea, select { font-family: inherit; font-size: max(16px, 1.08rem); }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-shell { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 80% 15%, #d9eade 0, transparent 32%), var(--paper); }
.login-card { width: min(100%, 420px); padding: 38px 30px; border-radius: 28px; background: var(--card); box-shadow: var(--shadow); }
.brand-mark { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 18px; color: #fff; background: var(--green); font-size: 24px; font-weight: 800; }
.eyebrow { margin: 18px 0 5px; color: var(--green); font-size: 11px; letter-spacing: 0.18em; font-weight: 800; }
h1, h2, h3, p { margin-top: 0; }
.login-card h1 { margin-bottom: 8px; font-size: 1.78rem; letter-spacing: -0.04em; }
.login-copy { color: var(--muted); line-height: 1.7; }
.stack-form { display: grid; gap: 16px; margin-top: 28px; }

label { display: grid; gap: 8px; }
label > span { font-size: 1rem; font-weight: 650; }
label b { color: var(--red); }
input, textarea, select { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 13px; padding: 12px 14px; color: var(--ink); background: #fff; outline: none; transition: border-color .2s, box-shadow .2s; }
textarea { resize: vertical; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 107, 77, .12); }

.primary-button, .ghost-button, .load-more { min-height: 50px; border: 0; border-radius: 14px; padding: 0 20px; font-weight: 750; }
.primary-button { color: #fff; background: var(--green); box-shadow: 0 10px 20px rgba(23, 107, 77, .18); }
.primary-button:disabled { opacity: .6; cursor: wait; }
.ghost-button { color: var(--green); background: var(--green-soft); }
.ghost-button.compact { min-height: 38px; padding: 0 14px; }
.text-button { border: 0; padding: 8px; color: var(--green); background: transparent; font-weight: 750; }

.app-shell { width: min(100%, 900px); min-height: 100dvh; margin: auto; padding: max(18px, env(safe-area-inset-top)) 22px max(150px, calc(120px + env(safe-area-inset-bottom))); }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar .eyebrow { margin-top: 0; }
.topbar h1 { margin: 0; font-size: 1.72rem; letter-spacing: -.04em; }
.toolbar { display: grid; gap: 13px; }
.search-box { position: relative; display: block; }
.search-box input { height: 54px; padding-left: 48px; border: 0; background: var(--card); box-shadow: 0 6px 18px rgba(22, 46, 37, .06); }
.search-icon { position: absolute; left: 17px; top: 11px; z-index: 1; color: var(--green); font-size: 26px; font-weight: 400; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; padding: 5px; border-radius: 14px; background: #e8e8e1; }
.segmented button { min-height: 40px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; font-weight: 700; }
.segmented button.active { color: var(--green-dark); background: var(--card); box-shadow: 0 3px 10px rgba(29, 57, 46, .08); }
.summary-row { display: flex; align-items: center; justify-content: space-between; margin: 22px 2px 10px; }
.summary-row p { margin: 0; color: var(--muted); font-size: 1rem; }
.summary-row strong { color: var(--ink); font-size: 1.28rem; }

.campaign-list { display: grid; gap: 12px; }
.campaign-card { overflow: hidden; border: 1px solid rgba(38, 72, 58, .08); border-radius: 18px; background: var(--card); box-shadow: 0 8px 22px rgba(22, 46, 37, .05); }
.card-button { width: 100%; border: 0; padding: 15px; text-align: left; color: inherit; background: transparent; }
.campaign-card-top, .campaign-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.status-pill { padding: 5px 9px; border-radius: 99px; color: var(--green-dark); background: var(--green-soft); font-size: 11px; font-weight: 800; }
.status-pill.expired { color: #7a645f; background: #eee6e3; }
.campaign-id { color: #9aa59f; font-size: 12px; }
.campaign-title { margin: 11px 0 5px; font-size: 1.14rem; line-height: 1.45; }
.campaign-bank { margin-bottom: 14px; color: var(--green); font-size: .94rem; font-weight: 700; }
.campaign-meta { padding-top: 13px; border-top: 1px solid #ebebe5; color: var(--muted); font-size: 12px; }
.load-more { display: block; width: 100%; margin-top: 14px; color: var(--green); background: var(--green-soft); }
.empty-state { padding: 70px 20px; text-align: center; color: var(--ink); }
.empty-state div { font-size: 19px; font-weight: 750; }
.empty-state p { margin: 8px 0; color: var(--muted); }
.floating-button { position: fixed; right: max(22px, calc((100vw - 900px) / 2 + 22px)); bottom: max(30px, calc(20px + env(safe-area-inset-bottom))); min-height: 54px; border: 0; border-radius: 17px; padding: 0 19px; color: #fff; background: var(--green); box-shadow: 0 14px 30px rgba(17, 79, 56, .3); font-size: 14px; font-weight: 800; }
.floating-button span { font-size: 20px; }

.editor { position: fixed; inset: 0; z-index: 20; }
.editor-backdrop { position: absolute; inset: 0; background: rgba(11, 29, 22, .46); backdrop-filter: blur(4px); }
.editor-panel { position: absolute; inset: 0 0 0 auto; width: min(100%, 720px); height: 100dvh; overflow-y: auto; overscroll-behavior-y: contain; scroll-behavior: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y pinch-zoom; background: var(--paper); box-shadow: var(--shadow); }
.editor-header { position: sticky; top: 0; z-index: 3; display: grid; grid-template-columns: 78px 1fr 54px; align-items: center; gap: 8px; min-height: 68px; padding: max(10px, env(safe-area-inset-top)) 16px 10px; border-bottom: 1px solid var(--line); background: rgba(245, 243, 237, .97); backdrop-filter: blur(14px); }
.editor-header .eyebrow { margin: 0 0 2px; }
.editor-header h2 { margin: 0; font-size: 1.28rem; }
.draft-status { margin: 3px 0 0; color: var(--muted); font-size: 11px; line-height: 1.25; }
.draft-status.saved { color: var(--green); }
.icon-button { width: 48px; height: 48px; border: 0; border-radius: 14px; color: var(--green); background: var(--green-soft); font-size: 20px; }
.back-button { display: inline-flex; width: 76px; flex-wrap: nowrap; align-items: center; justify-content: center; gap: 5px; padding: 0 8px; white-space: nowrap; }
.back-button b { flex: none; font-size: 1rem; white-space: nowrap; }
.editor-header .text-button { min-width: 54px; min-height: 48px; padding: 8px 6px; }
.campaign-form { display: grid; gap: 13px; padding: 16px 18px max(150px, calc(120px + env(safe-area-inset-bottom))); }
.form-section { display: grid; gap: 14px; margin: 0; border: 0; border-radius: 18px; padding: 16px; background: var(--card); box-shadow: 0 7px 20px rgba(22, 46, 37, .04); }
.section-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 2px; }
.section-heading > span, .advanced-section summary > span { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 36px; border-radius: 12px; color: var(--green); background: var(--green-soft); font-size: 12px; font-weight: 850; }
.section-heading h3 { margin: 0 0 3px; font-size: 1.08rem; }
.section-heading p { margin: 0; color: var(--muted); font-size: .86rem; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.switch-row { position: relative; grid-template-columns: 1fr 48px; align-items: center; cursor: pointer; }
.switch-row span { display: grid; gap: 3px; }
.switch-row small { color: var(--muted); font-weight: 400; }
.switch-row input { position: absolute; opacity: 0; }
.switch-row i { position: relative; width: 46px; height: 28px; border-radius: 99px; background: #c9cec9; transition: background .2s; }
.switch-row i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.2); transition: transform .2s; }
.switch-row input:checked + i { background: var(--green); }
.switch-row input:checked + i::after { transform: translateX(18px); }
.advanced-section { padding: 0; }
.advanced-section summary { display: flex; align-items: center; gap: 12px; padding: 16px; list-style: none; cursor: pointer; }
.advanced-section summary::-webkit-details-marker { display: none; }
.advanced-section summary strong { flex: 1; }
.advanced-section summary em { color: var(--muted); font-size: 12px; font-style: normal; }
.details-content { display: grid; gap: 15px; padding: 0 18px 18px; }
.editor-actions { display: grid; gap: 9px; margin-top: 4px; }
.editor-actions .primary-button { min-height: 58px; }
.danger-text-button { min-height: 46px; border: 0; color: var(--red); background: transparent; font-weight: 700; }

.font-size-button { min-height: 38px; border: 1px solid rgba(23, 107, 77, .15); border-radius: 12px; padding: 0 11px; color: var(--green-dark); background: var(--card); font-size: 12px; font-weight: 800; }

.toast { position: fixed; z-index: 50; left: 50%; top: calc(18px + env(safe-area-inset-top)); width: max-content; max-width: calc(100% - 32px); transform: translate(-50%, -16px); border-radius: 12px; padding: 11px 16px; color: #fff; background: var(--ink); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .25s; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: var(--red); }
.skeleton { height: 155px; border-radius: 18px; background: linear-gradient(100deg, #e8e8e1 20%, #f5f4ef 40%, #e8e8e1 60%); background-size: 200% 100%; animation: shine 1.2s infinite; }
@keyframes shine { to { background-position-x: -200%; } }

@media (min-width: 700px) {
  .toolbar { grid-template-columns: 1fr 320px; }
  .campaign-list { grid-template-columns: 1fr 1fr; }
  .campaign-form { padding: 24px 30px 40px; }
}

@media (max-width: 460px) {
  .two-columns { grid-template-columns: 1fr; }
  .app-shell { padding-inline: 20px; }
  .form-section { padding: 15px; }
  .campaign-form { padding-inline: 16px; }
  .editor-header h2 { font-size: 1.28rem; }
  .draft-status { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
