:root {
  --bg: #fafaf9; --surface: #ffffff; --ink: #1c1917; --muted: #78716c; --faint: #e7e5e4; --hover: #f5f5f4;
  --accent: #1c1917; --danger: #dc2626;
  --x: #1c1917; --facebook: #1877f2; --instagram: #e1306c; --youtube: #ff0033; --tiktok: #00c2c7; --website: #7c3aed;
  --r: 14px; --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111110; --surface: #1a1a19; --ink: #f5f5f4; --muted: #a8a29e; --faint: #292524; --hover: #232321; --accent: #f5f5f4; --x: #f5f5f4; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 8px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; }
.mark { width: 44px; height: 44px; border-radius: 13px; background: conic-gradient(from 200deg, var(--instagram), var(--youtube), var(--tiktok), var(--facebook), var(--website), var(--instagram)); margin-bottom: 18px; }
.primary { background: var(--accent); color: var(--bg); padding: 13px 22px; border-radius: 999px; font-weight: 600; min-width: 220px; display: inline-flex; gap: 8px; justify-content: center; align-items: center; }
.primary svg { width: 18px; height: 18px; }
.link { color: var(--muted); font-size: 13px; }
.register { display: flex; gap: 8px; width: min(320px, 100%); }
.register input { flex: 1; min-width: 0; font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--faint); border-radius: 999px; padding: 10px 14px; }
.register button { padding: 10px 16px; border-radius: 999px; background: var(--faint); font-weight: 600; }
.msg { min-height: 1.4em; margin: 0; font-size: 13px; color: var(--muted); text-align: center; }
.msg.err { color: var(--danger); }

/* ---------- header ---------- */
.bar { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 2px; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); }
.icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; color: var(--muted); }
.icon:hover { background: var(--hover); color: var(--ink); }
.range { font-weight: 650; font-size: 17px; letter-spacing: -0.01em; padding: 4px 6px; border-radius: 8px; white-space: nowrap; }
.range.away::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); margin-left: 6px; vertical-align: middle; }
.spacer { flex: 1; }
.seg { display: flex; background: var(--faint); border-radius: 10px; padding: 2px; margin-right: 4px; }
.seg button { padding: 5px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }

/* ---------- day strip (mobile) ---------- */
.strip { display: none; }
.day-cell { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0 8px; border-radius: 12px; color: var(--muted); }
.day-cell .wd { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.day-cell .n { font-size: 17px; font-weight: 650; color: var(--ink); width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; }
.day-cell.today .n { color: var(--danger); }
.day-cell.sel .n { background: var(--ink); color: var(--bg); }
.dots { display: flex; gap: 2px; height: 5px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--net); }

/* ---------- calendar ---------- */
.cal { padding: 4px 12px calc(32px + var(--safe-b)); }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.col-head { display: flex; align-items: baseline; gap: 6px; padding: 6px 4px 10px; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; cursor: pointer; }
.col-head .n { font-size: 20px; color: var(--ink); text-transform: none; letter-spacing: -0.02em; }
.col-head.today .n { color: var(--danger); }
.col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.none { color: var(--faint); text-align: center; padding: 18px 0; font-size: 18px; }

.post { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: start; width: 100%; text-align: left; background: var(--surface); border-radius: var(--r); padding: 10px 10px 10px 12px; box-shadow: 0 0 0 1px var(--faint); transition: transform .12s ease, box-shadow .12s ease; }
.post:hover { box-shadow: 0 0 0 1px var(--faint), 0 6px 18px -8px rgb(0 0 0 / .18); }
.post:active { transform: scale(.985); }
.post .meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.post .meta svg { width: 14px; height: 14px; color: var(--net); stroke-width: 0; fill: currentColor; flex: none; }
.post .meta b { font-weight: 600; color: var(--ink); }
.post .txt { margin-top: 3px; font-size: 14px; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.post .th { width: 44px; height: 44px; border-radius: 9px; object-fit: cover; background: var(--faint); display: block; }
.post.published { opacity: .55; }
.post.draft { box-shadow: 0 0 0 1px var(--faint) inset; background: transparent; border: 1.5px dashed var(--faint); }
.post.failed { box-shadow: 0 0 0 1.5px var(--danger); }
.flag { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); margin-left: auto; }

/* day timeline */
.day { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; }
.hour { display: grid; grid-template-columns: 46px 1fr; gap: 8px; padding: 4px 0; }
.hour > time { font-size: 12px; color: var(--muted); padding-top: 12px; font-variant-numeric: tabular-nums; }
.hour .col { gap: 8px; }
.day .post .th { width: 56px; height: 56px; }
.day .post .txt { -webkit-line-clamp: 3; }
.now { display: grid; grid-template-columns: 46px 1fr; gap: 8px; align-items: center; margin: 2px 0; }
.now::before { content: ""; } .now i { height: 2px; background: var(--danger); border-radius: 2px; position: relative; }
.now i::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 64px 0; }

/* ---------- preview sheet ---------- */
.sheet { border: 0; padding: 0; margin: auto; width: min(520px, 100%); max-height: min(86dvh, 820px); border-radius: 22px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 60px -20px rgb(0 0 0 / .45); overflow: auto; }
.sheet::backdrop { background: rgb(0 0 0 / .4); backdrop-filter: blur(2px); }
.sheet[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.pv { padding: 18px 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.pv-top { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.pv-top > svg { width: 18px; height: 18px; stroke-width: 0; fill: var(--net); }
.pv-top .spacer { flex: 1; }
.pv h3 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.pv-media { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -20px; padding: 0 20px; scrollbar-width: none; }
.pv-media > * { flex: 0 0 auto; max-height: 340px; max-width: 86%; border-radius: 14px; scroll-snap-align: start; background: var(--faint); }
.pv-media > :only-child { max-width: 100%; }
.pv-part { white-space: pre-wrap; word-break: break-word; font-size: 15px; }
.pv-part + .pv-part { border-top: 1px solid var(--faint); padding-top: 12px; }
.pv-err { color: var(--danger); font-size: 13px; background: color-mix(in srgb, var(--danger) 8%, transparent); padding: 10px 12px; border-radius: 10px; margin: 0; }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .seg { display: none; }
  .strip { display: grid; grid-template-columns: repeat(7, 1fr); padding: 0 8px 6px; position: sticky; top: calc(56px + env(safe-area-inset-top, 0px)); z-index: 2; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--faint); }
  .cal { padding-top: 8px; }
  .sheet { margin: auto 0 0; width: 100%; max-width: 100%; max-height: 92dvh; border-radius: 22px 22px 0 0; padding-bottom: var(--safe-b); }
  .sheet[open] { animation: up .22s cubic-bezier(.2, .8, .2, 1); }
  .sheet::before { content: ""; display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--faint); margin: 8px auto 0; }
  @keyframes up { from { transform: translateY(40%); opacity: .4; } }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
