:root {
  color-scheme: light;
  --ink: #111512;
  --muted: #687069;
  --canvas: #f2f0e9;
  --paper: #fbfaf6;
  --line: #dddcd4;
  --line-dark: #c8c8bf;
  --green: #1f694b;
  --green-dark: #15513a;
  --green-soft: #e4f0e8;
  --amber: #a86716;
  --amber-soft: #fff0d7;
  --red: #a33a31;
  --red-soft: #fbe7e3;
  --blue: #30677d;
  --shadow: 0 14px 40px rgba(24, 32, 26, .08);
  --radius: 18px;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--canvas); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button, select { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 7px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: var(--serif); font-size: clamp(30px, 4vw, 46px); font-weight: 500; line-height: 1; letter-spacing: -.035em; }
h2 { margin-bottom: 5px; font-family: var(--serif); font-size: 27px; font-weight: 500; letter-spacing: -.02em; }
h3 { margin-bottom: 4px; font-size: 16px; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 30px 18px; background: radial-gradient(circle at 15% 12%, rgba(95, 142, 111, .18), transparent 30%), radial-gradient(circle at 87% 88%, rgba(182, 145, 78, .15), transparent 28%), #eeece4; }
.login-card { width: min(440px, 100%); padding: 45px; border: 1px solid rgba(30, 48, 37, .12); border-radius: 28px; background: rgba(251, 250, 246, .94); box-shadow: 0 30px 90px rgba(28, 35, 30, .12); }
.login-card h1 { margin: 4px 0 14px; font-size: 48px; }
.login-copy { max-width: 340px; margin-bottom: 30px; line-height: 1.6; }
.brand-mark { width: 56px; height: 56px; display: grid; place-items: center; margin-bottom: 26px; border-radius: 18px 4px 18px 4px; color: #fff; background: var(--green); font-family: var(--serif); font-size: 19px; box-shadow: 8px 8px 0 #d7c79b; }
.brand-mark-small { width: 38px; height: 38px; flex: 0 0 auto; margin: 0; border-radius: 12px 3px 12px 3px; font-size: 13px; box-shadow: 4px 4px 0 #5f6b62; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: 245px; display: flex; flex-direction: column; padding: 27px 18px 20px; color: #f4f5ef; background: #111512; }
.sidebar-brand { display: flex; align-items: center; gap: 14px; padding: 0 8px 28px; border-bottom: 1px solid rgba(255, 255, 255, .09); }
.sidebar-brand strong { display: block; font-family: var(--serif); font-size: 18px; font-weight: 500; }
.sidebar-brand span { display: block; margin-top: 2px; color: #8f9991; font-size: 11px; }
.side-nav { display: grid; gap: 5px; margin-top: 26px; }
.nav-item { width: 100%; display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; padding: 11px 12px; border: 0; border-radius: 11px; color: #aeb7b0; background: transparent; text-align: left; font-size: 13px; font-weight: 650; transition: .18s ease; }
.nav-item:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.nav-item.active { color: #fff; background: #23583f; }
.nav-symbol { width: 27px; height: 27px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.16); border-radius: 8px; font-family: var(--serif); font-size: 12px; }
.nav-badge { min-width: 22px; padding: 3px 6px; border-radius: 20px; color: #23382c; background: #dce9df; font-size: 10px; text-align: center; }
.sidebar-status { display: grid; gap: 14px; margin-top: auto; padding: 18px 10px; border-top: 1px solid rgba(255,255,255,.09); }
.status-line { display: flex; align-items: center; gap: 10px; }
.status-line b, .status-line small { display: block; }
.status-line b { color: #dce1dc; font-size: 11px; }
.status-line small { margin-top: 2px; color: #77817a; font-size: 10px; }
.status-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #6e746f; box-shadow: 0 0 0 4px rgba(255,255,255,.04); }
.status-dot.ok { background: #6ec594; box-shadow: 0 0 0 4px rgba(110,197,148,.12); }
.status-dot.warn { background: #e0a44c; }
.sidebar-logout { margin: 0 10px; color: #79827b !important; text-align: left; }

.main-content { min-height: 100vh; margin-left: 245px; padding: 36px clamp(24px, 4vw, 58px) 80px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 34px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border: 1px solid transparent; border-radius: 10px; font-size: 12px; font-weight: 750; transition: transform .15s ease, background .15s ease, border .15s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .55; transform: none; }
.button-primary { color: #fff; background: var(--green); border-color: var(--green); }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { color: #29302b; background: var(--paper); border-color: var(--line-dark); }
.button-secondary:hover { background: #fff; border-color: #a9aca5; }
.button-danger { color: var(--red); background: transparent; border-color: #dfbeb9; }
.button-danger:hover { background: var(--red-soft); }
.button-wide { width: 100%; }
.button-icon { font-size: 18px; line-height: 0; }
.text-button { padding: 0; border: 0; color: var(--green); background: transparent; font-size: 12px; font-weight: 750; }
.text-button:hover { text-decoration: underline; }
.icon-button { width: 36px; height: 36px; border: 0; border-radius: 50%; color: var(--muted); background: #ecebe5; font-size: 24px; line-height: 1; }
.autopilot-control { min-width: 156px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 9px 7px 13px; border: 1px solid var(--line-dark); border-radius: 11px; background: var(--paper); }
.autopilot-control span { display: flex; flex-direction: column; }
.autopilot-control b { font-size: 11px; }
.autopilot-control small { color: var(--muted); font-size: 9px; }
.autopilot-control input { position: absolute; opacity: 0; pointer-events: none; }
.autopilot-control i { position: relative; width: 38px; height: 22px; border-radius: 20px; background: #c9cdc9; transition: .2s; }
.autopilot-control i::after { content: ""; position: absolute; width: 16px; height: 16px; top: 3px; left: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2); transition: .2s; }
.autopilot-control input:checked + i { background: var(--green); }
.autopilot-control input:checked + i::after { transform: translateX(16px); }

.notice { margin-bottom: 22px; padding: 14px 17px; border: 1px solid; border-radius: 12px; font-size: 12px; line-height: 1.5; }
.notice-danger { color: #7d2c25; background: var(--red-soft); border-color: #e8b9b3; }
.metrics-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 14px; margin-bottom: 34px; }
.metric-card { min-height: 155px; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(251,250,246,.75); }
.metric-card p { margin-bottom: 18px; color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; }
.metric-card strong { display: block; margin-bottom: 9px; font-family: var(--serif); font-size: 38px; font-weight: 500; line-height: 1; }
.metric-card span { color: var(--muted); font-size: 11px; }
.metric-featured { color: #fff; background: var(--green); border-color: var(--green); box-shadow: var(--shadow); }
.metric-featured p, .metric-featured span { color: #bad3c4; }
.section-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin: 0 0 17px; }
.section-toolbar p, .settings-intro p { margin: 0; color: var(--muted); font-size: 12px; }
.filter-pills { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.45); }
.filter-pill { padding: 6px 11px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; font-size: 10px; font-weight: 750; }
.filter-pill.active { color: var(--ink); background: var(--paper); box-shadow: 0 2px 7px rgba(0,0,0,.07); }

.post-list { display: grid; gap: 13px; }
.post-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: 0 6px 24px rgba(25,32,27,.035); }
.post-card-main { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); }
.source-pane, .draft-pane { min-width: 0; padding: 21px 22px; }
.source-pane { border-right: 1px solid var(--line); background: #f5f3ed; }
.pane-label { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 13px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.source-text { max-height: 170px; overflow: auto; margin: 0; color: #4d544f; font-size: 12px; line-height: 1.7; white-space: pre-wrap; }
.source-link { color: var(--green); text-decoration: none; }
.source-media { width: 100%; max-height: 210px; object-fit: cover; margin: 14px 0 0; border-radius: 10px; background: #deddd7; }
.draft-pane { position: relative; }
.draft-html, .telegram-preview { font-size: 13px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.draft-html a, .telegram-preview a { color: #237497; }
.draft-summary { margin: 14px 0 0; padding-top: 12px; border-top: 1px dashed var(--line); color: var(--muted); font-size: 10px; line-height: 1.5; }
.post-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; border-top: 1px solid var(--line); background: #fff; }
.post-meta, .post-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.post-actions .button { min-height: 34px; padding: 6px 11px; font-size: 10px; }
.status-chip, .confidence-chip, .warning-chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 8px; font-size: 9px; font-weight: 800; }
.status-chip { color: #355848; background: var(--green-soft); }
.status-chip.failed, .status-chip.rejected_ai { color: #8d352e; background: var(--red-soft); }
.status-chip.processing, .status-chip.queued { color: #74500e; background: var(--amber-soft); }
.status-chip.denied { color: #606660; background: #e9e9e5; }
.confidence-chip { color: var(--blue); background: #e7f0f3; }
.warning-chip { color: #8a5613; background: var(--amber-soft); }
.empty-state { padding: 70px 24px; border: 1px dashed var(--line-dark); border-radius: var(--radius); color: var(--muted); background: rgba(255,255,255,.28); text-align: center; }
.empty-state strong { display: block; margin-bottom: 8px; color: var(--ink); font-family: var(--serif); font-size: 21px; font-weight: 500; }
.empty-state p { max-width: 420px; margin: 0 auto; font-size: 12px; line-height: 1.6; }
.skeleton { min-height: 220px; border-radius: var(--radius); background: linear-gradient(100deg, #e7e5de 30%, #f2f0ea 50%, #e7e5de 70%); background-size: 300% 100%; animation: shimmer 1.5s infinite; }
@keyframes shimmer { to { background-position-x: -150%; } }

.timeline-list { display: grid; gap: 1px; }
.timeline-item { position: relative; display: grid; grid-template-columns: 140px 16px 1fr; gap: 18px; min-height: 120px; }
.timeline-time { padding-top: 19px; text-align: right; }
.timeline-time strong, .timeline-time span { display: block; }
.timeline-time strong { font-family: var(--serif); font-size: 20px; font-weight: 500; }
.timeline-time span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.timeline-axis { position: relative; }
.timeline-axis::before { content: ""; position: absolute; top: 0; bottom: 0; left: 7px; width: 1px; background: var(--line-dark); }
.timeline-axis::after { content: ""; position: absolute; top: 25px; left: 3px; width: 9px; height: 9px; border: 2px solid var(--canvas); border-radius: 50%; background: var(--green); }
.timeline-card { margin-bottom: 13px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.timeline-card .draft-html { max-height: 110px; overflow: hidden; }
.timeline-card-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--line); }
.compact-list .post-card-main { grid-template-columns: 1fr; }
.compact-list .source-pane { display: none; }

.settings-intro { margin-bottom: 22px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.settings-card { padding: 23px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.settings-wide { grid-column: 1 / -1; }
.card-heading { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 22px; }
.card-heading p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.step-number { width: 27px; height: 27px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: var(--green); background: var(--green-soft); font-family: var(--serif); font-size: 12px; }
.badge { margin-left: auto; padding: 5px 8px; border-radius: 20px; color: #5f4306; background: #f6e7b6; font-size: 9px; font-weight: 800; }
.stack-form { display: grid; gap: 16px; }
.inline-form { display: flex; align-items: flex-start; gap: 10px; }
.inline-form .field { min-width: 180px; }
.inline-form .grow { flex: 1; }
.align-end { align-self: end; }
.field { display: grid; gap: 7px; }
.field label, .editor-grid > div > label { color: #414842; font-size: 10px; font-weight: 800; letter-spacing: .03em; }
.field small { color: var(--muted); font-size: 9px; line-height: 1.45; }
input, textarea, select { width: 100%; border: 1px solid var(--line-dark); border-radius: 9px; outline: none; color: var(--ink); background: #fff; transition: border .15s, box-shadow .15s; }
input, select { height: 42px; padding: 0 11px; }
textarea { min-height: 90px; padding: 11px; line-height: 1.55; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: #6e9a80; box-shadow: 0 0 0 3px rgba(45, 113, 79, .11); }
input[type="range"] { height: 6px; padding: 0; accent-color: var(--green); box-shadow: none; }
label output { float: right; color: var(--green); }
.form-error { min-height: 17px; margin: 0; color: var(--red); font-size: 11px; }
.form-note { margin: 9px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.two-columns { display: grid; grid-template-columns: 1fr 35px 1fr; align-items: center; gap: 8px; }
.route-arrow { margin-top: 8px; color: var(--green); text-align: center; font-size: 19px; }
.two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.label-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.check-row { display: flex; align-items: flex-start; gap: 10px; }
.check-row input { width: 17px; height: 17px; margin-top: 1px; accent-color: var(--green); }
.check-row b, .check-row small { display: block; }
.check-row b { font-size: 11px; }
.check-row small { margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.4; }
.connected-card { display: flex; align-items: center; gap: 11px; margin-bottom: 17px; padding: 12px; border: 1px solid #bfdbc9; border-radius: 11px; background: var(--green-soft); }
.connected-card strong, .connected-card span { display: block; }
.connected-card strong { font-size: 12px; }
.connected-card span { margin-top: 3px; color: var(--muted); font-size: 9px; }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--green); font-family: var(--serif); }
.connection-ok { margin-left: auto !important; color: var(--green) !important; font-weight: 800; }
.emoji-form { display: grid; grid-template-columns: .7fr .45fr 1.3fr auto; gap: 7px; }
.emoji-list { display: grid; gap: 6px; margin-top: 14px; }
.emoji-row { display: grid; grid-template-columns: 30px 1fr 1fr auto; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; font-size: 10px; }
.emoji-row code { color: var(--green); }
.emoji-row button { border: 0; color: var(--red); background: transparent; }

.modal { width: min(520px, calc(100% - 28px)); padding: 0; border: 1px solid var(--line); border-radius: 20px; color: var(--ink); background: var(--paper); box-shadow: 0 28px 100px rgba(14,20,16,.28); }
.modal::backdrop { background: rgba(11, 15, 12, .55); backdrop-filter: blur(3px); }
.modal form { padding: 24px; }
.modal-large { width: min(920px, calc(100% - 28px)); }
.modal-heading { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 21px; }
.modal-heading h2 { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.split-actions { justify-content: space-between; }
.split-actions > div { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.editor-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 18px; }
.telegram-preview { min-height: 302px; max-height: 410px; overflow: auto; margin-top: 7px; padding: 17px; border: 1px solid #cbd8d0; border-radius: 12px; background: #ecf4ef; }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 8px; pointer-events: none; }
.toast { width: min(340px, calc(100vw - 32px)); padding: 13px 15px; border: 1px solid #3c5446; border-radius: 11px; color: #fff; background: #1e2922; box-shadow: var(--shadow); font-size: 11px; line-height: 1.45; animation: toast-in .22s ease both; }
.toast.error { border-color: #8e4a42; background: #662e29; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.bottom-nav { display: none; }

@media (max-width: 980px) {
  .sidebar { width: 205px; }
  .main-content { margin-left: 205px; padding-inline: 23px; }
  .sidebar-brand strong { font-size: 16px; }
  .post-card-main { grid-template-columns: 1fr; }
  .source-pane { border-right: 0; border-bottom: 1px solid var(--line); }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-wide { grid-column: auto; }
  .emoji-form { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 22px 15px 100px; }
  .topbar { align-items: flex-start; margin-bottom: 24px; }
  .topbar h1 { font-size: 34px; }
  .topbar-actions { align-items: flex-end; flex-direction: column-reverse; }
  #syncButton { min-height: 34px; padding: 6px 10px; }
  .autopilot-control { min-width: 142px; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-featured { grid-column: 1 / -1; }
  .metric-card { min-height: 125px; padding: 18px; }
  .section-toolbar { align-items: flex-start; flex-direction: column; }
  .post-card-footer { align-items: flex-start; flex-direction: column; }
  .post-actions { width: 100%; }
  .post-actions .button { flex: 1; }
  .timeline-item { grid-template-columns: 80px 12px 1fr; gap: 10px; }
  .timeline-time strong { font-size: 15px; }
  .timeline-axis::before { left: 5px; }
  .timeline-axis::after { left: 1px; }
  .two-columns { grid-template-columns: 1fr; }
  .route-arrow { transform: rotate(90deg); }
  .inline-form, .editor-grid { display: grid; grid-template-columns: 1fr; }
  .two-fields { grid-template-columns: 1fr; }
  .split-actions, .split-actions > div { justify-content: stretch; flex-direction: column; }
  .split-actions .button { width: 100%; }
  .emoji-form { grid-template-columns: 1fr; }
  .login-card { padding: 34px 27px; }
  .bottom-nav { position: fixed; z-index: 30; inset: auto 0 0; height: calc(68px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(4, 1fr); padding: 8px 8px env(safe-area-inset-bottom); border-top: 1px solid #2a302c; color: #8f9991; background: #111512; }
  .bottom-nav button { display: grid; place-items: center; gap: 2px; border: 0; color: inherit; background: transparent; font-size: 9px; }
  .bottom-nav b { width: 25px; height: 25px; display: grid; place-items: center; border: 1px solid #3d4640; border-radius: 7px; font-family: var(--serif); font-size: 11px; }
  .bottom-nav button.active { color: #bfe1ca; }
  .bottom-nav button.active b { border-color: #4c8f69; background: #23583f; }
}

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