:root {
  --c: #0f5c63; --c-d: #0b464c; --c-l: #e4f0f1; --acc: #ffb84d;
  --bg: #f4f6f7; --panel: #fff; --tx: #1d2b2d; --mut: #6a7b7e; --bd: #dde5e6;
  --err: #b23b2e; --ok: #2e7d4f; --warn: #a86a00;
  --r: 8px; --sh: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(15,92,99,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; color: var(--tx); background: var(--bg); }
a { color: var(--c); }
button, input, select, textarea { font: inherit; color: inherit; }
input[type=text], input[type=url], input[type=password], input[type=search], select, textarea, .auth input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--bd); border-radius: 6px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--c-l); border-color: var(--c); }
textarea { min-height: 80px; resize: vertical; }
code { background: #eef3f3; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; word-break: break-all; }
small, .mut { color: var(--mut); }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--bd); border-radius: 6px;
  background: #fff; cursor: pointer; text-decoration: none; color: var(--tx); white-space: nowrap; }
.btn:hover { background: #f1f5f5; }
.btn.primary { background: var(--c); border-color: var(--c); color: #fff; }
.btn.primary:hover { background: var(--c-d); }
.btn.danger { color: var(--err); border-color: #ecc7c2; }
.btn.small { padding: 3px 8px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.iconbtn { border: 0; background: transparent; cursor: pointer; padding: 4px 6px; border-radius: 5px; color: var(--mut); }
.iconbtn:hover { background: var(--c-l); color: var(--c); }

/* ---------- přihlášení / sdílení ---------- */
.auth { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-box { width: 100%; max-width: 400px; background: #fff; border-radius: 12px; box-shadow: var(--sh); padding: 26px 24px; }
.auth-logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; margin-bottom: 14px; color: var(--c); }
.auth-logo img { width: 36px; height: 36px; border-radius: 8px; }
.auth h1 { font-size: 20px; margin: 0 0 10px; }
.auth label { display: block; margin: 12px 0; font-weight: 600; }
.auth label input, .auth label select { margin-top: 4px; font-weight: 400; }
.auth .btn { width: 100%; justify-content: center; padding: 10px; margin-top: 6px; }
.auth-err, .auth-ok, .auth-warn { padding: 10px 12px; border-radius: 6px; margin: 10px 0; }
.auth-err { background: #fdeeec; color: var(--err); }
.auth-ok { background: #eaf6ef; color: var(--ok); font-size: 18px; text-align: center; }
.auth-warn { background: #fff6e5; color: var(--warn); font-size: 13px; }
.row-actions { display: flex; gap: 8px; }
.row-actions .btn { flex: 1; }

/* ---------- rozvržení aplikace ---------- */
.app { display: grid; grid-template-rows: auto 1fr; grid-template-columns: 280px minmax(0, 1fr); height: 100vh; height: 100dvh; }
header.top { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: var(--c); color: #fff; }
header.top .logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: #fff; text-decoration: none; }
header.top .logo img { width: 26px; height: 26px; border-radius: 6px; }
header.top .search { flex: 1; max-width: 560px; position: relative; }
header.top .search input { background: rgba(255,255,255,.14); border: 1px solid transparent; color: #fff; padding-left: 32px; }
header.top .search input::placeholder { color: rgba(255,255,255,.7); }
header.top .search input:focus { background: #fff; color: var(--tx); outline: none; }
header.top .search::before { content: "⌕"; position: absolute; left: 10px; top: 50%; transform: translateY(-52%); font-size: 17px; opacity: .8; pointer-events: none; }
header.top nav { display: flex; gap: 2px; margin-left: auto; }
header.top nav button { background: transparent; border: 0; color: rgba(255,255,255,.85); padding: 6px 10px; border-radius: 6px; cursor: pointer; }
header.top nav button:hover { background: rgba(255,255,255,.12); color: #fff; }
header.top nav button.on { background: rgba(255,255,255,.2); color: #fff; }
.menu-btn { display: none; background: transparent; border: 0; color: #fff; font-size: 20px; cursor: pointer; }

aside.side { background: var(--panel); border-right: 1px solid var(--bd); overflow: auto; padding: 10px 6px 30px; }
.side h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--mut); margin: 16px 10px 6px; }
.ftree { list-style: none; margin: 0; padding: 0; }
.ftree ul { list-style: none; margin: 0; padding-left: 14px; }
.frow { display: flex; align-items: center; gap: 4px; padding: 4px 6px; border-radius: 6px; cursor: pointer; user-select: none; }
.frow:hover { background: #f0f5f5; }
.frow.on { background: var(--c-l); color: var(--c-d); font-weight: 600; }
.frow.drop { background: #fff1d6; outline: 2px dashed var(--acc); }
.frow .tg { width: 16px; text-align: center; color: var(--mut); font-size: 11px; flex: none; }
.frow .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frow .ct { color: var(--mut); font-size: 12px; font-weight: 400; }
.tags-side { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 10px; }

main.main { overflow: auto; padding: 16px 22px 60px; min-width: 0; }
.crumbs { font-size: 13px; color: var(--mut); margin-bottom: 4px; }
.crumbs a { cursor: pointer; text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.main h2 { margin: 0 0 12px; font-size: 20px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.toolbar .sp { flex: 1; }
.selbar { position: sticky; top: -16px; z-index: 5; background: #fff7e6; border: 1px solid #f2d9a5; border-radius: var(--r); padding: 8px 10px; }

.list { background: var(--panel); border: 1px solid var(--bd); border-radius: var(--r); box-shadow: var(--sh); overflow: hidden; }
.item { display: grid; grid-template-columns: 26px 22px 1fr auto auto; align-items: center; gap: 10px; padding: 7px 12px; border-top: 1px solid #edf2f2; position: relative; }
.item:first-child { border-top: 0; }
.item:hover { background: #f8fbfb; }
.item.sel { background: #fff8e8; }
.item.drag { opacity: .4; }
.item.drop-before::before, .item.drop-after::after { content: ""; position: absolute; left: 0; right: 0; height: 3px; background: var(--acc); }
.item.drop-before::before { top: -2px; }
.item.drop-after::after { bottom: -2px; }
.item.drop-into { background: #fff1d6; outline: 2px dashed var(--acc); outline-offset: -2px; }
.item input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }
.item .ic { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; color: var(--c); font-size: 16px; }
.item .ic img { width: 16px; height: 16px; }
.item .tx { min-width: 0; }
.item .tt { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--tx); text-decoration: none; font-weight: 500; }
.item .tt:hover { color: var(--c); text-decoration: underline; }
.item.folder .tt { cursor: pointer; font-weight: 600; }
.item .sub { display: block; font-size: 12px; color: var(--mut); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--mut); white-space: nowrap; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 20px; background: var(--c-l); color: var(--c-d); font-size: 11.5px; cursor: pointer; white-space: nowrap; }
.chip:hover { background: #cfe5e7; }
.chip.bad { background: #fde3df; color: var(--err); }
.chip.okc { background: #e3f3e9; color: var(--ok); }
.empty { padding: 40px 20px; text-align: center; color: var(--mut); }

.card { background: var(--panel); border: 1px solid var(--bd); border-radius: var(--r); box-shadow: var(--sh); padding: 14px 16px; margin-bottom: 14px; }
.card h3 { margin: 0 0 8px; font-size: 15px; }
.group-h { display: flex; gap: 10px; align-items: center; padding: 8px 12px; background: #f6f9f9; border-top: 1px solid var(--bd); font-size: 13px; }
.group-h:first-child { border-top: 0; }
.group-h .u { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hist-day { font-weight: 700; color: var(--c); margin: 18px 0 6px; font-size: 13px; }
.ev { display: grid; grid-template-columns: 52px 22px 1fr auto; gap: 8px; align-items: baseline; padding: 6px 12px; border-top: 1px solid #edf2f2; }
.ev:first-child { border-top: 0; }
.ev .tm { color: var(--mut); font-size: 12px; font-variant-numeric: tabular-nums; }
.ev .dv { color: var(--mut); font-size: 12px; white-space: nowrap; }
.ev .what { min-width: 0; overflow-wrap: anywhere; }
.op-create { color: var(--ok); } .op-delete { color: var(--err); } .op-update { color: var(--warn); } .op-move { color: var(--c); }

table.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-top: 1px solid #edf2f2; font-size: 13.5px; vertical-align: middle; }
.tbl th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--mut); border-top: 0; }

/* ---------- dialogy ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15,30,32,.38); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 14px; z-index: 50; overflow: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal header { padding: 14px 18px 4px; font-weight: 700; font-size: 16px; display: flex; align-items: center; }
.modal header .x { margin-left: auto; }
.modal .body { padding: 8px 18px; }
.modal footer { padding: 12px 18px 16px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal footer .left { margin-right: auto; }
.modal label { display: block; margin: 10px 0 4px; font-weight: 600; font-size: 13px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; font-size: 12.5px; color: var(--mut); margin-top: 12px; }
.kv b { color: var(--tx); font-weight: 500; }
.picker { max-height: 340px; overflow: auto; border: 1px solid var(--bd); border-radius: 6px; margin-top: 8px; }
.picker div { padding: 6px 10px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker div:hover { background: var(--c-l); }
.picker div.on { background: var(--c); color: #fff; }
.mini-hist { max-height: 180px; overflow: auto; font-size: 12.5px; margin-top: 6px; border-top: 1px solid var(--bd); }
.mini-hist div { padding: 4px 0; border-bottom: 1px dashed #edf2f2; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #1d2b2d; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--sh); z-index: 60; max-width: 90vw; }
.loading { padding: 60px; text-align: center; color: var(--mut); }

/* ---------- mobil ---------- */
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: block; }
  header.top { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  header.top .logo span { display: none; }
  header.top .search { order: 3; flex-basis: 100%; max-width: none; }
  header.top nav { overflow-x: auto; min-width: 0; flex: 1; margin-left: 0; scrollbar-width: none; }
  header.top nav button { padding: 6px 7px; font-size: 13px; }
  aside.side { position: fixed; top: 0; bottom: 0; left: 0; width: 84vw; max-width: 330px; z-index: 40; transform: translateX(-105%); transition: transform .2s; box-shadow: 0 0 30px rgba(0,0,0,.2); padding-top: 14px; }
  aside.side.open { transform: none; }
  main.main { padding: 12px 10px 60px; }
  .item { grid-template-columns: 24px 20px 1fr auto; gap: 8px; padding: 9px 10px; }
  .item .meta .date { display: none; }
  .item .acts { grid-column: 4; }
  .item .meta { grid-column: 3; grid-row: 2; flex-wrap: wrap; white-space: normal; }
  .item .meta:empty { display: none; }
  .ev { grid-template-columns: 44px 18px 1fr; }
  .ev .dv { grid-column: 3; }
}
