/* ============================================================
   Bythorn Mail — globální styly
   Reset, typografie, základní prvky (tlačítka, vstupy, pomocné).
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: var(--lh);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; line-height: var(--lh-tight); letter-spacing: -0.01em; }
h1 { font-size: var(--fs-2xl); font-weight: 700; }
h2 { font-size: var(--fs-xl);  font-weight: 700; }
h3 { font-size: var(--fs-lg);  font-weight: 650; }
p  { margin: 0; }

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
  margin: 0;
}
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; opacity: 0.55; }

svg { display: block; }
.icon { width: 18px; height: 18px; flex: none; }
.icon-sm { width: 15px; height: 15px; flex: none; }

[hidden] { display: none !important; }

/* Skryté pro zrak, dostupné čtečkám */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Fokus jen z klávesnice */
:focus { outline: none; }
:focus-visible { box-shadow: var(--focus-ring); border-radius: var(--r-sm); }

::selection { background: var(--accent-soft); color: var(--accent-ink); }

/* --- Popisky s prostrkáním -------------------------------- */
.label {
  font-size: var(--fs-xs);
  font-weight: 650;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--ink-3);
}

/* --- Tlačítka -------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border-radius: var(--r-md);
  font-weight: 600; font-size: var(--fs-md);
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease),
              box-shadow var(--t) var(--ease), transform var(--t-fast) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { box-shadow: var(--focus-ring); }

.btn-primary {
  background: var(--accent); color: var(--on-accent);
  box-shadow: var(--shadow-accent);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-active); }

.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--ink); }

.btn-soft { background: var(--bg-sunken); color: var(--ink); }
.btn-soft:hover { background: var(--bg-active); }

.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }

.btn-sm { height: 32px; padding: 0 12px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-block { width: 100%; }

/* Ikonové tlačítko */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--r-sm);
  color: var(--ink-3);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--ink); }
.icon-btn.is-on { color: var(--accent); }

/* --- Formulářové prvky ----------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: var(--fs-sm); color: var(--ink-3); }

.input, .select, .textarea {
  width: 100%;
  background: var(--bg-sunken);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 0 14px;
  height: 42px;
  color: var(--ink);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.input:hover, .select:hover, .textarea:hover { background: var(--bg-active); }
.input:focus, .select:focus, .textarea:focus {
  background: var(--bg-elev);
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  border-radius: var(--r-md);
}
.input.is-invalid { border-color: var(--danger); }
.textarea { height: auto; padding: 12px 14px; resize: vertical; line-height: var(--lh-loose); }
.select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238B8172' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* --- Chip / badge ---------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 9px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 650; letter-spacing: 0.02em;
  background: var(--bg-sunken); color: var(--ink-2);
}
.chip-accent { background: var(--accent-soft); color: var(--accent-ink); }
.chip-green  { background: var(--green-soft);  color: var(--green-ink); }
.chip-olive  { background: var(--olive-soft);  color: var(--olive-ink); }
.chip-clay   { background: var(--clay-soft);   color: var(--clay-ink); }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot-green { background: var(--green); }
.dot-olive { background: var(--olive); }
.dot-clay  { background: var(--clay); }
.dot-accent{ background: var(--accent); }

/* --- Avatar ---------------------------------------------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  font-size: 13px; font-weight: 700; letter-spacing: 0.02em;
  background: var(--av-1); color: var(--av-1-ink);
  user-select: none;
}
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 44px; height: 44px; font-size: 15px; }
.avatar.av-1 { background: var(--av-1); color: var(--av-1-ink); }
.avatar.av-2 { background: var(--av-2); color: var(--av-2-ink); }
.avatar.av-3 { background: var(--av-3); color: var(--av-3-ink); }
.avatar.av-4 { background: var(--av-4); color: var(--av-4-ink); }
.avatar.av-5 { background: var(--av-5); color: var(--av-5-ink); }
.avatar.av-6 { background: var(--av-6); color: var(--av-6-ink); }
.avatar.av-bot { background: var(--accent-soft); color: var(--accent-ink); }

/* --- Klávesová zkratka ----------------------------------- */
kbd {
  display: inline-block; min-width: 20px; padding: 1px 6px;
  border-radius: 5px;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  box-shadow: 0 1px 0 var(--line-strong);
  font-family: var(--font); font-size: 11px; font-weight: 600; color: var(--ink-2);
  text-align: center; line-height: 1.4;
}

/* --- Toast ----------------------------------------------- */
.toast-region {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 100;
  pointer-events: none;
}
.toast {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 11px 16px 11px 14px;
  background: var(--ink); color: var(--bg);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm); font-weight: 500;
  pointer-events: auto;
  animation: toast-in var(--t-slow) var(--ease-out);
}
.toast .icon { color: var(--accent); width: 16px; height: 16px; }
.toast.is-leaving { animation: toast-out var(--t) var(--ease) forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* --- Pomocné --------------------------------------------- */
.muted { color: var(--ink-3); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1 1 auto; min-width: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
