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

:root {
  --p1: #667eea;
  --p2: #764ba2;
  --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-h: linear-gradient(135deg, #5a6fd6 0%, #6a3f96 100%);
  --green: #16a34a;
  --red: #dc2626;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --card-border: #e8e3f5;
  --shadow-main: 0 25px 70px rgba(0,0,0,.35);
  --shadow-panel: 0 4px 20px rgba(102,126,234,.10);
  --radius: 16px;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--gradient);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 40px 16px 0;
}

/* Bílá hlavní karta */
.container {
  background: rgba(255,255,255,.97);
  border-radius: 20px;
  box-shadow: var(--shadow-main);
  max-width: 900px;
  width: 100%;
  padding: 40px 40px 32px;
  position: relative;
}

/* Přepínač jazyků */
.lang-switcher {
  position: absolute;
  top: 14px;
  right: 16px;
  display: flex;
  gap: 4px;
  z-index: 10;
}

.lang-btn {
  background: none;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
  padding: 3px 4px;
  transition: transform .15s, border-color .15s;
  opacity: .55;
}

.lang-btn:hover {
  transform: scale(1.18);
  opacity: 1;
}

.lang-btn.active {
  border-color: var(--p1);
  opacity: 1;
}

@media (max-width: 520px) {
  .lang-switcher { top: 10px; right: 10px; gap: 2px; }
  .lang-btn { font-size: 1.15rem; padding: 2px 3px; }
}

/* Header */
header {
  text-align: center;
  margin-bottom: 36px;
}

.header-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 8px;
}

.logo {
  height: 56px;
  width: auto;
  border-radius: 8px;
  object-fit: contain;
  flex-shrink: 0;
}

header h1 {
  font-size: 2rem;
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--gray-500);
  font-size: .92rem;
  line-height: 1.5;
}

/* Screens */
.screen { display: none; }
.screen.active { display: block; }

/* ── Volba připojení ── */
.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

@media (max-width: 520px) {
  .cards { grid-template-columns: 1fr; }
  .container { padding: 28px 20px 24px; }
}

.card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 36px rgba(102,126,234,.22);
  border-color: var(--p2);
}

.card-icon {
  font-size: 2.6rem;
  margin-bottom: 14px;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.card h2 { font-size: 1.1rem; font-weight: 700; color: var(--gray-900); margin-bottom: 8px; }
.card p  { color: var(--gray-500); font-size: .88rem; line-height: 1.5; }

/* ── Panel (kód / chyba) ── */
.panel {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
  padding: 36px 32px;
  text-align: center;
}

.panel h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 22px;
}

.back-btn {
  display: inline-block;
  margin-bottom: 22px;
  background: none;
  border: none;
  color: var(--p1);
  cursor: pointer;
  font-size: .88rem;
  padding: 0;
}
.back-btn:hover { text-decoration: underline; }

/* Kód */
.code-display {
  font-size: clamp(1.2rem, 5.5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: clamp(2px, 1.2vw, 14px);
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  background-color: #f5f0ff;
  border-radius: 12px;
  padding: clamp(10px, 3vw, 18px) clamp(12px, 4vw, 32px);
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 16px;
  user-select: all;
  box-shadow: inset 0 0 0 1px #e0d8f7;
  white-space: nowrap;
}

/* Akce u kódu (kopírovat, odkaz, QR) */
.code-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 auto 20px;
  max-width: 520px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fff;
  border: 1.5px solid var(--card-border);
  border-radius: 10px;
  font-size: .87rem;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  transition: transform .15s, background .15s, border-color .15s, color .15s, box-shadow .15s;
  line-height: 1.1;
  white-space: nowrap;
  min-width: 0;
}
.action-btn .action-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  pointer-events: none;
}
.action-btn .action-label {
  pointer-events: none;
  overflow: hidden;
  text-overflow: ellipsis;
}
.action-btn:hover {
  background: #f5f0ff;
  border-color: var(--p1);
  color: var(--p1);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102,126,234,.18);
}
.action-btn:active { transform: translateY(0); box-shadow: none; }
.action-btn:focus-visible {
  outline: none;
  border-color: var(--p1);
  box-shadow: 0 0 0 3px rgba(102,126,234,.25);
}

.action-btn:disabled,
.action-btn:disabled:hover {
  opacity: .5;
  cursor: not-allowed;
  background: #fff;
  border-color: var(--card-border);
  color: var(--gray-500);
  transform: none;
  box-shadow: none;
}

.action-btn.copied,
.action-btn.copied:hover {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
  transform: none;
  box-shadow: none;
}

.action-btn.active,
.action-btn.active:hover {
  background: var(--gradient);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 14px rgba(118,75,162,.3);
  transform: none;
}

@media (max-width: 480px) {
  .code-actions { grid-template-columns: 1fr 1fr; }
  .action-btn { padding: 9px 12px; font-size: .82rem; gap: 6px; }
  .action-btn .action-icon { width: 15px; height: 15px; }
  .code-input-group { flex-direction: column; align-items: center; }
  .code-input-group input { width: 100%; max-width: 280px; font-size: 1.5rem; letter-spacing: 4px; }
  .code-input-group button { width: 100%; max-width: 280px; }
}
@media (max-width: 340px) {
  .code-actions { grid-template-columns: 1fr; }
}

/* QR kontejner */
#qr-wrap {
  margin: 0 auto 18px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  display: inline-block;
  max-width: 100%;
}
#qr-wrap svg, #qr-wrap canvas, #qr-wrap img {
  display: block;
  max-width: 100%;
  height: auto;
  width: 220px;
}
.qr-hint { font-size: .8rem; color: var(--gray-500); margin-top: 8px; }

.status-text { color: var(--gray-500); font-size: .92rem; margin-bottom: 14px; }

/* Spinner */
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--p1);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 14px auto 0;
}
.spinner.hidden { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Zadání kódu */
.code-input-group {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 12px;
}

.code-input-group input {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 5px;
  width: 240px;
  text-align: center;
  border: 2px solid var(--gray-200);
  border-radius: 10px;
  padding: 12px 14px;
  outline: none;
  color: var(--gray-900);
  transition: border-color .15s;
}
.code-input-group input:focus { border-color: var(--p1); }

.code-input-group button {
  padding: 12px 22px;
  background: var(--gradient);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
}
.code-input-group button:hover { opacity: .9; }

.error-text { color: var(--red); font-size: .88rem; min-height: 1.2em; }

/* ── Připojeno ── */
.conn-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.conn-badge {
  color: var(--green);
  font-weight: 700;
  font-size: .92rem;
}

.disconnect-btn {
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 5px 14px;
  font-size: .82rem;
  cursor: pointer;
  color: var(--gray-500);
  transition: border-color .15s, color .15s, opacity .15s;
}
.disconnect-btn:hover:not(:disabled) { border-color: var(--red); color: var(--red); }
.disconnect-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  border-color: var(--gray-200);
  color: var(--gray-300);
}

.conn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
@media (max-width: 640px) { .conn-grid { grid-template-columns: 1fr; } }

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--card-border);
  border-radius: 12px;
  padding: 26px 14px;
  margin-bottom: 14px;
  transition: border-color .15s, background .15s;
}
.drop-zone.over { border-color: var(--p1); background: #f3f0ff; }

.drop-icon { font-size: 1.9rem; margin-bottom: 8px; }
.drop-zone p { color: var(--gray-500); margin-bottom: 6px; font-size: .88rem; }
.drop-sub { font-size: .82rem !important; }
.drop-limit { font-size: .76rem !important; color: var(--gray-300) !important; margin-top: 6px; }

.file-btns {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 8px 0;
  flex-wrap: wrap;
}

.file-label {
  display: inline-block;
  padding: 7px 14px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: .83rem;
  cursor: pointer;
  transition: background .15s;
}
.file-label:hover { background: var(--gray-200); }

/* Fronta souborů */
.file-list { margin-bottom: 12px; text-align: left; }

.file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  background: #f5f0ff;
  border-radius: 8px;
  margin-bottom: 5px;
  font-size: .83rem;
  border: 1px solid #e8e3f5;
}
.file-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--gray-700); }
.file-item-size { color: var(--gray-500); white-space: nowrap; }

/* Tlačítko odeslat */
.primary-btn {
  padding: 11px 30px;
  background: var(--gradient);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(118,75,162,.3);
  transition: opacity .15s, transform .15s;
}
.primary-btn:hover { opacity: .9; transform: translateY(-1px); }
.primary-btn:disabled { background: var(--gray-200); box-shadow: none; cursor: not-allowed; }

/* Progress (inline) */
.progress-bar-wrap {
  background: var(--gray-200);
  border-radius: 99px;
  height: 9px;
  overflow: hidden;
  margin: 10px 0 7px;
}
.progress-bar {
  height: 100%;
  background: var(--gradient);
  width: 0%;
  transition: width .3s;
  border-radius: 99px;
}
.progress-filename {
  font-size: .84rem;
  color: var(--gray-700);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 2px;
}
.progress-pct {
  font-size: 1.4rem;
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 2px;
}
.progress-detail { color: var(--gray-500); font-size: .8rem; }

/* Přijaté soubory */
.recv-list {
  text-align: left;
  margin-top: 6px;
  max-height: 300px;
  overflow-y: auto;
}
.no-files-text {
  color: var(--gray-300);
  font-size: .88rem;
  text-align: center;
  padding: 28px 0;
}
.recv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  background: #f5f0ff;
  border: 1px solid #e8e3f5;
  border-radius: 8px;
  margin-bottom: 6px;
}
.recv-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .84rem; color: var(--gray-700); }
.recv-item-size { color: var(--gray-500); font-size: .8rem; white-space: nowrap; }
.recv-item-dl {
  padding: 5px 12px;
  background: var(--gradient);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity .15s;
}
.recv-item-dl:hover { opacity: .88; }

.recv-item-corrupted {
  background: #fff5f5;
  border-color: #fecaca;
}
.recv-item-warn {
  color: var(--red);
  font-size: .75rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: help;
}

/* Chyba */
.error-icon {
  font-size: 2.2rem;
  width: 60px; height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  background: #fee2e2;
  color: var(--red);
}

/* ── Intrusion warning toast ── */
.intrusion-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(calc(-100% - 30px));
  opacity: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #fff7ed;
  border: 1.5px solid #f97316;
  border-radius: 12px;
  padding: 13px 16px;
  box-shadow: 0 8px 28px rgba(0,0,0,.22);
  max-width: min(460px, calc(100vw - 32px));
  width: max-content;
  transition: transform .35s cubic-bezier(.22,1,.36,1), opacity .3s ease;
  pointer-events: none;
}
.intrusion-toast.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.intrusion-toast-icon {
  font-size: 1.15rem;
  flex-shrink: 0;
  color: #ea580c;
  line-height: 1.4;
}
.intrusion-toast-text {
  font-size: .88rem;
  font-weight: 600;
  color: #9a3412;
  flex: 1;
  line-height: 1.45;
}
.intrusion-toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #c2410c;
  font-size: .9rem;
  padding: 0 0 0 6px;
  flex-shrink: 0;
  line-height: 1.4;
  opacity: .65;
  transition: opacity .15s;
}
.intrusion-toast-close:hover { opacity: 1; }

/* ── Info toast ── */
.info-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(calc(-100% - 30px));
  opacity: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #f0f9ff;
  border: 1.5px solid #0284c7;
  border-radius: 12px;
  padding: 13px 16px;
  box-shadow: 0 8px 28px rgba(0,0,0,.15);
  max-width: min(480px, calc(100vw - 32px));
  width: max-content;
  transition: transform .35s cubic-bezier(.22,1,.36,1), opacity .3s ease;
  pointer-events: none;
}
.info-toast.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.info-toast-icon {
  font-size: 1.15rem;
  flex-shrink: 0;
  color: #0284c7;
  line-height: 1.4;
}
.info-toast-text {
  font-size: .88rem;
  font-weight: 600;
  color: #0c4a6e;
  flex: 1;
  line-height: 1.45;
}
.info-toast-text a {
  color: #0284c7;
  text-decoration: underline;
  font-weight: 700;
}
.info-toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #0284c7;
  font-size: .9rem;
  padding: 0 0 0 6px;
  flex-shrink: 0;
  line-height: 1.4;
  opacity: .65;
  transition: opacity .15s;
}
.info-toast-close:hover { opacity: 1; }

/* ── Divider ── */
.divider {
  border: none;
  border-top: 1px solid #eee;
  margin: 32px 0 24px;
}

/* ── Coffee sekce (jako na hlavním webu) ── */
.coffee-section {
  display: flex;
  align-items: center;
  gap: 20px;
}
@media (max-width: 480px) {
  .coffee-section { flex-direction: column; text-align: center; }
}
.coffee-icon {
  font-size: 2.6rem;
  flex-shrink: 0;
  animation: steam 2.5s ease-in-out infinite;
  display: inline-block;
}
@keyframes steam {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}
.coffee-text { flex: 1; }
.coffee-text h2 { font-size: .95rem; font-weight: 700; color: #444; margin-bottom: 4px; }
.coffee-text p  { font-size: .83rem; color: #888; line-height: 1.5; }
.btn-coffee {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #FFDD00 0%, #FFC200 100%);
  color: #333;
  font-size: .92rem;
  font-weight: 700;
  padding: 11px 22px;
  border-radius: 50px;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(255,193,0,.45);
  transition: transform .2s, box-shadow .2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-coffee:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 22px rgba(255,193,0,.6);
}
