:root {
  --brand: #0a8fd6;
  --brand-dark: #076aa0;
  --brand-soft: #e6f3fb;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #17202a;
  --muted: #64707d;
  --line: #e2e6eb;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --st-draft: #9aa3ad;
  --st-scheduled: #0a8fd6;
  --st-waiting: #f59e0b;
  --st-partial: #8b5cf6;
  --st-published: #16a34a;
  --st-failed: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
  --nav-h: 60px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body { background: var(--bg); font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-dark); }
[hidden] { display: none !important; }

/* ---------- išdėstymas ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; text-decoration: none; color: var(--text); }
.brand img { width: 32px; height: 32px; border-radius: 50%; }
.topnav { display: flex; gap: 4px; margin-left: 16px; }
.topnav a, .bottomnav a {
  text-decoration: none; color: var(--muted); padding: 8px 12px; border-radius: 8px; font-weight: 500; position: relative;
}
.topnav a.active { color: var(--brand-dark); background: var(--brand-soft); }
.topbar .spacer { flex: 1; }
.badge {
  display: inline-block; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--st-waiting); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; margin-left: 4px;
}
main { max-width: 1200px; margin: 0 auto; padding: 16px; padding-bottom: calc(var(--nav-h) + 24px); }
.bottomnav { display: none; }

@media (max-width: 760px) {
  .topnav { display: none; }
  main { padding: 10px; padding-bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: #fff; border-top: 1px solid var(--line);
  }
  .bottomnav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-size: 11px; padding: 6px 2px; border-radius: 0;
  }
  .bottomnav a .ico { font-size: 20px; line-height: 1; }
  .bottomnav a.active { color: var(--brand-dark); }
  .bottomnav .badge { position: absolute; top: 4px; left: 55%; margin: 0; }
}

/* ---------- elementai ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 12px; }
h1 { font-size: 22px; margin: 4px 0 14px; }
h2 { font-size: 18px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text); white-space: nowrap;
}
.btn:hover { background: #f7f9fb; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--danger); border-color: #f3c4c4; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.big { min-height: 56px; font-size: 17px; width: 100%; border-radius: 14px; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.iconbtn { width: 40px; padding: 0; }

label.field { display: block; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; min-height: 42px;
}
textarea { resize: vertical; min-height: 140px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 8px 14px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--brand); color: #fff; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 14px; user-select: none;
}
.chip input { margin: 0; }
.chip.on { border-color: var(--brand); background: var(--brand-soft); }
.chip .mode { font-size: 11px; color: var(--muted); }

.pf {
  display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px;
  color: #fff; font-size: 10px; font-weight: 800; flex: none; letter-spacing: -0.2px;
}

.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.st-draft { background: var(--st-draft); }
.st-scheduled { background: var(--st-scheduled); }
.st-waiting { background: var(--st-waiting); }
.st-partial { background: var(--st-partial); }
.st-published { background: var(--st-published); }
.st-failed { background: var(--st-failed); }
.st-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }

.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.notice { padding: 12px 14px; border-radius: 10px; background: #fff7e6; border: 1px solid #fde3b0; }
.notice.info { background: var(--brand-soft); border-color: #bfe0f5; }
.notice.err { background: #fdecec; border-color: #f5c2c2; }

/* ---------- kalendorius ---------- */
.cal-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.cal-title { font-size: 20px; font-weight: 700; margin: 0 6px; min-width: 150px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--line); gap: 1px; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.cal-dow { background: #fafbfc; padding: 6px 8px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.cal-day { background: #fff; min-height: 118px; padding: 4px; position: relative; cursor: pointer; min-width: 0; overflow: hidden; }
.cal-day.other { background: #fafbfc; }
.cal-day.other .dnum { color: #b6bec7; }
.cal-day.today .dnum { background: var(--brand); color: #fff; }
.cal-day.selected { outline: 2px solid var(--brand); outline-offset: -2px; }
.cal-day.drop { background: var(--brand-soft); }
.dnum { display: inline-flex; width: 26px; height: 26px; align-items: center; justify-content: center; border-radius: 50%; font-size: 13px; font-weight: 600; }
.day-items { display: flex; flex-direction: column; gap: 3px; margin-top: 2px; }
.pchip {
  min-width: 0; display: flex; align-items: center; gap: 5px; padding: 3px 6px; border-radius: 7px; background: #f3f6f9;
  border-left: 3px solid var(--st-scheduled); font-size: 12px; cursor: grab; overflow: hidden; touch-action: manipulation;
}
.pchip .t { font-weight: 700; flex: none; }
.pchip .x { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pchip .pfs { display: flex; gap: 2px; flex: none; }
.pchip .pfs .pf { width: 14px; height: 14px; font-size: 7px; border-radius: 4px; }
.pchip.draft { border-left-color: var(--st-draft); opacity: 0.85; }
.pchip.waiting { border-left-color: var(--st-waiting); background: #fff7e6; }
.pchip.partial { border-left-color: var(--st-partial); }
.pchip.published { border-left-color: var(--st-published); background: #effaf2; }
.pchip.failed { border-left-color: var(--st-failed); background: #fdecec; }
.more { font-size: 12px; color: var(--muted); padding-left: 4px; }
.dragging { opacity: 0.4; }
.drag-ghost {
  position: fixed; z-index: 100; pointer-events: none; padding: 6px 10px; border-radius: 8px; background: var(--brand); color: #fff;
  font-size: 13px; font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.dots { display: none; gap: 3px; flex-wrap: wrap; margin-top: 4px; padding: 0 2px; }
.dots .status-dot { width: 7px; height: 7px; }

@media (max-width: 760px) {
  .cal-day { min-height: 56px; padding: 2px; }
  .cal-day .day-items { display: none; }
  .cal-day .dots { display: flex; }
  .dnum { width: 24px; height: 24px; font-size: 12px; }
  .cal-title { font-size: 17px; min-width: 0; }
}

/* savaitė */
.week { display: grid; grid-template-columns: 48px repeat(7, minmax(0, 1fr)); background: var(--line); gap: 1px; border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); max-height: calc(100vh - 190px); }
.week .wh { background: #fafbfc; padding: 6px 4px; font-size: 12px; font-weight: 700; text-align: center; position: sticky; top: 0; z-index: 2; }
.week .wh.today { color: var(--brand-dark); }
.week .hour { background: #fafbfc; font-size: 11px; color: var(--muted); text-align: right; padding: 2px 4px; }
.week .slot { min-width: 0; overflow: hidden; background: #fff; min-height: 44px; padding: 2px; display: flex; flex-direction: column; gap: 2px; }
.week .slot.drop { background: var(--brand-soft); }

.agenda .aday { margin-bottom: 14px; }
.agenda .aday h3 { font-size: 14px; color: var(--muted); margin: 0 0 6px; }
.aitem {
  display: flex; gap: 10px; align-items: center; background: #fff; border-radius: 10px; padding: 10px; box-shadow: var(--shadow); cursor: pointer;
  border-left: 4px solid var(--st-scheduled);
}
.aitem + .aitem { margin-top: 6px; }
.aitem .thumb { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: #e9edf1; flex: none; }
.aitem .info { flex: 1; min-width: 0; }
.aitem .txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aitem .meta { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 2px; flex-wrap: wrap; }
.aitem.draft { border-left-color: var(--st-draft); }
.aitem.waiting { border-left-color: var(--st-waiting); }
.aitem.partial { border-left-color: var(--st-partial); }
.aitem.published { border-left-color: var(--st-published); }
.aitem.failed { border-left-color: var(--st-failed); }

.legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom)); z-index: 25;
  width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; font-size: 30px; line-height: 1;
  box-shadow: 0 6px 18px rgba(10, 143, 214, 0.45); cursor: pointer; display: none;
}
@media (max-width: 760px) { .fab { display: block; } .hide-mobile { display: none !important; } }

/* ---------- modalas ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 30px 12px; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 720px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25); }
.modal header { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; border-radius: 16px 16px 0 0; z-index: 2; }
.modal header h2 { margin: 0; flex: 1; font-size: 18px; }
.modal .body { padding: 16px; }
.modal footer { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: #fff; border-radius: 0 0 16px 16px; }
@media (max-width: 760px) {
  .modal-back { padding: 0; }
  .modal { border-radius: 0; min-height: 100%; max-width: none; }
  .modal header, .modal footer { border-radius: 0; }
  .modal footer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}

.media-list { display: flex; gap: 8px; flex-wrap: wrap; }
.media-item { position: relative; width: 96px; height: 120px; border-radius: 10px; overflow: hidden; background: #e9edf1; }
.media-item img, .media-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-item .rm { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.6); color: #fff; cursor: pointer; }
.media-item .kind { position: absolute; left: 4px; bottom: 4px; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 10px; padding: 1px 5px; border-radius: 4px; }
.media-item .prog { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(0, 0, 0, 0.15); }
.media-item .prog i { display: block; height: 100%; background: var(--brand); width: 0; transition: width 0.2s; }
.upload-btn { width: 96px; height: 120px; border: 2px dashed #c6ced6; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); cursor: pointer; font-size: 13px; text-align: center; background: #fafbfc; }
.upload-btn b { font-size: 26px; color: var(--brand); }

.targets { display: flex; flex-direction: column; gap: 6px; }
.target-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; flex-wrap: wrap; }
.target-row .nm { flex: 1; min-width: 140px; font-weight: 600; }

details.box { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
details.box summary { cursor: pointer; font-weight: 600; }

/* ---------- priminimas ---------- */
.remind { max-width: 560px; margin: 0 auto; }
.remind .acc { display: flex; align-items: center; gap: 10px; }
.remind .acc .pf { width: 34px; height: 34px; font-size: 13px; border-radius: 9px; }
.remind .preview { width: 100%; max-height: 36vh; border-radius: 12px; background: #000; display: block; object-fit: contain; }
.remind .ptext { white-space: pre-wrap; background: #f7f9fb; border: 1px solid var(--line); border-radius: 10px; padding: 12px; max-height: 220px; overflow: auto; font-size: 14px; }
.steps { margin: 0; padding-left: 20px; }
.steps li + li { margin-top: 4px; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); z-index: 200;
  background: #1f2937; color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3); max-width: 90vw;
}
.toast.err { background: var(--danger); }

/* ---------- biblioteka ---------- */
.lib-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border-bottom: 1px solid var(--line); }
.lib-item:last-child { border-bottom: 0; }
.lib-item .thumb { width: 64px; height: 80px; border-radius: 8px; object-fit: cover; background: #e9edf1; flex: none; }
.lib-item .info { flex: 1; min-width: 0; }
.lib-item .txt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib-item .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

.preview-list { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.preview-list div { padding: 6px 10px; border-bottom: 1px solid var(--line); font-size: 13px; display: flex; gap: 8px; }
.preview-list div:last-child { border-bottom: 0; }
.preview-list b { flex: none; width: 128px; }
.preview-list span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.bar { height: 10px; border-radius: 5px; background: #e9edf1; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); }

.login { max-width: 380px; margin: 12vh auto 0; }
.login .logo { display: block; width: 84px; height: 84px; margin: 0 auto 10px; border-radius: 50%; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; background: #f3f5f8; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); }
table.log { width: 100%; border-collapse: collapse; font-size: 12px; }
table.log td { border-bottom: 1px solid var(--line); padding: 4px 6px; vertical-align: top; }
