@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap");

:root {
  color-scheme: light;
  --bg: #eef2f8;
  --panel: #ffffff;
  --panel-soft: #f0f4fb;
  --text: #202a3a;
  --muted: #6f7c92;
  --line: #c9d4e6;
  --accent: #2f6de5;
  --accent-strong: #1f59c7;
  --accent-soft: #eaf0ff;
  --brand-logo-gray: #6f7f94;
  --brand-logo-blue: #2f6de5;
  --brand-logo-blue-strong: #1f59c7;
  --focus: #7da6ff;
  --danger: #b42318;
  --topbar-height: 64px;
  --layout-offset: 40px;
  font-family: Manrope, "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 420px at 50% -210px, #dfe9ff 0%, rgba(223, 233, 255, 0) 62%),
    radial-gradient(900px 320px at 100% -160px, #ecf3ff 0%, rgba(236, 243, 255, 0) 60%),
    var(--bg);
  color: var(--text);
}

.site-footer {
  position: static;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 2px;
  min-height: 58px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
}

.footer-status {
  margin: 0;
  text-align: left;
}

.status-limited {
  color: var(--danger);
}

.site-footer-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.site-footer-text a {
  color: var(--accent);
  text-decoration: none;
}

.site-footer-text a:hover,
.site-footer-text a:focus-visible {
  text-decoration: underline;
}

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

.topbar {
  position: relative;
  z-index: 220;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  overflow: visible;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.brand-logo {
  display: block;
  width: auto;
  height: 44px;
}

.brand-title {
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.account {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-header-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  min-width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.history-header-button:hover,
.history-header-button:focus-visible {
  color: var(--accent-strong);
  background: transparent;
  box-shadow: none;
}

.ui-language-picker {
  position: relative;
  z-index: 240;
}

.ui-language-list {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 230px;
  max-height: 300px;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.14);
  z-index: 260;
}

.ui-language-button[aria-expanded="true"],
#uiLanguageButton[aria-expanded="true"] {
  position: relative;
  z-index: 261;
}

.ui-language-list button {
  width: 100%;
  border: 0;
  border-radius: 6px;
  padding: 8px 10px;
  text-align: left;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.ui-language-list button:hover,
.ui-language-list button.active {
  background: var(--panel-soft);
}

.ui-language-list button.ui-language-english {
  font-weight: 700;
}

.ui-language-divider {
  margin: 6px 4px;
  border-top: 1px solid var(--line);
}

.account-email {
  max-width: 220px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shell {
  flex: 1 0 auto;
  width: min(1480px, calc(100vw - 20px));
  margin: 14px auto;
  min-height: calc(100dvh - var(--topbar-height) - 86px);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
}

.translator-layout {
  display: flex;
  position: relative;
  z-index: 1;
  height: 100%;
  min-height: 0;
}

.option-sidebar {
  display: flex;
  position: relative;
  z-index: 30;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 24px rgba(26, 44, 83, 0.08);
  overflow: visible;
}

.option-disclosure {
  position: relative;
  z-index: 0;
  flex: 1 1 0;
  min-width: 0;
  max-width: none;
}

.option-disclosure[open] {
  z-index: 60;
}

.option-disclosure-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 40px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  cursor: pointer;
  list-style: none;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.option-disclosure-trigger:hover,
.option-disclosure[open] .option-disclosure-trigger {
  border-color: #b8caeb;
  background: #f7faff;
}

.option-disclosure-trigger::-webkit-details-marker {
  display: none;
}

.option-disclosure-heading {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.option-disclosure-title {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.option-disclosure-value {
  overflow: hidden;
  color: #334155;
  font-size: 0.78rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.option-disclosure-chevron {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  position: relative;
}

.option-disclosure-chevron::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translate(-65%, -55%) rotate(-45deg);
  transition: transform 0.16s ease;
}

.option-disclosure[open] .option-disclosure-chevron::before {
  transform: translate(-55%, -35%) rotate(45deg);
}

.option-disclosure-body {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: clamp(220px, 24vw, 320px);
  max-width: min(92vw, 320px);
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 18px 38px rgba(21, 43, 89, 0.18);
  z-index: 50;
  overflow: visible;
}

.option-disclosure[data-setting="dialect"] .option-disclosure-body {
  left: auto;
  right: 0;
}

.option-disclosure[open] .option-disclosure-body {
  display: block;
}

.option-disclosure-body .segmented-field {
  margin: 0;
  padding: 0;
  border: 0;
}

.dialect-options-menu {
  display: grid;
  gap: 4px;
}

.dialect-option-button {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid #e0e8f6;
  border-radius: 8px;
  background: #ffffff;
  color: #334155;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}

.dialect-option-button:hover,
.dialect-option-button:focus-visible {
  border-color: #cedcf5;
  background: #f7fbff;
}

.dialect-option-button.active {
  border-color: var(--accent);
  background: #ffffff;
  color: var(--accent-strong);
  box-shadow: 0 6px 14px rgba(54, 95, 178, 0.12);
}

.option-history-icon {
  font-size: 1rem;
  line-height: 1;
}

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

.translator {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  order: 1;
  flex: 1 1 0;
  gap: 18px;
  align-self: stretch;
  min-width: 0;
  min-height: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 20px 48px rgba(33, 63, 126, 0.12);
}

.translator-layout-toggle {
  justify-self: end;
}

.layout-toggle-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.layout-toggle-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.layout-toggle {
  position: relative;
  width: 44px;
  height: 26px;
  display: inline-block;
}

.layout-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.layout-toggle-slider {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.layout-toggle-slider::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.18);
  transition: transform 0.16s ease;
}

.layout-toggle input:checked + .layout-toggle-slider {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.layout-toggle input:checked + .layout-toggle-slider::before {
  transform: translateX(18px);
}

#translatorPanel.layout-stacked .panes {
  grid-template-columns: 1fr;
}

#translatorPanel.layout-stacked .input-pane {
  border-right: 0;
  border-bottom: 1px solid var(--line);
}

#translatorPanel.layout-stacked .pane-swap-button {
  display: none;
}

.select-wrap,
.advanced label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.language-combobox {
  position: static;
  z-index: 30;
}

.language-trigger-button {
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid rgba(47, 109, 229, 0.08);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(240, 246, 255, 0.92));
  color: #004899;
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 10px 24px -20px rgba(31, 89, 199, 0.7);
  transition: border-color 0.14s ease, background-color 0.14s ease, color 0.14s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.language-trigger-button:hover {
  border-color: rgba(47, 109, 229, 0.18);
  background: linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(235, 243, 255, 0.96));
  box-shadow: 0 16px 28px -22px rgba(31, 89, 199, 0.9);
}

.language-trigger-button[aria-expanded="true"] {
  border-color: rgba(47, 109, 229, 0.24);
  background: linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(232, 241, 255, 0.98));
  color: #004899;
  box-shadow: 0 20px 36px -26px rgba(31, 89, 199, 0.95);
}

.language-trigger-button:focus-visible {
  border-color: rgba(0, 72, 153, 0.45);
  box-shadow: 0 0 0 3px rgba(0, 72, 153, 0.12), 0 18px 34px -24px rgba(31, 89, 199, 0.95);
}

.language-trigger-label {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.language-trigger-chevron {
  flex: 0 0 auto;
  color: #004899;
  font-size: 0.9rem;
  line-height: 1;
  transition: transform 0.18s ease;
}

.language-trigger-button[aria-expanded="true"] .language-trigger-chevron {
  transform: rotate(180deg);
}

.language-options {
  --language-grid-columns: 4;
  position: absolute;
  top: 0;
  left: 0;
  transform: none;
  width: 800px;
  min-width: 0;
  max-width: calc(100vw - 24px);
  max-height: min(70vh, 532px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  margin: 0;
  padding: 10px;
  list-style: none;
  border: 1px solid rgba(47, 109, 229, 0.12);
  border-radius: 22px;
  background:
    radial-gradient(circle at top right, rgba(104, 162, 255, 0.16), rgba(104, 162, 255, 0) 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 250, 255, 0.96));
  box-shadow: 0 32px 90px -44px rgba(15, 40, 92, 0.55), 0 20px 42px -28px rgba(31, 89, 199, 0.3);
  backdrop-filter: blur(18px);
  isolation: isolate;
  z-index: 60;
}

.language-options::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.44), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.language-options::-webkit-scrollbar {
  width: 10px;
}

.language-options::-webkit-scrollbar-track {
  background: transparent;
}

.language-options::-webkit-scrollbar-thumb {
  background: rgba(95, 129, 180, 0.42);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
}

.language-menu-search-row {
  position: -webkit-sticky;
  position: sticky;
  top: -2px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  margin: 0 0 10px;
  height: 42px;
  border: 1px solid rgba(47, 109, 229, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78), 0 14px 30px -28px rgba(31, 89, 199, 0.8);
  backdrop-filter: blur(12px);
}

.language-menu-search-icon {
  flex: 0 0 auto;
  color: #4771b4;
  font-size: 1rem;
}

.language-menu-search-input {
  flex: 1 1 auto;
  width: auto;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #1f2937;
  font-size: 0.9rem;
  font-weight: 600;
}

.language-menu-search-input:focus {
  box-shadow: none;
}

.language-menu-search-input::placeholder {
  color: #7f90aa;
  font-weight: 500;
}

.language-section-title {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin: 0 0 6px;
  padding: 5px 9px;
  border: 1px solid rgba(47, 109, 229, 0.08);
  border-radius: 999px;
  background: rgba(239, 245, 255, 0.92);
  color: #5a6f91;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.language-section-divider {
  margin: 8px 2px 10px;
  border-top: 1px solid rgba(160, 184, 224, 0.42);
}

.language-options-grid {
  display: grid;
  grid-template-columns: repeat(var(--language-grid-columns), minmax(0, 1fr));
  gap: 4px;
  padding: 0 1px 4px;
}

.language-option-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  border: 1px solid rgba(47, 109, 229, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  color: #1f2937;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.76);
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.language-option-label {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.language-option-check {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(47, 109, 229, 0.12);
  font-size: 0.72rem;
  color: #1f59c7;
  opacity: 0;
  transform: scale(0.84);
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.language-option-button:hover,
.language-option-button.active {
  border-color: rgba(47, 109, 229, 0.16);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(239, 245, 255, 0.9));
  color: #143867;
  box-shadow: 0 18px 30px -28px rgba(31, 89, 199, 0.95);
  transform: translateY(-1px);
}

.language-option-button.selected {
  border-color: rgba(31, 89, 199, 0.2);
  background: linear-gradient(180deg, rgba(230, 240, 255, 0.98), rgba(216, 231, 255, 0.96));
  color: #004899;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55), 0 20px 34px -30px rgba(31, 89, 199, 1);
}

.language-option-button.selected .language-option-check {
  opacity: 1;
  transform: scale(1);
}

.language-option-empty {
  color: #64748b;
  padding: 12px 10px;
  border: 1px dashed rgba(95, 129, 180, 0.28);
  border-radius: 12px;
  background: rgba(247, 250, 255, 0.9);
  font-size: 0.85rem;
}

.language-hidden-select {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid #dbe4f4;
  border-radius: 12px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

select,
input {
  height: 48px;
  padding: 0 14px;
}

select:focus,
input:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 4px rgba(125, 166, 255, 0.2);
}

.icon-button,
.ghost-button,
.mini-button,
.primary-button,
.segment {
  border: 1px solid #dde6f5;
  border-radius: 12px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.icon-button {
  width: 44px;
  height: 44px;
  font-size: 1.25rem;
}

.ghost-button,
.mini-button {
  height: 40px;
  padding: 0 14px;
  font-weight: 700;
}

.ghost-button:hover,
.mini-button:hover,
.icon-button:hover {
  background: var(--panel-soft);
}

.segmented-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented-field legend {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: stretch;
  gap: 4px;
  min-height: 0;
  padding: 3px;
  border: 0;
  border-radius: 10px;
  background: #f8faff;
}

.segmented-control--vertical {
  flex-direction: column;
  flex-wrap: nowrap;
}

.segmented-control--vertical .segment {
  width: 100%;
  min-width: 0;
  max-width: none;
}

.segmented-control--with-help {
  gap: 4px;
}

.segment-row {
  display: flex;
  gap: 4px;
  align-items: stretch;
}

.segment-row .segment {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.option-help {
  flex: 0 0 22px;
  width: 22px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  cursor: help;
  position: relative;
}

.option-help:hover,
.option-help:focus-visible {
  color: var(--accent-strong);
  border-color: var(--accent);
  background: var(--accent-soft);
  z-index: 30;
}

.option-help::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  width: max(220px, 16vw);
  max-width: 280px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--text);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.4;
  white-space: normal;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, visibility 0.12s ease;
  z-index: 40;
}

.option-help:hover::after,
.option-help:focus-visible::after {
  opacity: 1;
  visibility: visible;
}

.option-sidebar .segment-row {
  position: relative;
}

.option-sidebar .option-help {
  position: static;
}

.option-sidebar .option-help::after {
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  width: auto;
  max-width: none;
  transform: none;
  box-sizing: border-box;
}

.segment {
  flex: 1 1 auto;
  min-width: fit-content;
  max-width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid #e0e8f6;
  border-color: #e0e8f6;
  border-radius: 8px;
  color: #334155;
  background: #ffffff;
  white-space: nowrap;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
}

.segment:hover {
  border-color: #cedcf5;
  background: #f7fbff;
}

.segment.active {
  border-color: var(--accent);
  background: #ffffff;
  color: var(--accent-strong);
  box-shadow: 0 6px 14px rgba(54, 95, 178, 0.12);
}

.panes {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 0;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: visible;
  background: #ffffff;
}

.pane-swap-button {
  position: absolute;
  top: 36px;
  left: 50%;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  border-color: #c8d5ef;
  background: #f9fbff;
  box-shadow: 0 8px 22px rgba(45, 84, 168, 0.18);
  z-index: 6;
}

.pane-swap-button:hover,
.pane-swap-button:focus-visible {
  border-color: var(--accent);
  background: #ffffff;
}

.pane {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  padding: 0;
  background: var(--panel);
}

.input-pane {
  border-right: 1px solid var(--line);
}

.pane-language-strip {
  --pane-seam-gap: 34px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: #eef4ff;
}

.input-pane .pane-language-strip {
  display: flex;
  justify-content: flex-start;
  padding-right: var(--pane-seam-gap);
}

.output-pane .pane-language-strip {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-left: var(--pane-seam-gap);
}

.pane-language-strip .pane-language-select {
  width: min(100%, 330px);
}

.pane-content {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
  padding: 14px 18px 16px;
}

.pane-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pane-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.input-language-prompt {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
  min-width: 0;
  flex: 1 1 auto;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.25;
  text-align: right;
}

.input-language-prompt[hidden] {
  display: none;
}

.input-language-prompt-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.input-language-prompt-button:hover,
.input-language-prompt-button:focus-visible {
  text-decoration: underline;
}

.pane-language-select {
  gap: 6px;
}

.pane-language-select--inline {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

#translatorPanel:not(.layout-stacked) .input-pane .pane-language-strip {
  justify-content: flex-end;
}

#translatorPanel:not(.layout-stacked) .pane-language-select--inline {
  grid-template-columns: minmax(0, 1fr);
}

#translatorPanel:not(.layout-stacked) .input-pane .pane-language-select--inline {
  justify-items: end;
}

#translatorPanel:not(.layout-stacked) .input-pane .pane-language-select--inline .language-combobox {
  justify-self: end;
}

#translatorPanel:not(.layout-stacked) .output-pane .pane-language-strip {
  justify-content: flex-start;
}

#translatorPanel:not(.layout-stacked) .output-pane .pane-language-select--inline {
  justify-items: start;
}

#translatorPanel:not(.layout-stacked) .output-pane .pane-language-select--inline .language-combobox {
  justify-self: start;
}

#translatorPanel.layout-stacked .pane-language-strip {
  justify-content: flex-start;
}

#translatorPanel.layout-stacked .pane-language-select--inline {
  justify-items: start;
}

.pane-language-select > span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#translatorPanel:not(.layout-stacked) .pane-language-select > span {
  display: none;
}

.pane-language-select .language-trigger-button {
  height: 40px;
  border-radius: 10px;
  font-size: 0.86rem;
}

.pane-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pane-actions--strip {
  margin-left: auto;
  justify-content: flex-end;
}

#resetButton {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid #dfe7f6;
  border-radius: 10px;
  background: #ffffff;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}
#resetButton:hover,
#resetButton:focus-visible {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--panel-soft);
}

#inputText {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 10px 0 8px;
  resize: none;
  overflow: auto;
  border: 0;
  border-radius: 0;
  line-height: 1.55;
}

#inputText:focus {
  box-shadow: none;
}

.output-text {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 10px 0 8px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}

.output-text.editable {
  min-height: 0;
  height: 100%;
  padding: 12px;
  border: 1px solid #dbe4f4;
  border-radius: 12px;
  background: #ffffff;
  overflow: auto;
}

.output-text.editable:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(201, 134, 34, 0.18);
}

body.output-edit-active {
  overflow: hidden;
}

body.output-edit-active::before {
  content: "";
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 320;
  pointer-events: none;
}

.output-pane.manual-edit-active {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(75vw, 1200px);
  height: 75vh;
  transform: translate(-50%, -50%);
  z-index: 330;
  border: 1px solid rgba(116, 137, 176, 0.38);
  border-radius: 14px;
  overflow: hidden;
  isolation: isolate;
  box-shadow:
    0 0 0 100vmax rgba(16, 24, 40, 0.22),
    0 0 0 1px rgba(255, 255, 255, 0.9),
    0 18px 34px rgba(15, 23, 42, 0.12),
    0 34px 72px rgba(15, 23, 42, 0.18);
  background: #ffffff;
}

.manual-edit-rephrase {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.manual-edit-rephrase-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.manual-edit-rephrase-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.manual-rephrase-button {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.manual-rephrase-button:hover,
.manual-rephrase-button:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.counter,
.status {
  color: var(--muted);
  font-size: 0.9rem;
}

.status {
  margin: 0;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status.status-actionable {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.status-action-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.status-action-button:hover,
.status-action-button:focus-visible {
  text-decoration: underline;
}

.counter {
  justify-self: end;
}

.advanced {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.advanced summary {
  padding: 15px 16px;
  cursor: pointer;
  color: var(--text);
  font-weight: 800;
}

.advanced-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  padding: 0 16px 16px;
}

.advanced textarea {
  min-height: 86px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.action-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
}

.cookie-disclaimer {
  margin: 0;
  color: var(--muted);
  opacity: 0.84;
  font-size: 0.76rem;
  line-height: 1.4;
  letter-spacing: 0.01em;
  text-align: center;
}

.cookie-disclaimer a {
  color: inherit;
  text-underline-offset: 2px;
}

.cookie-inline-button {
  border: 0;
  padding: 0;
  margin-left: 8px;
  color: inherit;
  background: transparent;
  font-size: inherit;
  line-height: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.cookie-banner {
  position: fixed;
  right: 14px;
  bottom: 14px;
  width: min(420px, calc(100vw - 28px));
  padding: 12px 12px 10px;
  border: 1px solid #e2e9f7;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 38px rgba(33, 63, 126, 0.16);
  z-index: 110;
}

.cookie-banner-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.cookie-banner-text a {
  color: var(--text);
  text-underline-offset: 2px;
}

.cookie-banner-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.cookie-banner-actions .ghost-button,
.cookie-banner-actions .mini-button {
  height: 34px;
  padding: 0 12px;
  font-size: 0.8rem;
}


.history-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.26);
  z-index: 70;
}

.history-drawer {
  position: fixed;
  top: calc(var(--topbar-height) + 10px);
  right: 12px;
  width: min(430px, calc(100vw - 24px));
  max-height: calc(100vh - var(--topbar-height) - 22px);
  border: 1px solid #dde6f6;
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 20px 50px rgba(35, 66, 134, 0.2);
  overflow: hidden;
  z-index: 80;
  transform: translateX(calc(100% + 16px));
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.history-drawer.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.history-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.history-drawer-close {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  font-size: 1rem;
}

.history-content {
  padding: 0 16px 16px;
  max-height: calc(100vh - var(--topbar-height) - 120px);
  overflow: auto;
}

.model-settings-drawer {
  width: min(480px, calc(100vw - 24px));
}

.model-settings-title-wrap {
  display: grid;
  gap: 4px;
}

.model-settings-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.model-settings-content {
  display: grid;
  gap: 14px;
}

.model-settings-grid {
  display: grid;
  gap: 14px;
  padding-top: 10px;
}

.model-settings-field {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 650;
}

.model-settings-field select {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
}

.model-settings-field select:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(125, 166, 255, 0.18);
}

.model-settings-description {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.45;
  min-height: 2.2em;
}

.model-settings-plan {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 0.84rem;
}

.model-settings-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.history-heading-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 10px;
  padding-top: 10px;
}

.history-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 750;
  color: var(--text);
}

.history-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.history-list {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.history-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
}

.history-summary::-webkit-details-marker {
  display: none;
}

.history-summary-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}

.history-summary-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
  color: var(--muted);
}

.history-summary-meta {
  font-size: 0.78rem;
  color: var(--muted);
}

.history-body {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
  border-top: 1px solid var(--line);
}

.history-body-row {
  font-size: 0.86rem;
  color: var(--text);
}

.history-body-row pre {
  margin: 6px 0 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.8rem;
}

.history-use-button {
  justify-self: start;
}

.history-actions {
  display: flex;
  justify-content: center;
}

.history-item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.history-delete-button {
  border-color: #f3c7c7;
  color: #8d1f1f;
  background: #fff5f5;
}

.history-delete-button:hover,
.history-delete-button:focus-visible {
  border-color: #e5a8a8;
  background: #ffeaea;
}

.primary-button {
  min-width: 142px;
  height: 48px;
  padding: 0 22px;
  border-color: var(--brand-logo-blue-strong);
  background: linear-gradient(135deg, #3f7af0 0%, #2f6de5 56%, #235bc6 100%);
  color: #ffffff;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(47, 109, 229, 0.3);
}

.primary-button:hover {
  background: linear-gradient(135deg, #4882f2 0%, #3069d5 100%);
}

.primary-button:disabled,
.mini-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.hidden {
  display: none;
}

.policy-shell {
  width: min(900px, calc(100vw - 28px));
  margin: 22px auto 44px;
}

.policy-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.policy-card h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

.policy-card h2 {
  margin: 20px 0 8px;
  font-size: 1.1rem;
}

.policy-card h3 {
  margin: 16px 0 8px;
  font-size: 0.96rem;
}

.policy-updated {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.84rem;
}

.policy-card p {
  margin: 0 0 10px;
  color: var(--text);
  line-height: 1.5;
}

.policy-table {
  width: 100%;
  margin: 10px 0 4px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.policy-table th,
.policy-table td {
  padding: 9px 10px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.policy-table th {
  background: var(--panel-soft);
  font-weight: 700;
}

.policy-backlink {
  margin-top: 18px;
}

@media (max-width: 900px) {
  .option-sidebar {
    overflow-x: auto;
    scrollbar-width: thin;
    padding: 8px;
  }

  .panes {
    min-height: clamp(420px, calc(100dvh - 300px), 680px);
  }

  .history-drawer {
    top: 12px;
    right: 12px;
    max-height: calc(100vh - 24px);
  }

  .policy-shell {
    width: min(100vw - 20px, 900px);
  }

  .policy-card {
    padding: 16px;
  }
}

@media (max-width: 760px) {
  :root {
    --topbar-height: 108px;
    --layout-offset: 28px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 16px;
  }

  .account {
    width: 100%;
    justify-content: space-between;
  }

  .shell {
    width: min(100vw - 20px, 1180px);
    margin-top: 12px;
    min-height: 0;
  }

  .translator {
    padding: 14px;
    border-radius: 16px;
  }

  .pane-swap-button {
    display: none;
  }

  .panes,
  .advanced-grid {
    grid-template-columns: 1fr;
  }

  .panes {
    min-height: 0;
  }

  .pane-language-strip,
  .pane-content {
    padding-left: 14px;
    padding-right: 14px;
  }

  .pane-language-select--inline {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  textarea,
  .output-text {
    min-height: 170px;
  }

  #inputText {
    height: auto;
    min-height: 170px;
  }

  .translator-layout {
    min-height: 0;
  }

  .input-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .footer-status {
    font-size: 0.84rem;
  }

  .primary-button {
    width: 100%;
  }

  .cookie-banner {
    right: 10px;
    left: 10px;
    bottom: 10px;
    width: auto;
  }
}
