:root {
  color-scheme: light;
  --bg: #eef3f8;
  --panel: #ffffff;
  --ink: #18212f;
  --muted: #647084;
  --line: #d8e1eb;
  --accent: #176b87;
  --accent-dark: #104d61;
  --accent-soft: #dff3f7;
  --paper: #f9fbfc;
  --paper-strong: #ffffff;
  --danger: #a13d45;
  --shadow: 0 24px 70px rgba(31, 46, 71, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(238, 243, 248, 0.94), rgba(220, 235, 237, 0.92)),
    url("https://images.unsplash.com/photo-1456513080510-7bf3a84b82f8?auto=format&fit=crop&w=1800&q=80") center / cover fixed;
  color: var(--ink);
}

button,
select,
textarea,
input {
  font: inherit;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.translator {
  width: min(1100px, 100%);
  max-width: 100%;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(20px, 3vw, 34px);
  backdrop-filter: blur(16px);
}

.topbar,
.language-row,
.actions,
.panel-heading,
.mode-tabs {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  min-width: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4.5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.version-badge {
  border: 1px solid rgba(23, 107, 135, 0.2);
  border-radius: 999px;
  background: linear-gradient(180deg, #effcff, var(--accent-soft));
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 900;
  padding: 8px 12px;
  box-shadow: 0 8px 22px rgba(23, 107, 135, 0.12);
  white-space: nowrap;
}

.brand-note {
  max-width: 680px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.5;
}

.coach-panel {
  margin: 4px 0 16px;
}

.coach-card {
  border: 1px solid rgba(23, 107, 135, 0.18);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(239, 252, 255, 0.9));
  box-shadow: 0 16px 38px rgba(24, 33, 47, 0.1);
  padding: 14px;
}

.coach-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.feedback-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.feedback-grid input,
.feedback-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 12px;
}

.feedback-grid textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.5;
}

.feedback-message {
  grid-column: 1 / -1;
}

.tips-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.tips-panel article {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid rgba(216, 225, 235, 0.85);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 12px;
}

.tips-panel article > span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 900;
}

.tips-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.tips-panel strong {
  color: var(--ink);
}

.icon-button {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 1.7rem;
  font-weight: 800;
}

.help-button {
  min-height: 44px;
  border: 1px solid rgba(23, 107, 135, 0.22);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-dark);
  cursor: pointer;
  font-weight: 900;
  padding: 0 14px;
  max-width: 100%;
}

.help-button:hover {
  background: var(--accent-soft);
}

.mode-tabs {
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  overflow: visible;
  padding-bottom: 2px;
}

.mode-tab {
  flex: 1 1 96px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  padding: 0 16px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.mode-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.language-row {
  gap: 14px;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 8px;
}

.language-row label {
  flex: 1;
}

label span,
.panel-title {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.panel-title {
  display: block;
  color: var(--ink);
  font-size: 0.98rem;
  letter-spacing: 0;
}

.panel-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

select {
  min-height: 46px;
  padding: 0 14px;
  cursor: pointer;
}

textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.14);
}

.media-tools {
  margin-bottom: 16px;
  min-width: 0;
}

.upload-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 14px;
}

.file-drop {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, auto);
  gap: 12px;
  align-items: center;
  border: 1px dashed #9fb1c4;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  min-height: 86px;
  place-items: center;
  padding: 16px;
  text-align: center;
}

.file-drop span {
  min-width: 0;
  color: var(--accent-dark);
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.file-drop input {
  width: min(320px, 100%);
  min-width: 0;
}

.hint {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.media-preview {
  width: min(520px, 100%);
  max-height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
  object-fit: contain;
}

.video-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 240px) auto;
  gap: 12px;
  align-items: end;
}

.link-row input,
.link-row select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
}

.divider-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.screen-text-result {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.screen-text-result > div {
  min-width: 0;
}

.screen-text-result p {
  margin: 8px 0 0;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}

.text-panel {
  min-height: 380px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--paper-strong), var(--paper));
  padding: 16px;
  box-shadow: 0 14px 35px rgba(24, 33, 47, 0.08);
}

.source-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
}

textarea {
  min-height: 286px;
  max-height: 58vh;
  resize: vertical;
  border: 1px solid rgba(216, 225, 235, 0.72);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  line-height: 1.7;
  font-size: 1.05rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.char-badge {
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 5px 10px;
  white-space: nowrap;
}

.output-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-heading {
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.output-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.translated-text {
  flex: 1;
  margin: 0;
  max-height: 58vh;
  overflow: auto;
  border: 1px solid rgba(216, 225, 235, 0.72);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.75;
  font-size: 1.05rem;
  color: #111827;
  outline: none;
}

.translated-text:empty::before {
  content: "Перевод появится здесь.";
  color: var(--muted);
}

.translated-text:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.14);
}

.actions {
  gap: 12px;
  margin-top: 18px;
}

.primary-button,
.secondary-button,
.text-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  padding: 0 22px;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  background: #e9eef4;
  color: var(--ink);
}

.compact {
  justify-self: start;
  min-height: 42px;
}

.text-button {
  border: 1px solid rgba(23, 107, 135, 0.22);
  background: #fff;
  color: var(--accent);
  padding: 8px 10px;
  text-decoration: none;
}

.text-button:hover {
  background: var(--accent-soft);
}

.status {
  min-height: 28px;
  margin: 14px 0 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  line-height: 1.45;
  padding: 8px 10px;
}

.status.error {
  background: rgba(161, 61, 69, 0.08);
  color: var(--danger);
}

@media (max-width: 900px) {
  .app-shell {
    padding: 10px;
    place-items: stretch;
  }

  .translator {
    align-self: center;
    width: 100%;
    padding: 18px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  h1 {
    font-size: clamp(2.1rem, 12vw, 3rem);
    line-height: 1;
  }

  .brand-note {
    font-size: 0.92rem;
  }

  .language-row,
  .panels {
    grid-template-columns: 1fr;
    display: grid;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr 48px;
    gap: 8px;
  }

  .help-button {
    width: 100%;
    padding: 0 10px;
    overflow-wrap: anywhere;
  }

  .mode-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .mode-tab {
    width: 100%;
    min-width: 0;
    padding: 0 10px;
  }

  .screen-text-result {
    grid-template-columns: 1fr;
  }

  .link-row {
    grid-template-columns: 1fr;
  }

  .tips-panel {
    grid-template-columns: 1fr;
  }

  .feedback-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .file-drop {
    grid-template-columns: 1fr;
    justify-items: stretch;
    text-align: left;
  }

  .file-drop input {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .translator {
    padding: 14px;
  }

  .version-badge {
    white-space: normal;
  }

  .top-actions {
    grid-template-columns: 1fr;
  }

  .icon-button {
    width: 100%;
  }

  .mode-tabs {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .output-actions {
    justify-content: stretch;
  }

  .text-button {
    text-align: center;
  }
}
