/* Shell rules copied verbatim from mockups/c/style.css (Fasa 1). Tab content rules (cells, KPIs, charts, schedule, queue, posts, settings, editor) land with fasa 2. */
:root {
  --font: "Inter", "DejaVu Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", "DejaVu Sans Mono", ui-monospace, monospace;
  --tg-bg: #ffffff; --tg-secondary-bg: #efeff4; --tg-section-bg: #ffffff; --tg-header-bg: #ffffff;
  --tg-text: #000000; --tg-hint: #6d6d72; --tg-link: #2481cc; --tg-accent: #2481cc;
  --tg-button: #2481cc; --tg-button-text: #ffffff; --tg-destructive: #d42a1f; --tg-separator: #d9d9de;
  --hover: #f2f2f6; --track: #e5e5ea; --series: #2481cc; --series-dim: #b6d3ec;
  --good: #1b7343; --info: #1d68c2; --ask: #6347b8; --warn: #8f5500; --bad: #bf2f1c; --mute: #6d6d72;
  --toast: rgb(30 30 32 / 0.94); --toast-ink: #ffffff; --toast-link: #6ab3f3;
  --skel: #ececf0; --skel-hi: #f6f6f8;
  color-scheme: light;
}
[data-theme="dark"] {
  --tg-bg: #17212b; --tg-secondary-bg: #0e1621; --tg-section-bg: #17212b; --tg-header-bg: #17212b;
  --tg-text: #f5f5f5; --tg-hint: #8b9aa8; --tg-link: #6ab3f3; --tg-accent: #6ab3f3;
  --tg-button: #5288c1; --tg-button-text: #ffffff; --tg-destructive: #ec3942; --tg-separator: #0b1219;
  --hover: #202b36; --track: #263646; --series: #6ab3f3; --series-dim: #2f4d6b;
  --good: #4fc58c; --info: #79b8ff; --ask: #b5a0f7; --warn: #f0aa48; --bad: #ff8070; --mute: #8b9aa8;
  --toast: rgb(240 244 248 / 0.96); --toast-ink: #15202b; --toast-link: #2481cc;
  --skel: #1f2d3b; --skel-hi: #2a3a4a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { min-height: 100dvh; font: 15px/1.4 var(--font); color: var(--tg-text); background: var(--tg-secondary-bg); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { list-style: none; padding: 0; }
code, .mono { font-family: var(--mono); font-size: 0.86em; }
:focus-visible { outline: 2px solid var(--tg-accent); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; }

.skip { position: fixed; left: 8px; top: -60px; z-index: 100; padding: 8px 12px; background: var(--tg-button); color: var(--tg-button-text); border-radius: 8px; }
.skip:focus { top: 8px; }

.tone-good { --tone: var(--good); }
.tone-info { --tone: var(--info); }
.tone-ask { --tone: var(--ask); }
.tone-warn { --tone: var(--warn); }
.tone-bad { --tone: var(--bad); }
.tone-muted { --tone: var(--mute); }
.badge { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px 1px 5px; border-radius: 99px; font-size: 12px; font-weight: 550; color: var(--tone); background: color-mix(in srgb, var(--tone) 13%, transparent); white-space: nowrap; }

/* Mini App frame: full screen on phones, a Telegram Desktop-sized window above 768px. */
.mini { position: relative; display: flex; flex-direction: column; min-height: 100dvh; background: var(--tg-secondary-bg); }
.mini-head { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 8px; background: var(--tg-header-bg); border-bottom: 1px solid var(--tg-separator); }
.head-btn { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: none; color: var(--tg-link); font-weight: 550; }
.head-btn:hover { background: var(--hover); }
.mini-title { flex: 1; min-width: 0; text-align: center; }
.mini-title h1 { font-size: 16px; font-weight: 650; }
.mini-title p { font-size: 12.5px; color: var(--tg-hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none; border: 0; border-radius: 50%; background: none; color: var(--tg-hint); }
.icon-btn:hover { background: var(--hover); color: var(--tg-text); }

.alert { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 10px 12px 0; padding: 10px 12px; border-radius: 12px; font-size: 14px; background: color-mix(in srgb, var(--tone) 12%, var(--tg-section-bg)); }
.alert > .i { color: var(--tone); }
.alert p { flex: 1 1 200px; }
.alert .chip { margin-left: auto; }

.views { flex: 1; padding: 10px 12px 150px; }
.view { display: grid; gap: 12px; align-content: start; }
.view:focus { outline: none; }

/* Sections, Telegram settings style */
.sec { background: var(--tg-section-bg); border-radius: 12px; overflow: hidden; }
.sec-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 10px 14px 4px; font-size: 12.5px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--tg-hint); }
.sec-h span { text-transform: none; letter-spacing: 0; font-weight: 450; }
.sec-b { padding: 6px 14px 12px; }
.sec-foot { padding: 0 14px 12px; font-size: 13px; color: var(--tg-hint); }

/* Chips (alert and sheet actions) */
.chip { display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 0 12px; border: 0; border-radius: 99px; background: color-mix(in srgb, var(--tg-button) 13%, transparent); color: var(--tg-link); font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.chip:hover:not(:disabled) { background: color-mix(in srgb, var(--tg-button) 22%, transparent); }
.chip.solid { background: var(--tg-button); color: var(--tg-button-text); }
.chip.danger { color: var(--tg-destructive); background: color-mix(in srgb, var(--tg-destructive) 11%, transparent); }
.row-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.empty { display: grid; justify-items: center; gap: 8px; padding: 28px 18px; text-align: center; color: var(--tg-hint); font-size: 14px; }
.empty .i { width: 28px; height: 28px; }

/* Bottom tab bar and MainButton */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; background: var(--tg-header-bg); border-top: 1px solid var(--tg-separator); }
.main-btn { margin: 8px 12px 4px; min-height: 46px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px; background: var(--tg-button); color: var(--tg-button-text); font-size: 15px; font-weight: 600; }
.main-btn:hover:not(:disabled) { filter: brightness(1.07); }
.main-btn.danger { background: var(--tg-destructive); }
.main-btn[aria-busy="true"] { cursor: progress; }
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tabbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 0 4px 4px; }
.tabbar [role="tab"] { position: relative; display: grid; justify-items: center; gap: 1px; padding: 6px 2px 4px; border: 0; border-radius: 8px; background: none; color: var(--tg-hint); font-size: 11px; font-weight: 550; }
.tabbar [role="tab"] .i { width: 22px; height: 22px; }
.tabbar [role="tab"][aria-selected="true"] { color: var(--tg-link); }
.tabbar .dot { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; display: grid; place-items: center; font-size: 10.5px; font-weight: 650; color: #fff; background: var(--tg-destructive); }

/* Bottom sheet: draft detail */
.scrim { position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / 0.4); }
.sheet { position: fixed; z-index: 55; left: 0; right: 0; bottom: 0; max-height: 88dvh; overflow-y: auto; display: grid; gap: 12px; padding: 8px 14px 16px; border-radius: 14px 14px 0 0; background: var(--tg-bg); box-shadow: 0 -6px 30px rgb(0 0 0 / 0.25); animation: up 0.2s ease-out; }
.sheet:focus { outline: none; }
.grab { justify-self: center; width: 36px; height: 5px; border-radius: 3px; background: var(--tg-separator); }
.sheet-h { display: flex; align-items: flex-start; gap: 8px; }
.sheet-h > div { flex: 1; min-width: 0; display: grid; gap: 3px; }
.sheet-h h2 { font-size: 17px; font-weight: 650; }
.sheet-h p { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: 13px; color: var(--tg-hint); }
.note { padding: 8px 10px; border-radius: 10px; font-size: 13.5px; background: color-mix(in srgb, var(--tone) 12%, transparent); }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }

/* Loading */
.skel { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--skel) 30%, var(--skel-hi) 50%, var(--skel) 70%); background-size: 300% 100%; animation: shimmer 1.3s linear infinite; }
.skel.tile { height: 72px; border-radius: 12px; }
.skel.block { height: 160px; border-radius: 12px; }
@keyframes shimmer { to { background-position: -150% 0; } }

/* Toasts sit above the MainButton, like Telegram's showPopup notices. */
.toasts { position: fixed; z-index: 80; left: 50%; bottom: 128px; transform: translateX(-50%); display: grid; gap: 6px; width: min(420px, calc(100vw - 24px)); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; background: var(--toast); color: var(--toast-ink); font-size: 14px; box-shadow: 0 6px 20px rgb(0 0 0 / 0.22); pointer-events: auto; transition: opacity 0.25s, transform 0.25s; animation: pop 0.18s ease-out; }
.toast span { flex: 1; }
.toast[class*="tone-"] { box-shadow: inset 3px 0 0 var(--tone), 0 6px 20px rgb(0 0 0 / 0.22); }
.toast.out { opacity: 0; transform: translateY(6px); }
.toast-action { padding: 4px 6px; border: 0; border-radius: 6px; background: none; color: var(--toast-link); font-weight: 650; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }

/* The mockup preview toggle would cover the tab bar; lift it above the dock. */
.kit { bottom: 128px; }

/* 768px and up: Telegram Desktop opens Mini Apps in a fixed window; the frame stays phone-wide and centred. */
@media (min-width: 768px) {
  body { display: grid; place-items: start center; padding: 24px 16px; background: color-mix(in srgb, var(--tg-secondary-bg) 70%, #000 6%); }
  .mini { width: 720px; min-height: calc(100dvh - 48px); border-radius: 14px; overflow: clip; box-shadow: 0 10px 40px rgb(0 0 0 / 0.18); }
  .dock { position: sticky; }
  .views { padding-bottom: 16px; }
  .sheet { left: calc(50% - 360px); right: calc(50% - 360px); }
  .toasts { bottom: 150px; }
  .kit { bottom: 12px; }
}
/* 1200px and up: the window is wider and the schedule shows its full 20 days beside the overview. */
@media (min-width: 1200px) {
  .mini { width: 1080px; }
  .sheet { left: auto; right: calc(50% - 540px); top: 24px; bottom: 24px; width: 440px; max-height: none; align-content: start; border-radius: 14px 0 0 14px; animation: side 0.2s ease-out; }
  .grab { display: none; }
  @keyframes side { from { transform: translateX(30px); opacity: 0; } }
}
