/* Rozložení: mobil = nadpis + přepínač + seznam + spodní lišta; počítač = složky vlevo, seznam vpravo */
:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --fg: #1d201e;
  --muted: #6c716d;
  --line: #e3e4df;
  --accent: #2f5a4c;
  --accent-soft: #e4ece8;
  --on-accent: #ffffff;
  --star: #c48a1e;
  --danger: #b2402f;
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 6px 24px rgba(20, 30, 25, .06);
  --font-display: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --tabbar-h: 64px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141715; --surface: #1c201e; --fg: #ebede9; --muted: #9aa09b; --line: #2b302d;
    --accent: #8cc2ad; --accent-soft: #23302b; --on-accent: #0f1a15; --star: #e3b049; --danger: #e07b69;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font-family: var(--font-body); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
code { font-size: .9em; background: var(--accent-soft); padding: 1px 5px; border-radius: 5px; }

/* Úvodní obrazovky */
.screen {
  min-height: 100%; display: grid; place-items: center;
  padding: calc(24px + var(--safe-t)) max(16px, var(--safe-r)) calc(24px + var(--safe-b)) max(16px, var(--safe-l));
}
.center-card { max-width: 380px; display: flex; flex-direction: column; gap: 16px; text-align: center; align-items: center; }
.center-card p { margin: 0; color: var(--muted); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.brand { font-family: var(--font-display); font-weight: 650; font-size: 22px; letter-spacing: -.01em; }
.brand.big { font-size: 34px; letter-spacing: -.02em; }

.app { display: flex; min-height: 100%; }

/* Postranní panel (počítač) */
.sidebar { display: none; }
.folders { display: flex; flex-direction: column; gap: 2px; }
.folder {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; border: 0; border-radius: 10px; background: none; text-align: left;
  color: var(--muted); font-weight: 500;
}
.folder:hover { background: var(--accent-soft); color: var(--fg); }
.folder[aria-current="true"] { background: var(--accent-soft); color: var(--fg); font-weight: 600; }
.folder svg { width: 20px; height: 20px; flex: none; }
.folder .count { margin-left: auto; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; }
.account { margin-top: auto; padding: 0 12px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
.account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Hlavní sloupec */
.main {
  flex: 1; min-width: 0;
  padding-left: max(16px, var(--safe-l));
  padding-right: max(16px, var(--safe-r));
  padding-top: calc(20px + var(--safe-t));
  padding-bottom: calc(var(--tabbar-h) + 96px + var(--safe-b));
}
.inner { max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }

.top { display: flex; align-items: center; gap: 12px; }
.top h1 { margin: 0; font-family: var(--font-display); font-weight: 650; font-size: 30px; letter-spacing: -.02em; text-wrap: balance; }
.top .meta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; margin-left: auto; }

.segment {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.segment button {
  border: 0; background: none; padding: 9px 10px; border-radius: 9px;
  font-weight: 500; color: var(--muted);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.segment button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.segment .n { font-size: 12px; opacity: .8; font-variant-numeric: tabular-nums; }

.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search {
  width: 100%; padding: 11px 14px 11px 40px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); outline: none; font-size: 16px;
}
.search:focus { border-color: var(--accent); }

.list { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: start;
  cursor: pointer; transition: border-color .15s;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.card-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.card h3 { margin: 0; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.card .sub { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.card .note { opacity: .85; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stars { color: var(--star); letter-spacing: 1px; font-size: 13px; }
.stars .off { color: var(--line); }
.card-actions { display: flex; gap: 6px; align-items: center; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; color: var(--muted); text-decoration: none; flex: none;
}
.icon-btn:hover { color: var(--fg); }
.icon-btn svg { width: 16px; height: 16px; }
.visit-btn {
  border: 1px solid var(--accent); color: var(--accent); background: none;
  border-radius: 10px; padding: 6px 10px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.visit-btn:hover { background: var(--accent); color: var(--on-accent); }

.empty { text-align: center; color: var(--muted); padding: 48px 16px; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.empty strong { color: var(--fg); font-weight: 600; font-size: 16px; }

.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font-size: 13px; font-weight: 600; text-align: left; }

/* Tlačítko Přidat */
.fab {
  position: fixed; z-index: 20;
  right: calc(20px + var(--safe-r));
  bottom: calc(var(--tabbar-h) + 18px + var(--safe-b));
  height: 54px; padding: 0 20px 0 16px; border: 0; border-radius: 16px;
  background: var(--accent); color: var(--on-accent); font-weight: 600;
  display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow);
}
.fab svg { width: 20px; height: 20px; }

/* Spodní lišta (mobil) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-left: max(8px, var(--safe-l));
  padding-right: max(8px, var(--safe-r));
  padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(4, 1fr);
}
.tabbar button {
  height: var(--tabbar-h); border: 0; background: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11.5px; font-weight: 500;
}
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button[aria-current="true"] { color: var(--accent); font-weight: 600; }

/* Formulář */
.overlay {
  position: fixed; inset: 0; z-index: 40; background: rgba(10, 15, 12, .35);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 560px; max-height: calc(100% - var(--safe-t) - 16px); overflow-y: auto;
  background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 20px max(18px, var(--safe-r)) calc(20px + var(--safe-b)) max(18px, var(--safe-l));
  display: flex; flex-direction: column; gap: 16px;
  animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet, .spinner { animation: none; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-family: var(--font-display); font-weight: 650; font-size: 22px; letter-spacing: -.01em; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .lbl { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.field input, .field textarea, .field select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); outline: none;
  font-size: 16px; /* 16px zabrání automatickému zoomu na iPhonu */
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.field textarea { min-height: 84px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row2 > * { min-width: 0; }
.rating { display: flex; gap: 4px; }
.rating button { border: 0; background: none; font-size: 26px; line-height: 1; padding: 2px; color: var(--line); }
.rating button.on { color: var(--star); }
.sheet-actions { display: flex; gap: 10px; align-items: center; padding-top: 4px; }
.btn { border-radius: 12px; padding: 12px 18px; font-weight: 600; border: 1px solid var(--line); background: var(--surface); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.sheet-actions .btn.primary { margin-left: auto; }
.btn.wide { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; }
.btn.wide svg { width: 18px; height: 18px; }
.btn.danger { color: var(--danger); border-color: transparent; background: none; padding-left: 4px; }
.btn.danger.confirm { background: var(--danger); color: var(--surface); padding-left: 18px; }
.error { color: var(--danger); font-size: 13px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(var(--tabbar-h) + 86px + var(--safe-b));
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow); max-width: calc(100% - 32px);
}

/* Počítač */
@media (min-width: 900px) {
  :root { --tabbar-h: 0px; }
  .tabbar, .mobile-only { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 28px; width: 260px; flex: none;
    padding: 28px 16px 28px max(20px, var(--safe-l));
    border-right: 1px solid var(--line); background: var(--surface);
    position: sticky; top: 0; height: 100vh;
  }
  .brand:not(.big) { padding: 0 12px; }
  .main { padding-top: 40px; padding-bottom: 120px; padding-left: 40px; }
  .top h1 { font-size: 36px; }
  .fab { bottom: calc(28px + var(--safe-b)); right: calc(32px + var(--safe-r)); }
  .toast { bottom: 100px; }
  .overlay { align-items: center; }
  .sheet { border-radius: 20px; max-height: 88%; }
}
