:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-border: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;
  --warning-bg: #fef3c7;
  --warning-text: #92400e;
  --success-bg: #dcfce7;
  --success-text: #166534;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(circle at top, rgba(59, 130, 246, 0.12), transparent 45%),
    var(--bg);
  color: var(--text);
}

.page {
  max-width: 56rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 1.5rem;
}

.header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  font-weight: 700;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.messages { margin: 1rem 0 0; }

.message {
  padding: 0.85rem 1rem;
  border-radius: 0.75rem;
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
}

.message-warning { background: var(--warning-bg); color: var(--warning-text); }
.message-danger { background: var(--danger-bg); color: var(--danger-text); }
.message-success { background: var(--success-bg); color: var(--success-text); }

.upload-form { margin-top: 1rem; }

.drop-zone {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border: 2px dashed var(--panel-border);
  border-radius: 0.75rem;
  background: var(--panel);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: #f8fbff;
  outline: none;
}

.drop-zone.has-file {
  border-style: solid;
  border-color: var(--accent);
}

.file-input-native {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
}

.drop-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.5rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
}

.drop-zone-text { flex: 1; min-width: 0; }

.drop-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
}

.selected-file {
  margin: 0.25rem 0 0;
  color: var(--success-text);
  font-size: 0.85rem;
  font-weight: 500;
  word-break: break-all;
}

.translate-mode-wrap { margin-top: 1rem; }

.translate-mode-label {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.translate-mode-switch {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 0.2rem;
  border: 1px solid var(--panel-border);
  border-radius: 0.65rem;
  background: #e2e8f0;
}

.translate-mode-switch .mode-segment {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  margin: 0;
  padding: 0.55rem 0.65rem;
  border: none;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}

.mode-segment__hint {
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.35;
  color: var(--muted);
}

.translate-mode-switch .mode-segment.is-active { color: var(--text); }

.translate-mode-switch .mode-slider {
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: calc(50% - 0.2rem);
  height: calc(100% - 0.4rem);
  border-radius: 0.5rem;
  background: var(--panel);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
  transition: transform 0.2s ease;
  pointer-events: none;
}

.translate-mode-switch.is-docx .mode-slider { transform: translateX(100%); }

.upload-options {
  margin-top: 1rem;
  border: 1px solid var(--panel-border);
  border-radius: 0.75rem;
  background: var(--panel);
  overflow: hidden;
}

.upload-options__section { padding: 0.95rem 1.1rem; }

.upload-options__section + .upload-options__section,
#pdf-options + .upload-options__section { border-top: 1px solid var(--panel-border); }

.upload-options__heading {
  margin: 0 0 0.65rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.upload-options__tiles {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 0.65rem;
}

.upload-flow-join {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 1.05rem;
}

.upload-option-tile {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--panel-border);
  border-radius: 0.55rem;
  background: #f8fafc;
  cursor: pointer;
}

.upload-option-tile:hover { border-color: #94a3b8; background: #fff; }

.upload-option-tile:has(input:checked) {
  border-color: rgba(59, 130, 246, 0.45);
  background: #f8fbff;
}

.upload-option-tile__head {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
}

.upload-option-tile__label {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
}

.upload-option-tile__hint {
  padding-left: 1.35rem;
  font-size: 0.74rem;
  line-height: 1.4;
  color: var(--muted);
}

.upload-option-tile input[type="checkbox"] {
  margin: 0.12rem 0 0;
  accent-color: var(--accent);
}

.upload-options__model { display: block; margin: 0; max-width: 16rem; }

.upload-options__action {
  display: flex;
  justify-content: flex-end;
}

.btn-submit {
  min-width: 7.5rem;
  padding: 0.4rem 0.9rem;
  border: none;
  border-radius: 0.5rem;
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-submit:hover { background: var(--accent-hover); }

.log-section {
  max-width: 56rem;
  margin: 0 auto;
  padding: 0 1.25rem 2.5rem;
}

.log-section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.log-section-header h2 { margin: 0; font-size: 1.35rem; }

.clear-finished-form { margin: 0; }

.btn-clear-finished,
.btn-delete {
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--panel-border);
  border-radius: 0.5rem;
  background: var(--panel);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.btn-delete { padding: 0.2rem 0.55rem; font-size: 0.75rem; }

.btn-clear-finished:hover,
.btn-delete:hover:not(:disabled) {
  border-color: #b91c1c;
  background: var(--danger-bg);
  color: var(--danger-text);
}

.btn-delete:disabled { opacity: 0.55; cursor: not-allowed; }

.translation-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.translation-list-empty {
  margin: 0;
  padding: 1.25rem;
  border: 1px dashed var(--panel-border);
  border-radius: 0.75rem;
  text-align: center;
  color: var(--muted);
}

.translation-card {
  border: 1px solid var(--panel-border);
  border-radius: 0.75rem;
  background: var(--panel);
  padding: 1rem 1.15rem;
}

.translation-card:nth-child(even) { background: #f8fafc; }

.translation-card--processing {
  border-color: #7dd3fc;
  box-shadow: 0 0 0 1px rgba(14, 165, 233, 0.15);
}

.translation-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.translation-card__title-block { flex: 1; min-width: 0; }

.translation-card__title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.translation-card__title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.translation-card__summary {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.translation-card__download { flex-shrink: 0; }

.step-checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0.85rem;
}

.step-checklist-item {
  display: flex;
  flex: 1 1 9rem;
  gap: 0.45rem;
  align-items: flex-start;
  min-width: 0;
  padding: 0.45rem 0.55rem;
  border-radius: 0.45rem;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid transparent;
  box-shadow: inset 0 -1px 0 #e2e8f0;
}

.step-checklist-item--ok { border-color: #bbf7d0; }
.step-checklist-item--active { border-color: #bae6fd; background: #f0f9ff; }
.step-checklist-item--pending { opacity: 0.72; }
.step-checklist-item--error { border-color: #fecaca; }

.step-checklist-item__icon { flex-shrink: 0; font-size: 1rem; line-height: 1.3; }
.step-checklist-item--ok .step-checklist-item__icon { color: #15803d; }
.step-checklist-item--active .step-checklist-item__icon { color: #0369a1; }
.step-checklist-item--pending .step-checklist-item__icon { color: #94a3b8; }
.step-checklist-item--error .step-checklist-item__icon { color: #b91c1c; }

.step-checklist-item__icon--spin { animation: step-spin 1.2s linear infinite; }

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

.step-checklist-item__label {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
}

.step-checklist-item__message {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.step-checklist-item__hints {
  margin: 0.35rem 0 0;
  padding-left: 1rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.step-download-link {
  display: inline-block;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0.35rem;
  border: 1px solid #0ea5e9;
  background: #f0f9ff;
  color: #0369a1;
}

.step-download-link:hover { background: #e0f2fe; }

.translation-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--panel-border);
}

.translation-actions form { margin: 0; }

.translation-actions__spacer { flex: 1; }

.translation-details { margin-top: 0.65rem; font-size: 0.8rem; }

.translation-details__summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
}

.translation-details__body {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--panel-border);
}

.translation-details__meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 0.5rem 1rem;
  margin: 0 0 0.5rem;
}

.translation-details__meta dt {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin: 0;
}

.translation-details__meta dd { margin: 0.1rem 0 0; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: #bbf7d0; color: #14532d; }
.badge-warning { background: #fde68a; color: #78350f; }
.badge-danger { background: #fecaca; color: #7f1d1d; }
.badge-secondary { background: #e2e8f0; color: #334155; }
.badge-info { background: #bae6fd; color: #0c4a6e; }

@media (max-width: 640px) {
  .upload-options__tiles { grid-template-columns: 1fr; }
  .upload-flow-join { display: none; }
  .translate-mode-switch { grid-template-columns: 1fr; }
  .translate-mode-switch .mode-slider { display: none; }
  .translate-mode-switch .mode-segment.is-active {
    background: var(--panel);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
  }
}
