/*
 * Max: rozvržení. Postranní panel a pracovní plocha jako v Claude; na mobilu je panel výsuvný
 * (nabídka vlevo nahoře nebo tah prstem) a celá plocha patří obsahu.
 */

/* ---------- Rám aplikace ---------- */
/* Aplikace žije v rámu přes viditelnou část okna; stránka sama se neposouvá. Na telefonu s otevřenou
   klávesnicí dostane rám výšku toho, co je vidět (core/viewport.js nastaví --app-height), takže pole pro
   psaní sedí hned nad klávesnicí a horní lišta zůstává nahoře. Rám je vztažná plocha i pro okna, nabídky
   a hlášky uvnitř (position: fixed se počítá od něj): drží se tak viditelné části obrazovky taky. */
#app {
  position: fixed;
  inset: 0;
  height: var(--app-height, auto);
  /* Telefon naležato: obsah nezajíždí pod výřez displeje. */
  padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left);
  contain: layout;
  overflow: hidden;
  background: var(--canvas);
}
/* Klávesnice odjíždí: rám se vrací plynule s ní (délka je i v core/viewport.js). */
html[data-keyboard="closing"] #app { transition: height 240ms var(--ease-out); }

/* ---------- Úvodní obrazovka před načtením aplikace ---------- */
.splash {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--s-4);
  height: 100%;
  color: var(--ink-3);
  font-size: var(--fs-sm);
}
.splash__logo {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 22.5%;
  background: var(--brand-blue) url("../brand/favicon.svg") center / cover no-repeat;
  animation: splash-pulse 1.4s var(--ease-inout) infinite alternate;
}
@keyframes splash-pulse { from { opacity: 0.55; } to { opacity: 1; } }
.splash__text { max-width: 32rem; padding: 0 var(--s-4); line-height: 1.5; text-align: center; }

/* ---------- Kostra ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100%;
  transition: grid-template-columns var(--t-slow) var(--ease-out);
}
.shell[data-sidebar="closed"] { grid-template-columns: 0 minmax(0, 1fr); }

/* ---------- Postranní panel ---------- */
.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--canvas);
  border-right: 1px solid var(--line);
}
.shell[data-sidebar="closed"] .sidebar { border-right: 0; visibility: hidden; }

.sidebar__inner {
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  height: 100%;
  padding: var(--s-3);
  gap: var(--s-1);
}
.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-1) var(--s-1) var(--s-3) var(--s-2);
}
.sidebar__brand { display: inline-flex; align-items: center; text-decoration: none; }

.navitem {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  min-height: 2.5rem;
  padding: 0 var(--s-3);
  border-radius: var(--r-md);
  color: var(--ink-2);
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast);
}
.navitem:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.navitem[aria-current="page"] { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }
.navitem--new { color: var(--primary-ink); font-weight: 600; }
.navitem__badge { margin-left: auto; }

.sidebar__section {
  padding: var(--s-4) var(--s-3) var(--s-1);
  color: var(--ink-3);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.sidebar__list {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0 calc(-1 * var(--s-1));
  padding: 0 var(--s-1);
  overflow-y: auto;
}
.sidebar__empty { padding: var(--s-2) var(--s-3); color: var(--ink-3); font-size: var(--fs-sm); }

/* Řádek konverzace v historii. */
.convitem {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: var(--r-md);
}
.convitem:hover, .convitem:focus-within { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.convitem[data-current="true"] { background: var(--primary-soft); }
.convitem__link {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 2.25rem;
  padding: 0 var(--s-1) 0 var(--s-3);
  color: var(--ink-2);
  font-size: var(--fs-sm);
  text-decoration: none;
}
.convitem[data-current="true"] .convitem__link { color: var(--primary-ink); font-weight: 550; }
.convitem__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convitem__more { opacity: 0; }
.convitem:hover .convitem__more,
.convitem:focus-within .convitem__more,
.convitem__more[aria-expanded="true"] { opacity: 1; }
@media (hover: none) { .convitem__more { opacity: 1; } }

/* Tečka: v konverzaci právě běží odpověď. */
.dot-live {
  width: 0.5rem;
  height: 0.5rem;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent);
  animation: live 1.6s var(--ease-inout) infinite;
}
@keyframes live {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); }
  100% { box-shadow: 0 0 0 0.4rem transparent; }
}

.sidebar__foot { padding-top: var(--s-2); border-top: 1px solid var(--line); position: relative; }
.userbtn {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  min-height: 3rem;
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-md);
  text-align: left;
}
.userbtn:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.userbtn__name { font-size: var(--fs-sm); font-weight: 600; }
.userbtn__sub { font-size: var(--fs-xs); color: var(--ink-3); }

.avatar {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  flex: none;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-ink);
  font-size: var(--fs-sm);
  font-weight: 650;
  text-transform: uppercase;
}

/* ---------- Pracovní plocha ---------- */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  background: var(--paper);
}
.topbar {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  flex: none;
  height: var(--topbar-h);
  padding: 0 var(--s-2);
}
.topbar__title {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 var(--s-2);
  font-size: var(--fs-md);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.main__body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

/* Zpráva od správce čeká na přečtení: nenápadná lišta pod horní lištou, text až v okně. */
.noticebar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex: none;
  padding: var(--s-2) var(--s-4);
  background: var(--primary-soft);
  color: var(--primary-ink);
  font-size: var(--fs-sm);
}
.noticebar > .icon { flex: none; }
.noticebar__text { flex: 1 1 auto; min-width: 0; font-weight: 600; }
.noticebar .btn { flex: none; }

/* Tlačítka, která dávají smysl jen na jedné šířce. */
.only-mobile { display: none; }

.scrim { display: none; }

@media (max-width: 56rem) {
  .only-mobile { display: inline-grid; }
  .only-desktop { display: none !important; }

  .shell, .shell[data-sidebar="closed"] { grid-template-columns: minmax(0, 1fr); }

  /* Panel se vysouvá přes obsah. */
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 70;
    width: min(20rem, 86vw);
    transform: translateX(-102%);
    transition: transform var(--t-slow) var(--ease-out);
    box-shadow: var(--shadow-3);
    visibility: visible !important;
    border-right: 1px solid var(--line) !important;
  }
  /* Vodorovný tah po panelu patří jeho zavírání (app/drawerSwipe.js), svislý rolování historie. */
  .sidebar { touch-action: pan-y; }
  .sidebar__inner { width: 100%; padding-bottom: calc(var(--s-3) + env(safe-area-inset-bottom)); }
  .shell[data-drawer="open"] .sidebar { transform: none; }
  /* Ztmavení plochy vedle panelu. Je tu pořád (jen průhledné a bez dotyku), ať může sílit a slábnout
     plynule s panelem. */
  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 65;
    background: var(--overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-slow) var(--ease-out);
    touch-action: none;
  }
  .shell[data-drawer="open"] .scrim { opacity: 1; pointer-events: auto; }
  /* Panel jde s prstem (app/drawerSwipe.js): polohu i ztmavení nastavuje tah přímo na prvcích, přechody
     na tu chvíli mlčí. Po puštění prstu dojede panel přechodem z místa, kde zrovna je. */
  .shell[data-drag] .sidebar { transition: none; will-change: transform; }
  .shell[data-drag] .scrim { transition: none; will-change: opacity; }

  /* Na telefonu je celá plocha pro obsah: navigace je v horní liště (nabídka vlevo, zkratka vpravo)
     a ve výsuvném panelu. Spodní nabídka není. */
  .topbar { border-bottom: 1px solid var(--line); }
  .topbar .iconbtn { -webkit-tap-highlight-color: transparent; }
  /* Stránky, které se posouvají samy, končí nad spodním okrajem telefonu (domovský proužek). */
  .page { padding-bottom: calc(var(--s-7) + env(safe-area-inset-bottom)); }
}

/* ---------- Přihlášení ---------- */
/* Karta je uprostřed; když se nevejde (malý telefon s klávesnicí), stránka se posouvá uvnitř rámu. */
.login {
  display: flex;
  height: 100%;
  padding: var(--s-4);
  overflow-y: auto;
  background: var(--canvas);
}
.login__card {
  margin: auto;
  width: min(25rem, 100%);
  padding: var(--s-6) var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--paper);
  box-shadow: var(--shadow-2);
}
.login__logo { display: flex; justify-content: center; margin-bottom: var(--s-5); }
.login__title { font-size: var(--fs-xl); font-weight: 680; text-align: center; letter-spacing: -0.01em; }
.login__lead {
  margin: var(--s-2) 0 var(--s-5);
  color: var(--ink-2);
  text-align: center;
  line-height: 1.5;
}
.login__form { display: flex; flex-direction: column; gap: var(--s-4); }
.login__alt { margin-top: var(--s-4); text-align: center; font-size: var(--fs-sm); }
.login__hint { margin-top: var(--s-3); color: var(--ink-3); font-size: var(--fs-sm); text-align: center; line-height: 1.5; }

/* Souhlas s propojením Clauda (stejná karta jako přihlášení). */
.connect__list { display: flex; flex-direction: column; gap: var(--s-3); margin: var(--s-4) 0; padding: 0; list-style: none; }
.connect__list li { display: flex; align-items: flex-start; gap: var(--s-3); line-height: 1.45; }
.connect__list .icon { flex: none; margin-top: 0.2em; color: var(--primary-ink); }
.connect__note { margin: 0 0 var(--s-4); }
.connect__actions { display: flex; flex-direction: column; gap: var(--s-2); }

/* Nastavení → Propojení: seznam propojených aplikací. */
.connections { display: flex; flex-direction: column; gap: var(--s-3); }
.connections__list { display: flex; flex-direction: column; gap: var(--s-2); margin: 0; padding: 0; list-style: none; }
.connections__item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
}
.connections__text { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.connections__item .btn { flex: none; }
/* Adresa účtu, do kterého odkaz přihlašuje: musí být vidět celá i na úzkém displeji. */
.login__account {
  margin: calc(-1 * var(--s-3)) 0 var(--s-5);
  font-weight: 650;
  text-align: center;
  overflow-wrap: anywhere;
}
.login__note { color: var(--ink-2); font-size: var(--fs-sm); line-height: 1.5; text-align: center; }
.login__foot { margin-top: var(--s-5); color: var(--ink-3); font-size: var(--fs-xs); text-align: center; line-height: 1.5; }
.linkbtn { color: var(--primary-ink); text-decoration: underline; text-underline-offset: 0.15em; font-weight: 550; }
.linkbtn:hover { text-decoration-thickness: 2px; }

.devbox {
  margin-top: var(--s-4);
  padding: var(--s-3);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  color: var(--ink-2);
  font-size: var(--fs-sm);
  text-align: center;
}
.devbox strong { font-family: var(--font-mono); font-size: var(--fs-lg); letter-spacing: 0.15em; }

/* ---------- Obecná stránka (Apky, Znalosti, zatím prázdné) ---------- */
.page {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--s-5) var(--s-4) var(--s-7);
}
.page__inner { max-width: var(--content-w); margin: 0 auto; }
.page__title { font-size: var(--fs-2xl); font-weight: 680; letter-spacing: -0.015em; }
.page__lead { margin-top: var(--s-2); color: var(--ink-2); line-height: 1.55; }

.empty {
  display: grid;
  justify-items: center;
  gap: var(--s-3);
  margin-top: var(--s-7);
  padding: var(--s-6) var(--s-4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-xl);
  color: var(--ink-2);
  text-align: center;
}
.empty .icon { width: 2.5rem; height: 2.5rem; color: var(--ink-3); }

/* ---------- Nastavení ---------- */
.settings { display: flex; flex-direction: column; gap: var(--s-5); min-width: 0; }
/* Záložky Nastavení: každá je široká podle svého názvu a když se vedle sebe nevejdou (větší písmo), zalomí se.
   Na úzký displej se skládají po dvou. */
.settings__tabs { display: flex; flex-wrap: wrap; }
.settings__tabs .segmented__item { flex: 1 1 auto; }
@media (max-width: 40rem) {
  .settings__tabs { display: grid; grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.settings__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
}
.settings__label { font-weight: 600; }
.settings__hint { color: var(--ink-3); font-size: var(--fs-sm); line-height: 1.45; max-width: 26rem; }
.settings__group { display: flex; flex-direction: column; gap: var(--s-2); }

.fontpick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); width: 100%; }
.fontpick__item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: var(--s-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  text-align: left;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.fontpick__item:hover { background: var(--sunken); }
.fontpick__item[aria-checked="true"] { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); background: var(--primary-soft); }
.fontpick__sample { font-size: 1.5rem; line-height: 1.2; }
.fontpick__name { font-size: var(--fs-sm); font-weight: 600; }
.fontpick__desc { font-size: var(--fs-xs); color: var(--ink-3); }
@media (max-width: 30rem) { .fontpick { grid-template-columns: 1fr; } }
