:root {
  --ink: #15211b;
  --muted: #69766f;
  --paper: #f4f4ee;
  --card: #fffefa;
  --line: #dde1d8;
  --green: #143f32;
  --green-2: #1e5a47;
  --mint: #cde9d7;
  --lime: #d9f36a;
  --red: #b44040;
  --shadow: 0 18px 50px rgba(24, 45, 35, .08);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 10px; color: var(--green-2); font: 700 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .15em; }
.label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; min-height: 72px; padding: 0 max(24px, calc((100vw - 1240px)/2)); background: rgba(244,244,238,.9); border-bottom: 1px solid rgba(20,63,50,.09); backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong, .brand span { display: block; }
.brand > div span { margin-top: 2px; color: var(--muted); font-size: 11px; letter-spacing: .06em; }
.brand-mark { display: grid; place-items: center; width: 58px; height: 58px; color: var(--lime); background: var(--green); border-radius: 18px 6px 18px 6px; font: 800 19px/1 ui-monospace, monospace; box-shadow: 0 10px 24px rgba(20,63,50,.18); }
.brand-mark.small { width: 39px; height: 39px; border-radius: 12px 4px 12px 4px; font-size: 14px; box-shadow: none; }
.top-actions, .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

.shell { width: min(1240px, calc(100% - 48px)); margin: 0 auto 80px; }
.hero-grid { display: grid; grid-template-columns: 1.5fr .8fr; gap: 22px; padding: 64px 0 36px; }
.hero-copy h1 { margin: 0; font: 500 clamp(38px, 5vw, 68px)/1.02 Georgia, "Noto Serif SC", serif; letter-spacing: -.045em; }
.hero-copy h1 span { color: var(--green-2); font-style: italic; }
.hero-copy > p:last-child { max-width: 670px; margin: 22px 0 0; color: var(--muted); line-height: 1.8; }
.status-card { align-self: end; display: flex; align-items: center; gap: 18px; min-height: 136px; padding: 26px; background: var(--green); color: white; border-radius: 28px 8px 28px 8px; box-shadow: 0 20px 45px rgba(20,63,50,.2); }
.status-card .muted, .status-card .label { color: #a9c4b8; }
.status-card strong { display: block; margin-bottom: 6px; font-size: 20px; }
.status-orbit { display: grid; place-items: center; flex: 0 0 auto; width: 60px; height: 60px; border: 1px solid rgba(217,243,106,.35); border-radius: 50%; }
.status-orbit span { width: 16px; height: 16px; background: #d8a759; border: 4px solid rgba(255,255,255,.18); border-radius: 50%; box-shadow: 0 0 0 8px rgba(216,167,89,.1); }
.status-orbit span.online { background: var(--lime); box-shadow: 0 0 0 8px rgba(217,243,106,.11); }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; overflow: hidden; margin-bottom: 40px; border: 1px solid var(--line); border-radius: 18px; background: var(--line); }
.metrics article { padding: 24px; background: var(--card); }
.metrics span { display: block; margin-bottom: 10px; color: var(--muted); font-size: 12px; }
.metrics strong { font: 500 31px/1 Georgia, serif; }

.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 5px; background: #e9ebe3; border-radius: 14px; }
.tab { flex: 1 0 auto; padding: 12px 18px; color: var(--muted); background: transparent; border: 0; border-radius: 10px; }
.tab.active { color: var(--ink); background: var(--card); box-shadow: 0 3px 12px rgba(21,33,27,.06); font-weight: 700; }
.tab-panel { display: none; margin-top: 18px; padding: 32px; background: var(--card); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.tab-panel.active { display: block; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.section-head h2 { margin: 0 0 6px; font: 500 30px/1.2 Georgia, "Noto Serif SC", serif; }
.section-head p { margin-top: 4px; margin-bottom: 0; }

.button { min-height: 40px; padding: 0 16px; color: var(--ink); background: transparent; border: 1px solid var(--line); border-radius: 10px; font-weight: 700; transition: transform .15s, background .15s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button.primary { color: white; background: var(--green); border-color: var(--green); }
.button.primary:hover { background: var(--green-2); }
.button.secondary { background: #eef0e9; }
.button.danger-solid { color: white; background: var(--red); border-color: var(--red); }
.button.danger-solid:hover { background: #8d322d; }
.button.ghost { border-color: transparent; }
.button.small { min-height: 34px; padding: 0 13px; font-size: 12px; }
.button.wide { width: 100%; }
.button:disabled, .icon-button:disabled { cursor: default; opacity: .35; }
.danger-text { color: var(--red) !important; }
.icon-button { width: 34px; height: 34px; padding: 0; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 9px; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 8px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill::before { width: 7px; height: 7px; border-radius: 50%; background: currentColor; content: ""; }
.pill.neutral { color: var(--muted); background: #e5e8e0; }
.pill.success { color: #245e49; background: #dcecdf; }
.pill.warning { color: #8b6328; background: #f4ead7; }

.queue-list { display: grid; gap: 10px; }
.queue-item { display: grid; grid-template-columns: 24px 46px minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 92px; padding: 15px; background: #fafaf6; border: 1px solid var(--line); border-radius: 14px; transition: opacity .15s, transform .15s; }
.queue-item.dragging { opacity: .55; transform: scale(.99); }
.drag-handle { color: #9ba49e; cursor: grab; font-size: 22px; }
.queue-index { color: var(--green-2); font: 700 14px ui-monospace, monospace; }
.queue-content { min-width: 0; }
.queue-content p { overflow: hidden; margin: 8px 0 0; text-overflow: ellipsis; white-space: nowrap; }
.queue-meta { display: flex; flex-wrap: wrap; gap: 7px; }
.queue-meta span { padding: 3px 7px; color: var(--muted); background: #ecefe7; border-radius: 6px; font-size: 11px; }
.queue-actions { display: flex; align-items: center; gap: 6px; }
.error-line { display: block; overflow: hidden; margin-top: 7px; color: var(--red); text-overflow: ellipsis; white-space: nowrap; }
.empty-state { padding: 70px 20px; text-align: center; }
.empty-state > span { color: var(--green-2); font-size: 54px; }
.empty-state h3 { margin: 12px 0 8px; font-family: Georgia, serif; font-size: 23px; }
.empty-state p, .empty-inline { color: var(--muted); }

.channel-live-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: -10px 0 18px; padding: 12px 14px; background: #f0f3eb; border-radius: 11px; }
.channel-live-bar > div { text-align: right; }
.channel-live-bar > div strong, .channel-live-bar > div span { display: block; }
.channel-live-bar > div span { margin-top: 4px; font-size: 12px; }
.channel-scope { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.channel-scope select { min-width: 170px; }
.channel-post-list { display: grid; gap: 12px; }
.channel-post-card { display: grid; grid-template-columns: 190px minmax(0, 1fr); overflow: hidden; min-height: 170px; background: #fafaf6; border: 1px solid var(--line); border-radius: 15px; }
.channel-post-media { display: grid; place-items: center; min-height: 170px; color: var(--muted); background: #e9eee8; }
.channel-post-media img { width: 100%; height: 100%; max-height: 250px; object-fit: cover; }
.channel-post-media .media-placeholder { padding: 20px; text-align: center; font-weight: 700; }
.channel-post-media.gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; padding: 2px; }
.media-tile { position: relative; display: grid; place-items: center; overflow: hidden; min-height: 82px; background: #dde5df; }
.media-tile img { position: absolute; inset: 0; max-height: none; }
.media-kind { position: absolute; right: 5px; bottom: 5px; z-index: 1; padding: 3px 6px; color: white; background: rgba(21,33,27,.72); border-radius: 5px; font-size: 10px; font-weight: 800; }
.media-more { color: var(--green-2); font-weight: 800; }
.channel-post-body { display: flex; flex-direction: column; gap: 11px; min-width: 0; padding: 17px; }
.channel-post-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.channel-post-meta span { padding: 4px 7px; color: var(--muted); background: #ecefe7; border-radius: 6px; font-size: 11px; }
.channel-post-meta .managed { color: #245e49; background: #dcecdf; font-weight: 800; }
.channel-post-text { display: -webkit-box; overflow: hidden; margin: 0; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 5; }
.channel-post-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: auto; }
.channel-post-stats { display: flex; gap: 12px; color: var(--muted); font-size: 12px; }
.channel-post-link { color: var(--green-2); font-size: 12px; font-weight: 800; text-decoration: none; }
.channel-post-link:hover { text-decoration: underline; }

.inline-form { display: flex; gap: 10px; margin-bottom: 22px; }
input, select, textarea { width: 100%; min-height: 44px; padding: 0 13px; color: var(--ink); background: white; border: 1px solid #cfd5cb; border-radius: 10px; outline: none; }
textarea { min-height: 118px; padding: 11px 13px; line-height: 1.55; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(30,90,71,.1); }
.inline-form input { max-width: 520px; }
.bulk-form { display: grid; grid-template-columns: minmax(0, 620px) auto; align-items: end; gap: 10px; margin-bottom: 12px; }
.bulk-form label { display: grid; gap: 7px; }
.bulk-form label > span { color: var(--muted); font-size: 12px; }
.bulk-import-result { max-width: 780px; margin: 0 0 22px; padding: 14px; background: #f7f8f2; border: 1px solid var(--line); border-radius: 12px; }
.bulk-import-summary { display: block; margin-bottom: 10px; }
.bulk-import-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; margin-bottom: 12px; }
.bulk-import-kpis span { padding: 9px; background: white; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-size: 11px; text-align: center; }
.bulk-import-kpis strong { display: block; margin-bottom: 2px; color: var(--ink); font-size: 18px; }
.bulk-import-actions { display: flex; gap: 8px; margin: 10px 0; }
.bulk-import-list { display: grid; gap: 6px; max-height: 260px; overflow: auto; }
.bulk-import-item { display: grid; grid-template-columns: 58px minmax(100px, .7fr) 1fr; gap: 8px; align-items: baseline; font-size: 12px; }
.bulk-import-item span { overflow-wrap: anywhere; }
.bulk-import-item .status { font-weight: 800; }
.bulk-import-item.added .status { color: var(--green-2); }
.bulk-import-item.duplicate .status { color: #8b6328; }
.bulk-import-item.failed .status { color: var(--red); }
.bulk-import-item .detail { color: var(--muted); }
.allowlist-toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) 130px auto; align-items: end; gap: 10px; margin: 22px 0 10px; padding: 12px; background: #f7f8f2; border: 1px solid var(--line); border-radius: 12px; }
.allowlist-toolbar label { display: grid; gap: 5px; }
.allowlist-toolbar label > span { color: var(--muted); font-size: 11px; }
.allowlist-toolbar strong { align-self: center; color: var(--green-2); font-size: 13px; text-align: right; }
.pagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 5px; min-height: 48px; padding: 7px 0; }
.pagination:empty { display: none; }
.pagination .button { min-height: 34px; padding: 0 10px; font-size: 12px; }
.pagination .button.current { color: white; background: var(--green); border-color: var(--green); }
.pagination-info { margin: 0 5px; color: var(--muted); font-size: 12px; }
.pagination-jump { display: flex; align-items: center; gap: 5px; margin-left: 6px; }
.pagination-jump input { width: 58px; min-height: 34px; padding: 0 7px; text-align: center; }
.sender-list { display: grid; gap: 10px; }
.subsection-title { margin: 32px 0 14px; padding-top: 28px; border-top: 1px solid var(--line); font: 500 21px Georgia, "Noto Serif SC", serif; }
.sender-row { display: grid; grid-template-columns: 46px 1fr auto; align-items: center; gap: 13px; padding: 14px; background: #fafaf6; border: 1px solid var(--line); border-radius: 13px; }
.sender-row .avatar { display: grid; place-items: center; width: 42px; height: 42px; color: var(--lime); background: var(--green); border-radius: 50%; font-weight: 800; }
.sender-row strong, .sender-row span { display: block; }
.sender-row span { margin-top: 4px; color: var(--muted); font-size: 12px; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: grid; gap: 7px; }
.field > span { font-size: 13px; font-weight: 700; }
.field small, .switch-row small { display: block; color: var(--muted); font-size: 11px; font-weight: 400; }
.full { grid-column: 1 / -1; }
.switch-row { display: flex; align-items: center; justify-content: space-between; min-height: 70px; padding: 15px; background: #f7f8f2; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-row i { position: relative; flex: 0 0 auto; width: 42px; height: 24px; margin-left: 15px; background: #bdc5bd; border-radius: 20px; transition: background .2s; }
.switch-row i::after { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: white; border-radius: 50%; box-shadow: 0 2px 5px rgba(0,0,0,.15); content: ""; transition: transform .2s; }
.switch-row input:checked + i { background: var(--green-2); }
.switch-row input:checked + i::after { transform: translateX(18px); }
.form-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; padding-top: 20px; border-top: 1px solid var(--line); }

.account-layout { display: grid; grid-template-columns: 1fr 340px; gap: 20px; }
.account-card, .qr-card { padding: 28px; background: #f7f8f2; border: 1px solid var(--line); border-radius: 18px; }
.account-card h3 { margin: 8px 0; font: 500 26px Georgia, serif; }
.account-card .actions { margin-top: 22px; }
.qr-card { text-align: center; }
.qr-card img { width: 210px; max-width: 100%; padding: 8px; background: white; border-radius: 12px; }
.qr-card strong { display: block; margin-top: 12px; }
.qr-card .stack { margin-top: 18px; text-align: left; }
.notice { margin-top: 20px; padding: 18px 20px; background: #eef3dc; border-left: 4px solid #9eb43d; border-radius: 4px 12px 12px 4px; }
.notice strong { display: block; margin-bottom: 4px; }
.notice p { margin: 0; color: #536043; line-height: 1.65; }

.cleanup-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(340px, .9fr); gap: 18px; }
.cleanup-card { padding: 24px; background: #fafaf6; border: 1px solid var(--line); border-radius: 16px; }
.cleanup-card h3 { margin: 0 0 8px; font: 500 21px Georgia, "Noto Serif SC", serif; }
.cleanup-card > .muted { margin: 0 0 20px; line-height: 1.65; }
.cleanup-preview { display: grid; gap: 16px; margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.cleanup-target { display: flex; align-items: center; gap: 12px; }
.cleanup-target > span { flex: 0 0 auto; padding: 7px 10px; color: #245e49; background: #dcecdf; border-radius: 8px; font-size: 12px; font-weight: 800; }
.cleanup-target strong, .cleanup-target small { display: block; }
.cleanup-target small { margin-top: 4px; color: var(--muted); }
.cleanup-preview dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.cleanup-preview dl > div { padding: 12px; background: white; border: 1px solid var(--line); border-radius: 10px; }
.cleanup-preview dt { color: var(--muted); font-size: 11px; }
.cleanup-preview dd { margin: 5px 0 0; font-weight: 800; }
.permission-ok { color: var(--green-2); }
.danger-panel { padding: 15px; color: #71322d; background: #f8e4e1; border-left: 4px solid var(--red); border-radius: 4px 11px 11px 4px; }
.danger-panel p { margin: 5px 0 0; line-height: 1.6; }
.cleanup-preview code { padding: 3px 6px; color: #71322d; background: #f8e4e1; border-radius: 5px; user-select: all; }
.cleanup-progress-card { align-self: start; }
.progress-track { overflow: hidden; height: 12px; margin: 24px 0 18px; background: #e3e7df; border-radius: 999px; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--green-2); border-radius: inherit; transition: width .3s ease; }
.cleanup-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.cleanup-stats div { padding: 11px 7px; background: white; border: 1px solid var(--line); border-radius: 9px; text-align: center; }
.cleanup-stats strong, .cleanup-stats span { display: block; }
.cleanup-stats strong { font: 500 22px Georgia, serif; }
.cleanup-stats span { margin-top: 4px; color: var(--muted); font-size: 10px; }
.cleanup-detail { min-height: 48px; margin: 18px 0; color: var(--muted); line-height: 1.6; overflow-wrap: anywhere; }
.cleanup-notice { background: #f4ece2; border-left-color: #b57b45; }
.cleanup-notice p { color: #6a5643; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; max-width: min(420px, calc(100vw - 48px)); padding: 14px 18px; color: white; background: var(--green); border-radius: 12px; box-shadow: 0 14px 34px rgba(0,0,0,.2); opacity: 0; pointer-events: none; transform: translateY(12px); transition: .2s; }
.toast.show { opacity: 1; transform: none; }
.toast.danger { background: var(--red); }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 20%, #e0ead8 0, transparent 33%), radial-gradient(circle at 85% 85%, #dce7d4 0, transparent 30%), var(--paper); }
.login-card { width: min(430px, 100%); padding: 42px; background: rgba(255,254,250,.94); border: 1px solid var(--line); border-radius: 28px 8px 28px 8px; box-shadow: var(--shadow); }
.login-card h1 { margin: 18px 0 8px; font: 500 38px Georgia, "Noto Serif SC", serif; }
.login-card > .muted { margin-bottom: 28px; }
.stack { display: grid; gap: 10px; }
.stack label { font-size: 13px; font-weight: 700; }
.form-error { min-height: 20px; margin: 0; color: var(--red); font-size: 13px; }
.login-note { margin: 24px 0 0; color: var(--muted); font-size: 11px; text-align: center; }

@media (max-width: 850px) {
  .shell { width: min(100% - 28px, 1240px); }
  .topbar { padding: 0 14px; }
  .top-actions .pill { display: none; }
  .hero-grid, .account-layout, .cleanup-grid { grid-template-columns: 1fr; }
  .hero-grid { padding-top: 38px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .section-head { align-items: start; flex-direction: column; }
  .settings-grid { grid-template-columns: 1fr; }
  .full { grid-column: auto; }
  .queue-item { grid-template-columns: 20px 36px 1fr; }
  .queue-actions { grid-column: 3; justify-content: flex-end; }
  .channel-post-card { grid-template-columns: 150px minmax(0, 1fr); }
}

@media (max-width: 520px) {
  .brand > div, #refresh-button { display: none; }
  .hero-copy h1 { font-size: 40px; }
  .metrics article { padding: 18px; }
  .metrics strong { font-size: 25px; }
  .tab-panel { padding: 20px 16px; border-radius: 17px; }
  .tabs { margin-inline: -2px; }
  .inline-form, .form-footer { align-items: stretch; flex-direction: column; }
  .bulk-form { grid-template-columns: 1fr; }
  .bulk-import-kpis { grid-template-columns: 1fr 1fr; }
  .cleanup-stats { grid-template-columns: 1fr 1fr; }
  .allowlist-toolbar { grid-template-columns: 1fr; }
  .allowlist-toolbar strong { text-align: left; }
  .pagination-jump { width: 100%; justify-content: center; margin: 5px 0 0; }
  .queue-item { grid-template-columns: 18px 1fr; }
  .queue-index { display: none; }
  .queue-actions { grid-column: 2; flex-wrap: wrap; justify-content: flex-start; }
  .channel-live-bar { align-items: flex-start; flex-direction: column; }
  .channel-live-bar > div { text-align: left; }
  .channel-scope { align-items: stretch; flex-direction: column; width: 100%; }
  .channel-post-card { grid-template-columns: 1fr; }
  .channel-post-media { min-height: 150px; max-height: 230px; }
  .login-card { padding: 30px 24px; }
}
