/* Jeden tmavý motiv. Aplikace se používá skoro výhradně na telefonu a
   přepínání světlé varianty by bylo víc kódu než užitku. */

:root {
  --bg: #1a1a18;
  --surface: #232320;
  --surface-2: #2c2c28;
  --line: #3a3a35;
  --text: #eceae4;
  --muted: #9b978c;
  --accent: #d87a55;
  --danger: #d96a6a;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ------------------------------------------------------------ přihlášení */

.login {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px;
}

.login-box {
  width: 100%;
  max-width: 320px;
}

.login-box > div {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.link {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  text-decoration: underline;
  padding: 6px;
}

.recovery {
  display: block;
  padding: 14px;
  border: 1px dashed var(--accent);
  border-radius: 10px;
  background: var(--surface);
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 17px;
  letter-spacing: .06em;
  text-align: center;
  /* Aby šel kód označit prstem a zkopírovat do Keeperu. */
  user-select: all;
  -webkit-user-select: all;
}

.login h1 {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 600;
  text-align: center;
}

.login input {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px; /* pod 16px iOS při fokusu zoomuje stránku */
}

.login .primary {
  padding: 13px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #1a1a18;
  font-size: 16px;
  font-weight: 600;
}

/* ------------------------------------------------------- potvrzení operace */

.confirm {
  align-self: stretch;
  padding: 12px 14px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.confirm .why {
  font-size: 13px;
  color: var(--accent);
}

.confirm .what {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.confirm .push {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border-radius: 9px;
  background: var(--bg);
  font-size: 12px;
}

.confirm .push-varovani {
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(217, 106, 106, .16);
  color: var(--danger);
  font-weight: 600;
}

.confirm .push-commity,
.confirm .push-soubory {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--muted);
}

.confirm .buttons {
  display: flex;
  gap: 8px;
}

.confirm button {
  flex: 1;
  padding: 11px;
  border: 0;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 600;
}

.confirm .approve { background: var(--accent); color: #1a1a18; }
.confirm .reject { background: var(--surface-2); color: var(--text); }

.confirm.resolved .buttons { display: none; }
.confirm.resolved { border-style: dashed; opacity: .65; }

.error {
  margin: 0;
  min-height: 20px;
  color: var(--danger);
  font-size: 14px;
  text-align: center;
}

/* ------------------------------------------------------------------- app */

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

.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(var(--safe-top) + 8px) 8px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  color: var(--muted);
  text-align: center;
}

.icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 19px;
}

.icon:active { background: var(--surface-2); }

/* --------------------------------------------------------------- zásuvka */

.drawer {
  position: fixed;
  z-index: 20;
  top: 0;
  bottom: 0;
  left: 0;
  width: 82%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  padding: calc(var(--safe-top) + 8px) 0 calc(var(--safe-bottom) + 8px);
  background: var(--surface);
  border-right: 1px solid var(--line);
  transform: translateX(-102%);
  transition: transform .22s ease;
}

.drawer.open { transform: none; }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 8px 16px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

#conversation-list {
  flex: 1;
  margin: 0;
  padding: 0 8px;
  overflow-y: auto;
  list-style: none;
}

#conversation-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 11px 10px;
  border-radius: 10px;
  font-size: 15px;
}

#conversation-list li.active { background: var(--surface-2); }

#conversation-list .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#conversation-list .delete {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
  padding: 0 4px;
}

.logout {
  margin: 8px 16px 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
}

.version {
  padding: 8px 16px 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.scrim {
  position: fixed;
  z-index: 10;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
}

.scrim.open { opacity: 1; pointer-events: auto; }

/* ---------------------------------------------------------------- zprávy */

/* ------------------------------------------------------------- status bar */

.statusbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-height: 20px;
}

.status-limits.warning { color: #d9b45a; }
.status-limits.critical { color: var(--danger); }

/* ------------------------------------------------------- ukazatel prace */

.busy {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  padding: 2px 0;
}

.spinner {
  width: 11px;
  height: 11px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex: 0 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}

.messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg { max-width: 100%; }

.msg.user {
  align-self: flex-end;
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  background: var(--surface-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg.assistant {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-wrap: anywhere;
}

/* Zalamování patří textovému bloku, ne celé bublině — jinak by se prázdné
   řádky dělaly i kolem značek nástrojů. */
.msg.assistant .answer {
  white-space: pre-wrap;
}

.msg.assistant code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-2);
  font-size: 14px;
}

.msg.assistant pre {
  margin: 8px 0;
  padding: 12px;
  border-radius: 10px;
  background: var(--surface);
  overflow-x: auto;
  font-size: 13px;
  white-space: pre;
}

/* Značka volaného nástroje. Stojí v proudu odpovědi tam, kde nástroj opravdu
   běžel, ne v pruhu nahoře — jinak by s každým dalším nástrojem odsouvala
   rozepsaný text mimo obrazovku. */
.chip {
  align-self: flex-start;
  max-width: 100%;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip.error { border-color: var(--danger); color: var(--danger); }

.meta {
  font-size: 11px;
  color: var(--muted);
}

/* --------------------------------------------------------------- vstupní */

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 10px calc(var(--safe-bottom) + 8px);
  border-top: 1px solid var(--line);
  background: var(--bg);
}

#input {
  flex: 1;
  max-height: 40vh;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  resize: none;
}

.send {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #1a1a18;
  font-size: 18px;
  font-weight: 700;
}

.send:disabled { opacity: .35; }
.send.stop { background: var(--danger); color: #fff; }
