:root {
  color-scheme: light;
  --paper: #f4f5f1;
  --surface: #ffffff;
  --ink: #181b1a;
  --muted: #68706d;
  --line: #d9ddda;
  --accent: #0f6f78;
  --accent-soft: #dceff0;
  --coral: #d85945;
  --coral-soft: #f8e5e1;
  --amber: #a76400;
  --amber-soft: #f6ead4;
  --charcoal: #232827;
  --sidebar-width: 228px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; color: var(--ink); background: var(--paper); font-size: 14px; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--charcoal); }
.login-panel { width: min(480px, 100%); padding: 44px; background: var(--surface); border-top: 6px solid #8ed5d9; }
.brand-mark { display: inline-grid; place-items: center; width: 42px; height: 42px; border: 1px solid currentColor; transform: rotate(45deg); font-weight: 800; font-size: 12px; }
.brand-mark::first-line { transform: rotate(-45deg); }
.login-panel .brand-mark { margin-bottom: 38px; }
.kicker { margin: 0 0 9px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 0.12em; }
.login-panel h1 { margin: 0 0 34px; font-size: 34px; line-height: 1.05; }
.login-panel label { display: block; margin-bottom: 8px; font-weight: 700; }
.password-row { display: grid; grid-template-columns: 1fr auto; border-bottom: 1px solid var(--ink); }
.password-row input { min-width: 0; padding: 13px 0; border: 0; outline: none; background: transparent; }
.password-row button { border: 0; padding: 0 16px; background: var(--ink); color: white; font-weight: 700; }
.form-error { min-height: 20px; color: var(--coral); }

.app-shell { min-height: 100vh; padding-left: var(--sidebar-width); }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); display: flex; flex-direction: column; padding: 22px 16px; background: var(--charcoal); color: #f6f7f4; z-index: 20; }
.sidebar-brand { display: flex; align-items: center; gap: 15px; min-height: 70px; padding: 0 10px 22px; border-bottom: 1px solid #3d4442; }
.sidebar-brand .brand-mark { width: 34px; height: 34px; color: #9ed9dd; }
.sidebar-brand div { display: grid; gap: 4px; }
.sidebar-brand strong { font-size: 14px; letter-spacing: 0.12em; }
.sidebar-brand small { color: #aeb7b4; font-size: 11px; }
.app-nav { display: grid; gap: 3px; margin-top: 24px; }
.nav-item { width: 100%; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px; border: 0; background: transparent; color: #b8c1be; text-align: left; }
.nav-item span { color: #7e8a87; font-size: 10px; font-weight: 800; }
.nav-item em { min-width: 22px; padding: 2px 6px; border-radius: 8px; background: #3a4240; color: white; font-size: 10px; font-style: normal; text-align: center; }
.nav-item:hover, .nav-item.is-active { background: #343b39; color: white; }
.nav-item.is-active { box-shadow: inset 3px 0 #9ed9dd; }
.sidebar-foot { display: grid; gap: 8px; margin-top: auto; padding: 18px 10px 0; border-top: 1px solid #3d4442; }
.sidebar-foot a, .sidebar-foot button { border: 0; padding: 5px 0; background: transparent; color: #aeb7b4; text-decoration: none; text-align: left; font-size: 12px; }
.sidebar-foot a:hover, .sidebar-foot button:hover { color: white; }

.workspace { min-width: 0; padding: 28px clamp(24px, 4vw, 64px) 72px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: clamp(27px, 3vw, 42px); line-height: 1; }
.topbar-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.primary-action, .secondary-action, .danger-action { min-height: 38px; border: 1px solid var(--line); border-radius: 6px; padding: 0 14px; background: var(--surface); color: var(--ink); font-weight: 700; }
.primary-action { border-color: var(--charcoal); background: var(--charcoal); color: white; }
.danger-action { border-color: #e6beb6; color: #a33725; background: #fff7f5; }
.primary-action:hover { background: var(--accent); border-color: var(--accent); }
.secondary-action:hover { border-color: var(--ink); }
.topbar-actions button span { margin-right: 5px; font-size: 17px; }

.summary-strip { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.summary-strip > div { display: grid; grid-template-columns: auto 1fr; column-gap: 11px; align-items: baseline; padding: 19px 20px 19px 0; }
.summary-strip > div + div { padding-left: 20px; border-left: 1px solid var(--line); }
.summary-strip span { grid-column: 1 / -1; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: 0.12em; }
.summary-strip strong { font-size: 26px; }
.summary-strip small { color: var(--muted); }

.view { display: none; padding-top: 22px; }
.view.is-active { display: block; }
.filterbar, .section-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.segmented { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--surface); }
.segmented button { min-height: 36px; border: 0; border-right: 1px solid var(--line); padding: 0 14px; background: transparent; color: var(--muted); }
.segmented button:last-child { border-right: 0; }
.segmented button.is-active { background: var(--charcoal); color: white; }
.search-field { display: flex; align-items: center; gap: 7px; width: min(420px, 48vw); min-height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.search-field.wide { width: min(620px, 70vw); }
.search-field input { width: 100%; border: 0; outline: none; background: transparent; }
.toggle-row, .check-line { display: flex !important; align-items: center; gap: 8px; }

.candidate-list { display: grid; gap: 10px; }
.candidate-card { display: grid; grid-template-columns: 34px minmax(130px, 190px) minmax(0, 1fr) auto; min-height: 164px; border: 1px solid var(--line); background: var(--surface); transition: border-color 160ms ease, transform 160ms ease; }
.candidate-card:hover { border-color: #9ba5a1; transform: translateY(-1px); }
.select-cell { display: grid; place-items: start center; padding-top: 14px; border-right: 1px solid var(--line); }
.select-cell input { width: 16px; height: 16px; accent-color: var(--accent); }
.candidate-thumb { position: relative; min-height: 164px; overflow: hidden; background: #e8ebe7; }
.candidate-thumb img { width: 100%; height: 100%; position: absolute; inset: 0; object-fit: cover; }
.image-count { position: absolute; right: 7px; bottom: 7px; padding: 3px 6px; border-radius: 4px; background: rgba(20, 25, 24, .82); color: white; font-size: 10px; }
.candidate-body { min-width: 0; padding: 17px 20px; }
.candidate-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 9px; color: var(--muted); font-size: 11px; }
.candidate-meta span:first-child { color: var(--accent); font-weight: 800; }
.candidate-body h3 { margin: 0 0 8px; font-size: 17px; line-height: 1.25; }
.candidate-body p { display: -webkit-box; overflow: hidden; margin: 0; color: #4e5754; line-height: 1.55; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.candidate-side { width: 150px; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end; gap: 14px; padding: 17px; border-left: 1px solid var(--line); }
.status-badge { display: inline-flex; align-items: center; min-height: 23px; padding: 0 8px; border-radius: 4px; background: var(--amber-soft); color: var(--amber); font-size: 10px; font-weight: 800; }
.status-badge.ready, .status-badge.approved { background: var(--accent-soft); color: var(--accent); }
.status-badge.failed { background: var(--coral-soft); color: var(--coral); }
.category-label { color: var(--muted); font-size: 11px; text-align: right; }
.text-action { border: 0; padding: 5px 0; background: transparent; color: var(--accent); font-weight: 700; }
.empty-state { padding: 80px 20px; text-align: center; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.empty-state strong, .empty-state span { display: block; }
.empty-state strong { font-size: 20px; }
.empty-state span { margin-top: 7px; color: var(--muted); }

.published-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.published-card { min-width: 0; border: 1px solid var(--line); background: var(--surface); }
.published-card.is-hidden { opacity: .5; }
.published-card button { width: 100%; border: 0; padding: 0; background: transparent; color: inherit; text-align: left; }
.published-image { aspect-ratio: 4 / 3; overflow: hidden; background: #e5e8e4; }
.published-image img { width: 100%; height: 100%; object-fit: cover; }
.published-copy { padding: 13px 14px 15px; }
.published-copy small { color: var(--accent); font-weight: 800; }
.published-copy h3 { margin: 7px 0 5px; font-size: 15px; line-height: 1.3; }
.published-copy p { overflow: hidden; margin: 0; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }

.source-list { display: grid; border-top: 1px solid var(--line); }
.source-row { display: grid; grid-template-columns: 44px minmax(180px, 1.2fr) minmax(180px, 1fr) 120px 150px 42px; align-items: center; min-height: 68px; border-bottom: 1px solid var(--line); }
.source-row > * { padding: 0 13px; }
.source-row strong { display: block; }
.source-row small { color: var(--muted); }
.source-platform { color: var(--accent); font-size: 10px; font-weight: 800; }
.source-state { color: var(--muted); }
.source-state.error { color: var(--coral); }
.switch { position: relative; width: 34px; height: 19px; padding: 0; border: 0; border-radius: 10px; background: #c6ccc9; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 13px; height: 13px; border-radius: 50%; background: white; transition: transform 160ms ease; }
.switch.is-on { background: var(--accent); }
.switch.is-on::after { transform: translateX(15px); }
.icon-button { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; color: inherit; font-size: 22px; }
.icon-button:hover { background: #e8ebe8; }
.policy-band { display: grid; grid-template-columns: 140px 1fr; gap: 20px; margin-top: 28px; padding: 18px 0; border-top: 1px dashed #aeb6b2; border-bottom: 1px dashed #aeb6b2; color: var(--muted); line-height: 1.6; }
.policy-band strong { color: var(--ink); }

.job-head, .job-row { display: grid; grid-template-columns: 180px 160px 100px minmax(0, 1fr); gap: 12px; align-items: center; min-height: 48px; border-bottom: 1px solid var(--line); }
.job-head { min-height: 34px; color: var(--muted); font-size: 10px; font-weight: 800; }
.job-row span:last-child { color: var(--muted); }

.drawer-backdrop { position: fixed; inset: 0; z-index: 40; border: 0; background: rgba(24, 28, 27, .36); opacity: 0; visibility: hidden; transition: opacity 220ms ease, visibility 220ms ease; backdrop-filter: blur(3px); }
.editor-drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: min(620px, 94vw); overflow: auto; background: var(--surface); transform: translateX(102%); transition: transform 260ms cubic-bezier(.2,.8,.2,1); box-shadow: -18px 0 60px rgba(20, 25, 24, .16); }
body.drawer-open .drawer-backdrop { opacity: 1; visibility: visible; }
body.drawer-open .editor-drawer { transform: translateX(0); }
.drawer-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; min-height: 82px; padding: 18px 24px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.95); backdrop-filter: blur(10px); }
.drawer-head h2 { margin: 7px 0 0; font-size: 21px; }
.editor-media { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 78%); gap: 8px; overflow-x: auto; padding: 18px 24px; scroll-snap-type: x mandatory; background: #eceeeb; }
.editor-media figure { height: 340px; margin: 0; scroll-snap-align: start; background: #dfe3df; }
.editor-media img { width: 100%; height: 100%; object-fit: contain; }
.editor-form { display: grid; gap: 17px; padding: 24px; }
.editor-form label, .form-grid label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
.editor-form input, .editor-form select, .editor-form textarea, .form-grid input, .form-grid select, .form-grid textarea { width: 100%; border: 1px solid var(--line); border-radius: 5px; padding: 11px 12px; outline: none; background: white; color: var(--ink); }
.editor-form textarea { min-height: 230px; resize: vertical; line-height: 1.6; }
.editor-form input:focus, .editor-form select:focus, .editor-form textarea:focus, .form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.prompt-meta { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; }
.source-link { color: var(--accent); text-decoration: none; }
.drawer-actions { display: grid; grid-template-columns: auto auto 1fr 1fr; gap: 8px; padding-top: 8px; }

.modal { width: min(720px, calc(100vw - 32px)); max-height: 90vh; padding: 0; border: 0; border-radius: 7px; background: var(--surface); box-shadow: 0 25px 80px rgba(20, 25, 24, .24); }
.small-modal { width: min(580px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(23, 27, 26, .48); backdrop-filter: blur(4px); }
.modal header, .modal footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.modal footer { justify-content: flex-end; border-top: 1px solid var(--line); border-bottom: 0; }
.modal h2 { margin: 0; font-size: 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-height: calc(90vh - 160px); overflow: auto; padding: 24px; }
.form-grid .full { grid-column: 1 / -1; }
.check-line { grid-template-columns: auto 1fr !important; }
.check-line input { width: 16px; height: 16px; accent-color: var(--accent); }

.toast { position: fixed; right: 20px; bottom: 20px; z-index: 80; max-width: 420px; padding: 12px 16px; border-radius: 5px; background: var(--charcoal); color: white; opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity 160ms ease, transform 160ms ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: #9e3525; }

@media (max-width: 900px) {
  :root { --sidebar-width: 72px; }
  .sidebar { padding-inline: 10px; }
  .sidebar-brand { justify-content: center; padding-inline: 0; }
  .sidebar-brand div, .nav-item:not(.is-active)::after, .nav-item { font-size: 0; }
  .nav-item { grid-template-columns: 1fr; justify-items: center; padding: 0; }
  .nav-item span { font-size: 11px; }
  .nav-item em { display: none; }
  .sidebar-foot { padding-inline: 0; }
  .sidebar-foot a, .sidebar-foot button { font-size: 0; }
  .sidebar-foot a::first-letter, .sidebar-foot button::first-letter { font-size: 12px; }
  .candidate-card { grid-template-columns: 34px 150px minmax(0, 1fr); }
  .candidate-side { grid-column: 2 / -1; width: auto; flex-direction: row; align-items: center; padding: 10px 17px; border-top: 1px solid var(--line); border-left: 0; }
  .source-row { grid-template-columns: 40px 1fr 100px 42px; }
  .source-row .source-locator, .source-row .source-state { display: none; }
}

@media (max-width: 680px) {
  :root { --sidebar-width: 0px; }
  .app-shell { padding: 0; }
  .sidebar { position: fixed; inset: auto 0 0; width: 100%; height: 62px; flex-direction: row; padding: 7px; }
  .sidebar-brand, .sidebar-foot { display: none; }
  .app-nav { width: 100%; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 0; }
  .nav-item { min-height: 48px; }
  .nav-item.is-active { box-shadow: inset 0 -3px #9ed9dd; }
  .workspace { padding: 20px 14px 100px; }
  .topbar { align-items: flex-start; }
  .topbar-actions { display: grid; grid-template-columns: repeat(3, 38px); }
  .topbar-actions button { width: 38px; overflow: hidden; padding: 0; font-size: 0; }
  .topbar-actions button span { margin: 0; font-size: 18px; }
  .summary-strip { grid-template-columns: repeat(2, 1fr); }
  .summary-strip > div:nth-child(3) { border-left: 0; }
  .summary-strip > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .filterbar, .section-toolbar { align-items: stretch; flex-direction: column; }
  .search-field, .search-field.wide { width: 100%; }
  .segmented { overflow-x: auto; }
  .segmented button { flex: 1 0 auto; }
  .candidate-card { grid-template-columns: 30px 112px minmax(0, 1fr); min-height: 138px; }
  .candidate-thumb { min-height: 138px; }
  .candidate-body { padding: 13px; }
  .candidate-body p { -webkit-line-clamp: 2; }
  .published-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .published-copy h3 { font-size: 13px; }
  .source-row { grid-template-columns: 36px 1fr 42px; }
  .source-row .source-frequency { display: none; }
  .policy-band { grid-template-columns: 1fr; }
  .job-head, .job-row { grid-template-columns: 105px 1fr 70px; }
  .job-head span:last-child, .job-row span:last-child { display: none; }
  .drawer-actions { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .login-panel { padding: 34px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
