:root {
  color-scheme: light;
  --ink: #15191f;
  --muted: #6d7680;
  --line: #e0e6ec;
  --paper: #f7f9fb;
  --panel: #ffffff;
  --brand: #2563eb;
  --brand-dark: #1747ad;
  --green: #15a06f;
  --gold: #c88a20;
  --navy: #101820;
  --brand-gradient: linear-gradient(135deg, #2563eb 0%, #15a06f 100%);
  --soft-yellow: rgba(255, 218, 92, 0.22);
  --shadow: 0 24px 80px rgba(24, 32, 44, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 8%, rgba(200, 138, 32, 0.13), transparent 25%),
    radial-gradient(circle at 88% 4%, rgba(21, 160, 111, 0.12), transparent 27%),
    linear-gradient(180deg, #ffffff 0%, var(--paper) 44%);
  color: var(--ink);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(120deg, rgba(37, 99, 235, 0.06), transparent 34%),
    linear-gradient(300deg, rgba(21, 160, 111, 0.08), transparent 38%),
    linear-gradient(180deg, rgba(16, 24, 32, 0.03), transparent 40%);
}

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

.page {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 48px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 56px;
  padding: 8px 0;
}

.brand,
.header nav,
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  position: relative;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--green));
  font-weight: 900;
}

.brand-mark b {
  position: relative;
  z-index: 1;
  font-style: normal;
}

.brand-mark i {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 9px;
  height: 9px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-top: 0;
  border-radius: 0 0 999px 999px;
}

.header nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.locale-label {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
}

.compact-locale {
  gap: 0;
}

.locale-label select {
  width: auto;
  min-width: 136px;
  height: 38px;
  border-radius: 999px;
  padding-inline: 14px 34px;
  border-color: rgba(21, 160, 111, 0.22);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 10px 30px rgba(24, 32, 44, 0.06);
}

.intro {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 38px 0 24px;
  text-align: center;
}

.intro p,
.review-card > div:first-child p {
  margin: 0;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.intro h1 {
  margin: 0;
  max-width: 920px;
  font-size: clamp(36px, 6vw, 64px);
  line-height: 1.04;
  letter-spacing: 0;
}

.intro span {
  color: var(--muted);
  font-size: 14px;
}

.business-points {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.business-points span {
  color: #38414a;
  border: 1px solid rgba(16, 24, 32, 0.08);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 10px 24px rgba(24, 32, 44, 0.05);
  font-size: 13px;
  font-weight: 800;
}

.account-strip {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(240px, auto) auto;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid rgba(21, 160, 111, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 16px 42px rgba(24, 32, 44, 0.07);
}

.account-copy {
  display: grid;
  gap: 3px;
}

.account-copy strong {
  font-size: 15px;
}

.account-copy span,
.usage-pill {
  color: var(--muted);
  font-size: 13px;
}

.account-controls,
.plan-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-controls input {
  width: 210px;
  height: 40px;
}

.account-controls .code-input {
  width: 132px;
  text-align: center;
  letter-spacing: 0;
}

.compact-button,
.plan-button {
  min-height: 40px;
  white-space: nowrap;
}

.inline-auth-button {
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.compact-button {
  width: auto;
  padding: 0 14px;
}

.plan-pill,
.usage-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(21, 160, 111, 0.1);
  color: var(--green);
  font-weight: 900;
}

.usage-pill {
  background: rgba(37, 99, 235, 0.08);
  color: var(--brand-dark);
}

.plan-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 16px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  font-weight: 900;
}

.primary-plan {
  border: 0;
  color: #fff;
  background: var(--brand-gradient);
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.16);
}

.plan-button:disabled,
.compact-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  filter: grayscale(0.2);
}

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

.panel,
.review-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.panel {
  min-height: 500px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-label {
  display: flex;
  align-items: center;
  gap: 12px;
}

.panel-label > span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: var(--navy);
  font-size: 13px;
  font-weight: 900;
}

.panel-label strong {
  display: block;
  color: var(--ink);
  font-size: 16px;
}

.panel-label small {
  color: var(--muted);
  font-size: 13px;
}

.panel-top,
.actions,
.voice-row,
.mini-metrics {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

label {
  display: grid;
  flex: 1;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

select,
input {
  height: 44px;
  padding: 0 12px;
}

textarea {
  flex: 1;
  min-height: 330px;
  padding: 18px;
  resize: none;
  border: 1px solid rgba(16, 24, 32, 0.04);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(245, 248, 251, 0.92)),
    repeating-linear-gradient(180deg, transparent 0 34px, rgba(16, 24, 32, 0.025) 34px 35px);
  font-size: 18px;
  line-height: 1.72;
}

.paragraph-view {
  flex: 1;
  min-height: 330px;
  overflow: auto;
}

.source-paragraphs {
  padding: 10px;
  border-radius: 10px;
  background: linear-gradient(180deg, #fbfdff, #f5f8fb);
  cursor: text;
}

.aligned-paragraph {
  margin: 0 0 18px;
  border-radius: 8px;
  transition: background-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.aligned-paragraph:last-child {
  margin-bottom: 0;
}

.source-aligned {
  padding: 14px 16px;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.72;
}

.source-aligned.is-linked-highlight {
  background: var(--soft-yellow);
  box-shadow: inset 3px 0 0 rgba(230, 170, 20, 0.42);
}

textarea::-webkit-scrollbar {
  width: 10px;
}

textarea::-webkit-scrollbar-thumb {
  border: 3px solid #f8fafc;
  border-radius: 999px;
  background: #cbd5df;
}

.secondary-button,
.primary-button,
.icon-button {
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 900;
}

.secondary-button {
  min-height: 42px;
  color: var(--muted);
  background: #eef3f8;
}

.primary-button {
  flex: 1;
  min-height: 50px;
  color: #fff;
  position: relative;
  overflow: hidden;
  background: var(--brand-gradient);
  box-shadow: 0 14px 34px rgba(37, 99, 235, 0.24);
}

.primary-button:hover {
  filter: saturate(1.08) brightness(1.02);
  transform: translateY(-1px);
}

.primary-button:disabled,
.icon-button:disabled {
  cursor: wait;
  opacity: 0.92;
}

.primary-button.is-loading {
  animation: buttonBreath 1.45s ease-in-out infinite;
}

.primary-button.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.24), transparent);
  transform: translateX(-120%);
  animation: buttonSheen 1.45s ease-in-out infinite;
}

.secondary-button {
  width: 90px;
}

.helper-text {
  min-height: 0;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.helper-text:empty {
  display: none;
}

.result-panel {
  border-color: rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 30%),
    radial-gradient(circle at 80% 10%, rgba(21, 160, 111, 0.16), transparent 32%),
    var(--navy);
  color: #fff;
}

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

.result-panel .panel-top span,
.result-panel h2 {
  color: rgba(255, 255, 255, 0.72);
}

.result-panel .panel-top strong {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--green), #4fb181);
  font-size: 20px;
}

#translatedText {
  flex: 1;
  min-height: 360px;
  max-height: 620px;
  overflow: auto;
  margin: 0;
  padding: 18px 4px 8px;
  font-size: 21px;
  line-height: 1.78;
}

.translated-aligned {
  padding: 14px 16px;
  color: rgba(255, 255, 255, 0.94);
  background: rgba(255, 255, 255, 0.035);
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.08);
}

.translated-aligned:hover {
  background: rgba(255, 255, 255, 0.07);
  transform: translateX(2px);
}

.translation-loading {
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 16px;
  font-weight: 800;
}

.translation-loading span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  animation: loadingDot 1.1s ease-in-out infinite;
}

.translation-loading span:nth-child(2) {
  animation-delay: 0.16s;
}

.translation-loading span:nth-child(3) {
  animation-delay: 0.32s;
}

.mini-metrics {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.mini-metrics span {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.74);
}

@keyframes buttonBreath {
  0%, 100% {
    box-shadow: 0 14px 34px rgba(37, 99, 235, 0.24), 0 0 0 rgba(21, 160, 111, 0);
    transform: translateY(0) scale(1);
  }
  50% {
    box-shadow: 0 18px 46px rgba(21, 160, 111, 0.34), 0 0 0 7px rgba(21, 160, 111, 0.1);
    transform: translateY(-1px) scale(1.01);
  }
}

@keyframes buttonSheen {
  0% {
    transform: translateX(-120%);
  }
  65%, 100% {
    transform: translateX(120%);
  }
}

@keyframes loadingDot {
  0%, 80%, 100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-5px);
  }
}

.mini-metrics strong {
  color: #fff;
}

.icon-button {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: var(--green);
}

.icon-button span {
  width: 0;
  height: 0;
  margin-left: 3px;
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
  border-left: 16px solid #fff;
}

.text-button,
.download-button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.download-button.disabled {
  pointer-events: none;
  opacity: 0.48;
}

.voice-row select,
.result-panel input {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.result-panel input::placeholder {
  color: rgba(255, 255, 255, 0.48);
}

.switch {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.82);
}

.switch em {
  font-style: normal;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
}

.switch span {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  position: relative;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s ease;
}

.switch input:checked + span {
  background: var(--green);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

#voiceTitle {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

#audioPlayer {
  width: 100%;
}

.review-card {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 20px;
  margin-top: 16px;
  padding: 20px;
}

.review-card h2 {
  margin: 6px 0 0;
}

.review-list {
  display: grid;
  gap: 8px;
}

.review-list p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.review-list strong {
  margin-right: 6px;
  color: var(--ink);
}

.hidden-controls,
.workflow-map {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(10, 15, 22, 0.52);
}

.modal-backdrop[hidden] {
  display: none;
}

.voice-modal {
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 44px));
  overflow: auto;
  padding: 22px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.28);
}

.modal-top,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.modal-top p {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.modal-top h2 {
  margin: 0;
}

.close-button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink);
  background: #eef3f8;
  font-size: 26px;
}

.voice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 22px 0 14px;
}

.custom-voice {
  margin-bottom: 14px;
}

.modal-switch {
  color: var(--ink);
  margin-bottom: 18px;
}

.modal-switch span {
  background: #cbd5df;
}

.modal-actions .primary-button {
  flex: 1;
}

.voice-modal #voiceTitle {
  margin-top: 16px;
  color: var(--muted);
}

.voice-modal #audioPlayer {
  margin-top: 14px;
}

@media (max-width: 860px) {
  .account-strip {
    grid-template-columns: 1fr;
  }

  .account-controls,
  .plan-actions {
    width: 100%;
  }

  .account-controls input {
    width: 100%;
  }

  .plan-button {
    flex: 1;
  }

  .translator,
  .review-card {
    grid-template-columns: 1fr;
  }

  .intro {
    padding-top: 34px;
  }

  .panel {
    min-height: auto;
  }

  #translatedText {
    min-height: 260px;
  }

  textarea {
    min-height: 230px;
  }
}

@media (max-width: 560px) {
  .page {
    width: min(100% - 24px, 1180px);
    padding-top: 12px;
  }

  .header {
    align-items: flex-start;
    gap: 14px;
    flex-direction: column;
  }

  .header nav {
    display: none;
  }

  .header-actions {
    width: 100%;
  }

  .locale-label,
  .locale-label select {
    width: 100%;
  }

  .panel-top,
  .voice-row,
  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .result-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

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