/* КосмоЙога · Blue Mini App. See design-system/blue-miniapp.md before restyling. */
:root {
  color-scheme: light;
  --ink: #203f68;
  --ink-secondary: #304d6c;
  --muted: #4e647b;
  --accent: #6595b9;
  --action: #2f648f;
  --action-hover: #244f75;
  --sky: #dbe7f0;
  --surface: #edf1f4;
  --surface-soft: #e2e8ed;
  --surface-glass: #edf1f4;
  --border: #bdccd8;
  --control-border: #71859a;
  --action-top: #39729e;
  --surface-inset: #e5ebef;
  --surface-preview: #dbe3e9;
  --surface-hover: #cfdfe9;
  --draft: #526078;
  --draft-soft: #e3e8ee;
  --placeholder: #536980;
  --glass-fill: #e4edf4c9;
  --glass-edge: #829cb5;
  --glass-highlight: #f4faffb3;
  --glass-shadow: #244f7526;
  --glass-art-opacity: .65;
  --focus: #2f648f;
  --focus-ring: #2f648f21;
  --pattern: #90a9bc44;
  --shadow-soft: #0f3b8209;
  --shadow-card: #0f3b8214;
  --shadow-dialog: #0f3b8233;
  --scrim: #0d244966;
  --success: #176448;
  --success-soft: #eaf6f0;
  --warning: #82500c;
  --warning-soft: #fff5e3;
  --warning-border: #e6c997;
  --danger: #a12e3d;
  --danger-soft: #fff0f2;
  --danger-border: #e6b9c0;
  --danger-ring: #a12e3d26;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-editorial: Georgia, "Times New Roman", serif;
  --radius-card: 18px;
  --radius-control: 12px;
  --control-height: 44px;
  --button-padding: 10px 14px;
  --button-font-size: 13px;
  --space-control: 8px;
}

/* Complete dark material; all components inherit these semantic roles. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #dfecff; --ink-secondary: #ceddf0; --muted: #a9bed5;
  --accent: #7db3de; --action: #90c7f0; --action-hover: #b4ddfa;
  --action-top: #9dd0f5; --sky: #243e58;
  --surface: #172b40; --surface-soft: #0d1c2d; --surface-glass: #172b40;
  --surface-inset: #1a3047; --surface-preview: #102338; --surface-hover: #2d4a66;
  --border: #39526b; --control-border: #7894af;
  --focus: #9ed2fa; --focus-ring: #9ed2fa40; --pattern: #5483a533;
  --shadow-soft: #030a121f; --shadow-card: #030a1233; --shadow-dialog: #02081199;
  --scrim: #030b16b3;
  --success: #8de0bc; --success-soft: #123c30;
  --warning: #f2cc8d; --warning-soft: #44341d; --warning-border: #967c4e;
  --danger: #ffb3bf; --danger-soft: #452530; --danger-border: #a56775; --danger-ring: #ffb3bf33;
  --draft: #c0cde4; --draft-soft: #29364e; --placeholder: #a9bed5;
  --glass-fill: #192f45d1; --glass-edge: #6388a8; --glass-highlight: #a8dcff66;
  --glass-shadow: #02091566; --glass-art-opacity: .4;
}

body {
  background: var(--surface-soft);
  font-family: var(--font-body);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
h1, .editor-heading h2, .confirmation h2 {
  font-family: var(--font-editorial);
  font-weight: 400;
  letter-spacing: -1.2px;
  text-wrap: balance;
}
h1 { font-size: clamp(36px, 3.6vw, 48px); line-height: 1.12; }
.editor-heading h2, .confirmation h2 { font-size: 30px; line-height: 1.2; }
h3 { color: var(--ink); }
button, input, select, textarea { font-family: var(--font-body); }
button, summary { transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease; }
button:disabled { cursor: not-allowed; }
button:active:not(:disabled), summary:active { filter: brightness(.96); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* A quiet brand rail: ornament is decorative and never sits behind useful text. */
.sidebar {
  background: linear-gradient(165deg, var(--surface), var(--surface-soft));
  border-color: var(--border);
}
.brand { gap: 10px; color: var(--ink); font-family: var(--font-editorial); font-weight: 400; letter-spacing: -.6px; }
.brand small { font: 8px/1.5 var(--font-body); letter-spacing: 1.3px; color: var(--muted); }
.brand-mark { display: block; width: 48px; height: 48px; flex: 0 0 48px; border-radius: 0; background: transparent; object-fit: contain; }
.sidebar nav { gap: 8px; }
.nav { min-height: 48px; border-radius: var(--radius-control); color: var(--muted); padding: 13px 15px; }
.nav:hover { background: var(--sky); color: var(--ink); }
.nav.active { color: var(--ink); background: var(--sky); box-shadow: inset 3px 0 var(--action); }
.nav svg { stroke-width: 1.6; }
.sidebar-foot { padding-top: 20px; border-top: 1px solid var(--border); }
.sidebar-foot small { font-size: 12px; }
.avatar { background: var(--surface); color: var(--action); border-color: var(--border); }
.topline { font-size: 11px; letter-spacing: 1.5px; }
.timezone { font-size: 12px; }
.page-header { margin-top: 32px; }
.page-header p { color: var(--muted); font-size: 14px; }

.primary {
  min-height: var(--control-height);
  padding: var(--button-padding);
  font-size: var(--button-font-size);
  line-height: 1.4;
  white-space: nowrap;
  border-radius: var(--radius-control);
  background: linear-gradient(180deg, var(--action-top), var(--action));
  box-shadow: 0 3px 10px #1266c71a;
  font-weight: 600;
  color: #fff;
}
.primary:hover { background: var(--action-hover); }
.secondary, .quiet {
  min-height: var(--control-height);
  padding: var(--button-padding);
  border: 1px solid var(--control-border);
  line-height: 1.4;
  border-radius: var(--radius-control);
  background: var(--surface);
  border-color: var(--control-border);
  color: var(--ink);
  font-size: var(--button-font-size);
}
.secondary:hover, .quiet:hover { background: var(--sky); }
.environment { background: transparent; border: 0; border-left: 2px solid var(--border); border-radius: 0; padding: 3px 12px; margin-top: 24px; color: var(--muted); font-size: 12px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 22px 0 18px; }
.stats > div, .stats > button { display: flex; flex-direction: column; min-width: 0; min-height: 142px; border: 1px solid var(--sky); border-radius: var(--radius-card); background: var(--surface); padding: 18px 20px; text-align: left; color: inherit; box-shadow: 0 2px 9px var(--shadow-soft); }
.stats > button:hover, .stats > button.selected { border-color: var(--action); background: var(--sky); }
.stats small { min-height: 30px; font-size: 10px; line-height: 1.5; color: var(--muted); letter-spacing: 1px; overflow-wrap: anywhere; }
.stats strong { margin: 8px 0 2px; color: var(--ink); font-family: var(--font-body); font-variant-numeric: lining-nums tabular-nums; font-size: 36px; font-weight: 500; line-height: 1.2; letter-spacing: -1px; }
.stats span { min-height: 36px; margin-top: 0; padding-top: 9px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.next-publications h2 { font-size: 15px; }
#upcoming-list li { border-left: 2px solid var(--accent); background: var(--sky); border-radius: 0 10px 10px 0; }
.upcoming-post:hover, .upcoming-post:focus-visible { background: var(--surface-hover); }
.upcoming-post { gap: 6px; }
#upcoming-list time { color: var(--ink); }

.filter-panel { border-radius: 14px; background: var(--surface); padding: 0; margin: 20px 0; }
.filter-panel > summary { min-height: 52px; padding: 12px 16px; border-radius: 14px; gap: 12px; }
.filter-panel > summary > span:first-child { font-size: 14px; font-weight: 600; color: var(--ink); margin-left: 0; }
.filter-panel > summary::after { font-size: 20px; color: var(--action); }
.filter-panel[open] > summary { margin-bottom: 8px; }
.filters { gap: 5px; }
.filters button { min-height: 44px; border-radius: 10px; font-size: 12px; color: var(--muted); }
.filters .selected { background: var(--ink); color: #fff; }
.filters button:not(.selected):hover { background: var(--sky); }
.search input { background: var(--surface); font-size: 14px; }
.bulk-bar { background: var(--sky); border: 1px solid var(--border); border-radius: 14px; padding: 12px; font-size: 13px; }
.selection-toolbar { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.post-list { gap: 14px; }
.post-card { padding: 20px; border-radius: var(--radius-card); gap: 16px; box-shadow: 0 2px 8px var(--shadow-soft); }
.post-card:hover { border-color: #a9c4e4; box-shadow: 0 5px 18px var(--shadow-soft); }
.post-card:has(.post-selection input:checked) { border-color: var(--action); background: var(--sky); box-shadow: inset 0 0 0 1px var(--action); }
.post-icon { border-radius: 12px; background: var(--sky); color: var(--action); width: 48px; height: 48px; }
.post-card h3 { margin: 8px 0 10px; font-family: var(--font-body); font-size: 17px; letter-spacing: -.2px; line-height: 1.4; font-weight: 600; }
.excerpt { color: var(--muted); }
.meta { gap: 6px 16px; line-height: 1.7; }
.meta .next-send { color: var(--ink); font-weight: 600; }
.badge { border-radius: 6px; font-size: 11px; padding: 3px 8px; }
.badge.active { background: var(--sky); color: var(--ink); }
.badge.completed { background: var(--success-soft); color: var(--success); }
.badge.draft { background: var(--draft-soft); color: var(--draft); }
.badge.paused { background: var(--warning-soft); color: var(--warning); }
.card-actions { gap: 8px; margin-top: 14px; }
.card-actions button { min-height: 44px; padding: 9px 14px; border-radius: 10px; font-size: 13px; }
.card-actions .edit { background: var(--sky); color: var(--ink); }
.card-actions .edit:hover { background: var(--surface-hover); }
.card-actions .danger-text { color: var(--danger); background: var(--danger-soft); }
.post-menu { position: relative; border: 0; margin: 0; padding: 0; }
.post-menu > summary { list-style: none; min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 14px; border-radius: 10px; background: var(--surface-soft); color: var(--ink); font-size: 13px; }
.post-menu > summary::-webkit-details-marker { display: none; }
.post-menu > summary > span[aria-hidden="true"] { display: none; }
.post-menu > summary::after { content: '⌄'; color: var(--muted); }
.post-menu[open] > summary { background: var(--sky); }
.post-menu-actions { position: absolute; top: calc(100% + 6px); right: 0; z-index: 4; width: 220px; max-width: calc(100vw - 48px); padding: 6px; display: grid; gap: 4px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 8px 28px var(--shadow-dialog); }
.post-menu-actions button { width: 100%; text-align: left; white-space: normal; background: var(--surface); }
.post-menu-actions button:hover { background: var(--sky); }
.post-selection { color: var(--ink); padding: 6px 10px; }
.post-selection:has(input:checked) { background: var(--sky); }
.post-selection input { accent-color: var(--action); }
.pager { font-size: 13px; color: var(--muted); }
.empty { padding: 40px 24px; border-radius: var(--radius-card); background: var(--surface); }

/* The editor shares the same palette, with plain readable controls. */
dialog { background: var(--surface); border-color: var(--border); border-radius: 22px; }
.editor-heading { background: var(--surface-glass); border-color: var(--border); }
.eyebrow { font-size: 10px; letter-spacing: 1.3px; color: var(--muted); }
.editor-author { font-size: 12px; }
label { color: var(--ink-secondary); font-size: 13px; }
input, select, textarea { width: 100%; min-width: 0; padding: 10px 12px; border: 1px solid var(--control-border); border-radius: 10px; background: var(--surface); color: var(--ink-secondary); outline: none; }
/* macOS WebKit otherwise draws a short native select despite min-height. */
select, .mode-label select {
  appearance: none;
  -webkit-appearance: none;
  min-height: 44px;
  padding: 10px 34px 10px 12px;
  background-image: url("/static/select-chevron.svg?v=20260927-v4");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}
input::placeholder, textarea::placeholder { color: var(--placeholder); }
input:focus, select:focus, textarea:focus { border-color: var(--action); box-shadow: 0 0 0 3px var(--focus-ring); }
input[type="checkbox"], input[type="radio"] { padding: 0; width: 20px; height: 20px; min-height: 0; accent-color: var(--action); }
.hint, .muted, .section-title p, .editor-actions span { font-size: 12px; color: var(--muted); }
.format-toolbar button, .schedule-presets button { min-height: 44px; border-color: var(--control-border); border-radius: 10px; background: var(--surface); color: var(--ink); }
.format-toolbar button:hover, .schedule-presets button:hover { background: var(--sky); }
.visual-body { border-color: var(--control-border); background: var(--surface); color: var(--ink-secondary); font-size: 16px; }
.visual-body:focus { outline-color: var(--action); }
.visual-body a, .formatted a { color: var(--action); }
.upload-zone { background: var(--surface-soft); border-color: var(--control-border); color: var(--ink); border-radius: 12px; min-height: 62px; display: grid; place-items: center; }
.upload-zone.drag-over { border-color: var(--action); background: var(--sky); }
.schedule-summary, .storage-note { background: var(--sky); border-left-color: var(--accent); color: var(--ink-secondary); }
.rule { border-radius: 14px; background: var(--surface-soft); }
.rule-title, .date-item { color: var(--ink-secondary); font-size: 12px; }
.rule-days label { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; min-width: 58px; padding: 8px 10px; border-radius: 9px; font-size: 12px; font-weight: 500; background: var(--surface); border: 1px solid var(--border); }
.rule-days label:has(input:checked) { background: var(--sky); border-color: #8da8bd; }
.rule-days input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
  min-height: 17px;
  max-height: 17px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--control-border);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: none;
  cursor: pointer;
}
.rule-days input[type="checkbox"]:checked {
  background-color: var(--sky);
  background-image: url("/static/check-mark.svg?v=20260927-v4");
  background-size: 15px;
  background-repeat: no-repeat;
  background-position: center;
  border-color: var(--action);
}
.rule-days input[type="checkbox"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.rule-days input[type="checkbox"]:disabled { opacity: .5; cursor: not-allowed; }
.preview-column { background: transparent; min-height: 0; }
.dates-panel { margin-top: 20px; padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-inset); }
.dates-panel h3 { margin-bottom: 12px; }
.dates-panel .date-item:last-child { border-bottom: 0; }
.preview-label { color: var(--muted); font-size: 10px; }
.telegram-stage { background: var(--surface-preview); border: 1px solid var(--border); border-radius: 16px; padding: 18px 14px; min-height: 0; }
.telegram-bubble { background: var(--surface); border-radius: 12px 12px 12px 4px; }
.channel-name { color: var(--action); }
.formatted { color: var(--ink-secondary); font-size: 14px; }
.preview-button { background: var(--surface-glass); color: var(--ink); min-height: 44px; }
.editor-actions { background: var(--surface-glass); }
.editor-actions > div { flex-wrap: wrap; }
.editor-tabs { background: var(--surface); }
.editor-tabs button[aria-selected="true"] { background: var(--sky); color: var(--ink); }
.error { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); }
.history-row { border-radius: 16px; background: var(--surface); }
.history-row p { color: var(--muted); font-size: 13px; }
.history-row .card-actions { justify-content: flex-start; }
.post-date { color: var(--ink); font-weight: 600; }
.resolve-dialog .resolve-post { background: var(--sky); border-left: 3px solid var(--accent); border-radius: 0 10px 10px 0; padding: 12px 14px; margin: 18px 0; color: var(--ink); }
.resolve-check { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; margin: 18px 0; padding: 12px; border: 1px solid var(--control-border); border-radius: 12px; background: var(--surface-soft); line-height: 1.6; font-size: 14px; cursor: pointer; }
.resolve-check input { flex: 0 0 20px; width: 20px; height: 20px; min-height: 0; padding: 0; margin: 2px 0 0; }
.resolve-dialog .confirmation-actions { align-items: stretch; }
.resolve-dialog .confirmation-actions button { white-space: normal; line-height: 1.4; text-align: center; flex: 1 1 180px; min-height: 48px; }
.resolution-note { padding: 10px 12px; border-radius: 10px; background: var(--success-soft); color: var(--success); font-size: 13px; line-height: 1.6; }
.diagnostic-checks > div { padding: 14px 0; }
.calendar-grid { border-radius: 16px; overflow: hidden; }
.calendar-controls h2 { font-family: var(--font-body); font-variant-numeric: lining-nums tabular-nums; font-size: 25px; font-weight: 500; letter-spacing: -.4px; text-transform: none; }
.day.today { background: var(--sky); }
.day.selected { box-shadow: inset 0 0 0 2px var(--action); }
.day .day-count { background: var(--surface-hover); color: var(--ink); }
.day-add { color: var(--action); border-color: var(--control-border); background: var(--surface); }
footer { color: var(--muted); font-size: 11px; }
#toast { background: var(--ink); color: var(--surface); }

@media (min-width: 1181px) { .editor-grid { background: var(--surface); } }
@media (min-width: 761px) and (max-width: 1100px) { .brand-mark { width: 38px; height: 38px; flex-basis: 38px; } .brand { font-size: 21px; gap: 7px; } .brand small { font-size: 6px; letter-spacing: 1px; } }
@media (max-width: 760px) {
  :root { --button-padding: 7px 12px; }
  .sidebar { background: var(--surface); gap: 16px; padding-block: 16px 10px; }
  .brand { font-size: 25px; }
  .brand-mark { width: 42px; height: 42px; flex-basis: 42px; }
  .brand small { font-size: 7px; letter-spacing: 1.2px; }
  .sidebar nav { gap: 4px; }
  .nav { min-height: 58px; padding: 8px 2px; font-size: 11px; gap: 4px; border-radius: 10px; }
  .nav.active { box-shadow: inset 0 -2px var(--action); }
  main { padding: 22px 16px; }
  .topline { font-size: 9px; letter-spacing: 1px; }
  .timezone { font-size: 11px; }
  .page-header { margin-top: 24px; gap: 18px; }
  .page-header p { font-size: 13px; }
  .page-header > .primary { min-height: 48px; border-radius: 12px; }
  .environment { margin-top: 18px; font-size: 12px; }
  .stats { gap: 8px; margin-top: 18px; }
  .stats > div, .stats > button { padding: 14px; min-height: 120px; border-radius: 14px; }
  .stats small { font-size: 9px; letter-spacing: .7px; }
  .stats strong { font-size: 32px; margin: 5px 0; }
  .stats span { font-size: 11px; padding-top: 7px; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .filters button { font-size: 12px; }
  .search input { font-size: 16px; }
  .post-card { grid-template-columns: 1fr; padding: 18px; gap: 0; }
  .post-card > .post-icon { display: none; }
  .post-card h3 { font-size: 17px; margin: 10px 0; }
  .post-card .excerpt { display: none; }
  .post-card .meta { gap: 4px; flex-direction: column; font-size: 12px; }
  .post-card .card-actions { grid-column: 1; justify-content: space-between; margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
  .post-card .card-actions > .edit { flex: 1; }
  .post-card .post-selection { margin-bottom: 8px; }
  .post-menu-actions { top: auto; bottom: calc(100% + 6px); }
  .bulk-bar { gap: 8px; }
  .bulk-bar > span { flex-basis: 100%; }
  dialog:not(.confirmation) { border-radius: 0; }
  .editor-heading h2, .confirmation h2 { font-size: 27px; }
  .editor-actions > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor-actions > div button { font-size: 13px; min-width: 0; }
  .editor-actions #save-active { grid-column: auto; }
  .history-row .card-actions { margin-top: 8px; }
  .calendar-controls h2 { font-size: 24px; }
  .day-select { min-height: 100px; }
  .day .day-count { font-size: 10px; }
  .day-add { width: 44px; height: 44px; min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) { button, summary, .post-card, .day-add { transition: none; } }

@media (forced-colors: active) { .rule-days input[type="checkbox"] { appearance: auto; -webkit-appearance: checkbox; background: none; } }

:root[data-theme="dark"] .primary { color: #102338; }
:root[data-theme="dark"] .filters .selected { background: var(--sky); color: var(--ink); box-shadow: inset 0 0 0 1px var(--accent); }
:root[data-theme="dark"] .rule-days input:checked { background-color: #bddcf1; }
:root[data-theme="dark"] .ky-calendar-grid button.is-selected { color: #102338; }
