:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0eee9;
  --border: #e3e0d9;
  --text: #1d1c1a;
  --muted: #6d6a63;
  --accent: #2f5d50;
  --accent-hover: #244a40;
  --accent-soft: #e3ede9;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --danger-soft: #fbeae9;
  --shadow: 0 1px 2px rgba(20, 18, 14, .05), 0 4px 16px rgba(20, 18, 14, .06);
  --radius: 14px;
  --radius-sm: 9px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --surface: #1d1c1a;
    --surface-2: #262522;
    --border: #34322e;
    --text: #efede8;
    --muted: #a19d94;
    --accent: #7fb8a5;
    --accent-hover: #96c8b7;
    --accent-soft: #23332e;
    --accent-text: #0f1a17;
    --danger: #f08b84;
    --danger-soft: #3a2220;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Tlačítka a pole ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 550; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 14px; }
.btn.lg { height: 48px; padding: 0 22px; font-size: 16px; }
.btn.icon { width: 40px; padding: 0; }
.btn.sm.icon { width: 34px; }

.input, textarea.input {
  width: 100%; height: 44px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 84px; padding: 10px 14px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 550; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.error-text { color: var(--danger); font-size: 14px; min-height: 20px; margin: 6px 0 0; }

/* ---------- Úvod / přihlášení ---------- */
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; padding: 36px 32px 30px; text-align: center; }
.auth-card h1 { font-size: 24px; margin: 14px 0 6px; letter-spacing: -.01em; }
.auth-card p.lead { margin: 0 0 24px; color: var(--muted); }
.auth-card form { text-align: left; }
.logo-mark {
  width: 56px; height: 56px; margin: 0 auto; border-radius: 16px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.logo-mark svg.i { width: 28px; height: 28px; }
.code-input {
  height: 60px; text-align: center; font-size: 26px; font-weight: 650; letter-spacing: .18em;
  text-transform: uppercase; font-variant-numeric: tabular-nums;
}
.code-input::placeholder { letter-spacing: .18em; color: var(--border); }
.auth-card .btn.lg { width: 100%; margin-top: 4px; }
.foot-note { margin-top: 22px; font-size: 13px; color: var(--muted); }

/* ---------- Horní lišta ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; text-decoration: none; color: var(--text); }
.brand .logo-mark { width: 34px; height: 34px; border-radius: 10px; margin: 0; }
.brand .logo-mark svg.i { width: 18px; height: 18px; }
.topbar .spacer { flex: 1; }

/* ---------- Galerie zákazníka ---------- */
.wrap { max-width: 1240px; margin: 0 auto; padding: 28px 24px 120px; }
.hero { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px 24px; margin-bottom: 22px; }
.hero .titles { flex: 1 1 320px; min-width: 0; }
.hero h1 { font-size: 30px; line-height: 1.15; letter-spacing: -.02em; margin: 0 0 6px; overflow-wrap: anywhere; }
.hero .stats { color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.note { white-space: pre-wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; margin: 0 0 22px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 6px 0 16px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; flex: 1; min-width: 0; font-size: 15px; }
.crumbs button { border: 0; background: none; padding: 6px 8px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 550; }
.crumbs button:hover { background: var(--surface-2); color: var(--text); }
.crumbs button.cur { color: var(--text); cursor: default; background: none; }
.crumbs .sep { color: var(--border); }

.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 22px; }
.folder {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.folder:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.folder .fi { width: 42px; height: 42px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.folder .fi svg.i { width: 22px; height: 22px; }
.folder b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.folder small { color: var(--muted); }
.folder > div { min-width: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.tile { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--surface); border: 1px solid var(--border); }
.tile .thumb {
  position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center;
  cursor: zoom-in; overflow: hidden;
}
.tile .thumb img, .tile .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s ease; }
.tile:hover .thumb img, .tile:hover .thumb video { transform: scale(1.03); }
.tile .thumb .ext {
  display: grid; place-items: center; gap: 6px; color: var(--muted); font-weight: 700; font-size: 13px; letter-spacing: .05em;
}
.tile .thumb .ext svg.i { width: 34px; height: 34px; stroke-width: 1.4; }
.tile .play {
  position: absolute; inset: 0; margin: auto; width: 52px; height: 52px; border-radius: 50%;
  background: rgba(0, 0, 0, .55); color: #fff; display: grid; place-items: center; pointer-events: none;
}
.tile .play svg { width: 22px; height: 22px; fill: #fff; stroke: none; margin-left: 3px; }
.tile .meta { display: flex; align-items: center; gap: 8px; padding: 9px 8px 9px 12px; }
.tile .meta > div { flex: 1; min-width: 0; }
.tile .name { font-size: 13.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .size { font-size: 12px; color: var(--muted); }
.check {
  position: absolute; top: 10px; left: 10px; z-index: 2; width: 28px; height: 28px; border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, .95); background: rgba(0, 0, 0, .25); cursor: pointer;
  display: grid; place-items: center; opacity: 0; transition: opacity .15s, background .15s;
}
.check svg.i { width: 16px; height: 16px; stroke: #fff; stroke-width: 3; opacity: 0; }
.tile:hover .check, .selecting .check, .check:focus-visible { opacity: 1; }
.tile.sel { outline: 3px solid var(--accent); outline-offset: -1px; }
.tile.sel .check { opacity: 1; background: var(--accent); border-color: var(--accent); }
.tile.sel .check svg.i { opacity: 1; }
@media (hover: none) { .check { opacity: 1; } }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .logo-mark { margin-bottom: 14px; }

.selbar {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 18px;
  background: var(--text); color: var(--bg); border-radius: 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
  max-width: calc(100vw - 32px);
}
.selbar .btn.ghost { color: var(--bg); }
.selbar .btn.ghost:hover { background: rgba(127, 127, 127, .25); }
.selbar span { white-space: nowrap; font-weight: 550; }

/* ---------- Prohlížeč (lightbox) ---------- */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(8, 8, 8, .96); display: flex; flex-direction: column; color: #fff; }
.lb-top { display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
.lb-top .lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.lb-top .lb-name small { color: #aaa; font-weight: 400; margin-left: 8px; }
.lightbox .btn { background: rgba(255, 255, 255, .1); border-color: transparent; color: #fff; }
.lightbox .btn:hover { background: rgba(255, 255, 255, .2); }
.lightbox .btn.primary { background: #fff; color: #111; }
.lb-stage { flex: 1; position: relative; display: grid; place-items: center; min-height: 0; padding: 0 64px 20px; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: 100%; object-fit: contain; display: block; border-radius: 4px; }
.lb-stage .lb-other { text-align: center; color: #ccc; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; }
.lb-nav.prev { left: 10px; } .lb-nav.next { right: 10px; }
.lb-loading { position: absolute; width: 36px; height: 36px; border: 3px solid rgba(255,255,255,.2); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(20px); z-index: 200;
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 11px; font-weight: 550;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Mobil ---------- */
@media (max-width: 700px) {
  .topbar { padding: 10px 16px; }
  .wrap { padding: 20px 16px 120px; }
  .hero h1 { font-size: 24px; }
  .hero .actions { width: 100%; }
  .hero .actions .btn { width: 100%; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .folders { grid-template-columns: 1fr; }
  .lb-stage { padding: 0 0 12px; }
  .lb-nav { display: none; }
  .auth-card { padding: 28px 20px 24px; }
  .selbar { left: 16px; right: 16px; transform: none; padding-left: 14px; }
  .selbar .hide-sm, .detail-head .hide-sm, .files-head .hide-sm { display: none; }
}
