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

body {
  min-height: 100vh;
  background: #0f1a14;
  font-family: 'Lora', serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 16px;
}

/* ── Header ── */
.badge {
  display: inline-block;
  background: linear-gradient(135deg, #1a3a2a, #0f2018);
  border: 1px solid #2d5c3e;
  border-radius: 6px;
  padding: 5px 16px;
  color: #7fffc4;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 14px;
}

h1 {
  color: #f0ede6;
  font-size: clamp(26px, 5vw, 44px);
  font-weight: 400;
  font-style: italic;
  margin-bottom: 8px;
  text-align: center;
}

.subtitle {
  color: #6b9e82;
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  margin-bottom: 36px;
  text-align: center;
}

/* ── Card ── */
.card {
  width: 100%;
  max-width: 760px;
  margin-bottom: 20px;
}

.input-card {
  background: #fffef8;
  border-radius: 6px;
  border: 1px solid #d4c9a0;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  overflow: visible;
}

.card-header {
  background: #1a6b3a;
  padding: 9px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header span {
  color: #d4fce8;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.btn-example {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #d4fce8;
  border-radius: 4px;
  padding: 3px 12px;
  font-size: 11px;
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  transition: background 0.2s;
}

.btn-example:hover {
  background: rgba(255, 255, 255, 0.25);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-login {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #d4fce8;
  border-radius: 4px;
  padding: 3px 12px;
  font-size: 11px;
  font-family: 'DM Mono', monospace;
  text-decoration: none;
  transition: background 0.2s;
}

.btn-login:hover {
  background: rgba(255, 255, 255, 0.25);
}

.btn-logout {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #d4fce8;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 10px;
  font-family: 'DM Mono', monospace;
  cursor: pointer;
  margin-left: 4px;
}

.user-info {
  display: flex;
  align-items: center;
}

.provider-row {
  padding: 10px 18px;
  border-bottom: 1px solid #e8e0c8;
  background: #f7faf7;
}

.provider-label {
  display: block;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  color: #1a6b3a;
  text-transform: uppercase;
  margin-bottom: 7px;
}

.provider-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.provider-btn {
  background: #fff;
  border: 1px solid #d4c9a0;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-family: 'DM Mono', monospace;
  cursor: pointer;
  color: #2a1f0a;
  transition: all 0.15s;
}

.provider-btn:hover {
  border-color: #1a6b3a;
  color: #1a6b3a;
}

.provider-btn.active {
  background: #1a6b3a;
  border-color: #1a6b3a;
  color: #fff;
}

.model-apikey-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.model-select {
  flex: 1 1 160px;
  min-width: 140px;
  padding: 6px 10px;
  font-size: 12px;
  font-family: 'DM Mono', monospace;
  border: 1px solid #d4c9a0;
  border-radius: 6px;
  background: #fff;
  color: #2a1f0a;
}

.provider-apikey {
  flex: 2 1 200px;
  min-width: 160px;
  padding: 6px 10px;
  font-size: 12px;
  font-family: 'DM Mono', monospace;
  border: 1px solid #d4c9a0;
  border-radius: 6px;
  background: #fff;
  color: #2a1f0a;
}

.lang-row {
  padding: 10px 18px;
  border-bottom: 1px solid #e8e0c8;
  background: #fafaf4;
}

.lang-label {
  display: block;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  color: #1a6b3a;
  text-transform: uppercase;
  margin-bottom: 7px;
}

.lang-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.lang-btn {
  background: #fff;
  border: 1px solid #d4c9a0;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-family: 'DM Mono', monospace;
  cursor: pointer;
  color: #2a1f0a;
  transition: all 0.15s;
}

.lang-btn:hover {
  border-color: #1a6b3a;
  color: #1a6b3a;
}

.lang-btn.active {
  background: #1a6b3a;
  border-color: #1a6b3a;
  color: #fff;
}

/* ── Textarea ── */
textarea {
  width: 100%;
  padding: 16px 18px;
  font-family: 'Lora', serif;
  font-size: 14px;
  line-height: 1.75;
  color: #2a1f0a;
  background: transparent;
  border: none;
  outline: none;
  resize: vertical;
  min-height: 120px;
}

textarea::placeholder {
  color: #a09070;
}

.upload-row {
  padding: 12px 18px;
  border-top: 1px dashed #d4c9a0;
  background: #fafaf2;
}

.upload-label {
  display: block;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: #1a6b3a;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  cursor: pointer;
}

#fileInput {
  display: block;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: #2a1f0a;
  width: 100%;
}

.file-preview {
  margin-top: 6px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: #1a6b3a;
  min-height: 16px;
}

/* ── Footer / button ── */
.card-footer {
  padding: 12px 18px;
  border-top: 1px solid #e8e0c8;
  display: flex;
  justify-content: flex-end;
}

.btn-translate {
  background: #1a6b3a;
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 10px 28px;
  font-size: 13px;
  font-family: 'DM Mono', monospace;
  cursor: pointer;
  letter-spacing: 1px;
  transition: background 0.2s;
}

.btn-translate:hover:not(:disabled) {
  background: #228b4a;
}

.btn-translate:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Output ── */
.output-card {
  background: #122118;
  border-radius: 6px;
  border: 1px solid #2d5c3e;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  display: none;
  animation: fadeIn 0.4s ease;
}

.output-header {
  background: #1a3a2a;
  padding: 9px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.check {
  color: #7fffc4;
  font-size: 15px;
}

.output-header-label {
  color: #7fffc4;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.output-body {
  padding: 22px 26px;
}

.usage-info {
  width: 100%;
  max-width: 760px;
  text-align: center;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: #6b9e82;
  margin-bottom: 10px;
}

.usage-info a {
  color: #7fffc4;
  text-decoration: underline;
}

.section-label {
  display: inline-block;
  background: #1a3a2a;
  color: #7fffc4;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 3px;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.section-text {
  margin: 0 0 18px 0;
  color: #d4efe3;
  font-size: 15px;
  line-height: 1.7;
}

.pdf-row {
  width: 100%;
  max-width: 760px;
  display: flex;
  justify-content: flex-end;
  margin-bottom: 20px;
}

.btn-pdf {
  background: transparent;
  border: 1px solid #2d5c3e;
  border-radius: 5px;
  color: #7fffc4;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  padding: 8px 18px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.2s;
}

.btn-pdf:hover {
  background: #1a3a2a;
  border-color: #7fffc4;
}

/* ── States ── */
.loading {
  text-align: center;
  padding: 20px;
  color: #6b9e82;
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  display: none;
}

.spinner {
  display: inline-block;
  animation: spin 1s linear infinite;
  margin-right: 6px;
}

.error-box {
  background: #2a0a0a;
  border: 1px solid #8b0000;
  border-radius: 6px;
  padding: 14px 18px;
  color: #ff8080;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  display: none;
  word-break: break-word;
}

.disclaimer {
  color: #3d5c48;
  font-size: 11px;
  text-align: center;
  font-family: 'DM Mono', monospace;
  margin-top: 8px;
}

.admin-link-wrap {
  margin-top: 6px;
}

.admin-link {
  color: #3d5c48;
  text-decoration: none;
}

/* ── History ── */
.history-section {
  display: none;
  width: 100%;
  max-width: 760px;
  margin-bottom: 20px;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.history-title {
  color: #6b9e82;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.btn-clear-history {
  background: transparent;
  border: 1px solid #2d5c3e;
  border-radius: 4px;
  color: #6b9e82;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  padding: 3px 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-clear-history:hover {
  border-color: #8B0000;
  color: #ff8080;
}

.history-item {
  background: #122118;
  border: 1px solid #1e3d2a;
  border-radius: 6px;
  padding: 14px 18px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.history-item:hover {
  border-color: #2d5c3e;
}

.history-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.history-badge {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
}

.history-badge.text {
  background: #1a3a2a;
  color: #7fffc4;
}

.history-badge.ocr {
  background: #2a2a1a;
  color: #ffc47f;
}

.history-date {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: #3d5c48;
}

.history-lang {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: #3d5c48;
  margin-left: auto;
}

.history-input-preview {
  font-size: 12px;
  color: #6b9e82;
  font-family: 'DM Mono', monospace;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-input-full {
  font-size: 12px;
  color: #6b9e82;
  font-family: 'DM Mono', monospace;
  margin-bottom: 6px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.history-result-preview {
  font-size: 13px;
  color: #d4efe3;
  line-height: 1.5;
  display: none;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #1e3d2a;
}

.history-item.expanded .history-result-preview {
  display: block;
}

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

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

.btn-upload {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px dashed #d4c9a0;
  border-radius: 6px;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: #1a6b3a;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.btn-upload:hover,
.btn-upload:focus {
  border-color: #1a6b3a;
  background: #f0fff4;
}

/* ── Mobile optimalizácia ───────────────── */
@media (max-width: 600px) {

  body {
    padding: 20px 12px 24px 12px;
  }

  h1 {
    font-size: 32px;
    margin-bottom: 6px;
  }

  .subtitle {
    font-size: 11px;
    margin-bottom: 24px;
  }

  /* Jazykové tlačidlá — scrollovateľný riadok */
  .lang-options {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    gap: 8px;
  }

  .lang-options::-webkit-scrollbar {
    display: none;
  }

  .lang-btn {
    flex-shrink: 0;
    padding: 6px 14px;
    font-size: 13px;
  }

  /* Textarea — väčšia na mobile */
  textarea {
    min-height: 140px;
    font-size: 16px; /* zabraňuje zoom na iOS pri focuse */
  }

  /* Upload row */
  .upload-row {
    padding: 10px 14px;
  }

  .btn-upload {
    padding: 14px;
    font-size: 14px;
  }

  /* Akčné tlačidlo v rámci karty */
  .card-footer {
    display: flex;
    padding: 16px;
  }

  .btn-translate {
    position: static;
    width: 100%;
    padding: 16px;
    font-size: 15px;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(26, 107, 58, 0.5);
    letter-spacing: 2px;
    text-align: center;
  }

  /* Output sekcia */
  .output-body {
    padding: 16px 16px;
  }

  .section-label {
    font-size: 9px;
  }

  .section-text {
    font-size: 14px;
  }

  /* História */
  .history-item {
    padding: 12px 14px;
  }

  .history-input-preview {
    font-size: 11px;
  }

  /* Offline banner */
  #offlineBanner {
    font-size: 11px;
    padding: 8px;
    bottom: calc(72px + var(--safe-bottom));
  }

  /* Badge + nadpis horizontálne centrovanie */
  .badge {
    font-size: 9px;
    letter-spacing: 2px;
  }
}

/* ── Malé telefóny (iPhone SE a pod.) ───── */
@media (max-width: 380px) {
  h1 {
    font-size: 26px;
  }

  .lang-btn {
    padding: 5px 10px;
    font-size: 12px;
  }
}

/* ── Touch optimalizácia (všetky mobily) ── */
@media (hover: none) and (pointer: coarse) {
  .btn-example,
  .lang-btn,
  .history-item,
  .btn-clear-history {
    min-height: 40px;      /* minimálna dotyková plocha */
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .history-item {
    display: block;        /* override flex len pre tlačidlá */
  }
}
