:root {
  --bg: #f6f2eb;
  --paper: #fffdf8;
  --paper-strong: #ffffff;
  --ink: #17212b;
  --muted: #68717c;
  --line: #ded6c9;
  --teal: #0f766e;
  --teal-deep: #115e59;
  --amber: #b45309;
  --rose: #9f1239;
  --green: #166534;
  --shadow: 0 18px 45px rgba(35, 31, 27, 0.11);
  --radius: 8px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.78), rgba(246, 242, 235, 0.96)),
    var(--bg);
  font-family:
    "Inter", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  line-height: 1.55;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 4vw, 42px);
  border-bottom: 1px solid rgba(222, 214, 201, 0.76);
  background: rgba(255, 253, 248, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff9ed;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(23, 33, 43, 0.18);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1rem;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
}

.top-actions,
.result-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  white-space: nowrap;
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.icon-button svg,
.heading-icon svg,
.empty-state svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.icon-button:hover {
  transform: translateY(-1px);
}

.icon-button:active {
  transform: translateY(0);
}

.icon-button.primary {
  color: #fff;
  background: var(--teal);
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.22);
}

.icon-button.primary:hover {
  background: var(--teal-deep);
}

.icon-button:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.icon-button.is-loading svg {
  animation: spin 0.9s linear infinite;
}

.icon-button.ghost {
  color: var(--ink);
  border-color: rgba(222, 214, 201, 0.9);
  background: rgba(255, 253, 248, 0.86);
}

.icon-button.ghost:hover {
  border-color: #c8bda8;
  background: #fff;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.workspace-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.88fr);
  gap: 24px;
  min-height: 330px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(26px, 5vw, 54px);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--amber);
  font-size: 0.86rem;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(2.15rem, 6vw, 4.5rem);
  line-height: 1.03;
  letter-spacing: 0;
}

.hero-copy > p:not(.eyebrow) {
  max-width: 660px;
  margin-bottom: 26px;
  color: #3f4852;
  font-size: 1.02rem;
}

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

.hero-stats div {
  min-height: 76px;
  padding: 13px 12px;
  border: 1px solid rgba(222, 214, 201, 0.82);
  border-radius: var(--radius);
  background: rgba(246, 242, 235, 0.72);
}

.hero-stats dt {
  color: var(--teal-deep);
  font-size: 1.35rem;
  font-weight: 800;
}

.hero-stats dd {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.hero-image {
  width: 100%;
  height: 100%;
  min-height: 330px;
  object-fit: cover;
}

.value-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.value-strip div {
  min-height: 78px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.78);
}

.value-strip span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.value-strip strong {
  display: block;
  margin-top: 5px;
  font-size: 1rem;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(330px, 0.42fr) minmax(0, 0.58fr);
  gap: 18px;
  align-items: stretch;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.92);
  box-shadow: 0 14px 30px rgba(35, 31, 27, 0.08);
}

.main-grid > * {
  min-width: 0;
}

.composer,
.result-panel {
  padding: 22px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  margin-bottom: 20px;
}

.result-heading {
  align-items: center;
}

.panel-heading h2 {
  margin-bottom: 2px;
  font-size: 1.05rem;
}

.panel-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.heading-icon {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  color: var(--teal-deep);
  background: #e6f3ef;
}

.heading-icon.accent {
  color: var(--amber);
  background: #fbecd8;
}

.control-group {
  padding: 0;
  margin: 0 0 18px;
  border: 0;
}

.control-group legend,
.field > span {
  display: block;
  margin-bottom: 9px;
  color: #39434d;
  font-size: 0.9rem;
  font-weight: 750;
}

.control-group.compact {
  margin-top: 2px;
}

.segmented,
.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segmented button,
.chip-grid button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #d6cdbd;
  border-radius: 999px;
  color: #42505c;
  background: #fffaf0;
  transition:
    background 0.16s ease,
    color 0.16s ease,
    border-color 0.16s ease,
    transform 0.16s ease;
}

.segmented button:hover,
.chip-grid button:hover {
  transform: translateY(-1px);
  border-color: #b9ab95;
}

.segmented button[aria-pressed="true"],
.chip-grid button[aria-pressed="true"] {
  border-color: rgba(15, 118, 110, 0.22);
  color: #fff;
  background: var(--teal);
}

.tone-group button[aria-pressed="true"]:nth-child(2) {
  background: var(--amber);
  border-color: rgba(180, 83, 9, 0.25);
}

.tone-group button[aria-pressed="true"]:nth-child(3) {
  background: var(--rose);
  border-color: rgba(159, 18, 57, 0.24);
}

.two-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: block;
  margin-bottom: 18px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #d8cebf;
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--paper-strong);
  outline: none;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 142px;
  padding: 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.field small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.78rem;
}

.result-panel {
  display: flex;
  min-height: 650px;
  flex-direction: column;
}

.result-heading {
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(222, 214, 201, 0.7);
}

.result-heading > div:nth-child(2) {
  flex: 1;
  min-width: 210px;
}

.result-primary-actions {
  justify-content: flex-end;
  margin-left: auto;
}

.empty-state {
  display: grid;
  flex: 1;
  min-height: 420px;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 34px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed #d2c5b2;
  border-radius: var(--radius);
  background: rgba(246, 242, 235, 0.62);
}

.empty-state svg {
  width: 46px;
  height: 46px;
  color: var(--teal);
}

.empty-state strong {
  color: var(--ink);
  font-size: 1.02rem;
}

.empty-state p {
  max-width: 420px;
  margin: 0;
}

.speech-output {
  flex: 1;
  min-height: 420px;
  padding: 26px;
  overflow: auto;
  border: 1px solid #e4dac9;
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(180, 83, 9, 0.05), transparent 22%),
    #fffefa;
  color: #26313a;
  font-family: "Noto Serif SC", "Songti SC", SimSun, serif;
  font-size: 1.02rem;
  line-height: 1.9;
  white-space: pre-wrap;
}

.speech-output h3 {
  margin: 0 0 16px;
  color: var(--teal-deep);
  font-family:
    "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 1.2rem;
  line-height: 1.35;
}

.quality-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.quality-bar span {
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  color: #47515d;
  background: #f1eadf;
  font-size: 0.8rem;
}

.quality-bar span.pass {
  color: var(--green);
  background: #e7f4e7;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: var(--radius);
  color: #083d3a;
  background: #e8f7f3;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

@media (max-width: 960px) {
  .workspace-hero,
  .main-grid {
    grid-template-columns: 1fr;
  }

  .hero-image {
    min-height: 260px;
    max-height: 360px;
  }

  .value-strip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  main {
    width: min(100% - 22px, 1180px);
    padding-top: 14px;
  }

  .workspace-hero {
    min-height: 0;
  }

  .workspace-hero,
  .value-strip {
    gap: 10px;
  }

  .hero-copy,
  .composer,
  .result-panel {
    padding: 18px;
  }

  .hero-copy {
    padding-bottom: 12px;
  }

  .hero-copy > p:not(.eyebrow) {
    margin-bottom: 16px;
    font-size: 0.95rem;
  }

  h1 {
    font-size: 2.7rem;
    margin-bottom: 10px;
  }

  .hero-stats,
  .two-cols {
    grid-template-columns: 1fr;
  }

  .hero-image {
    min-height: 180px;
    max-height: 220px;
  }

  .hero-stats div,
  .value-strip div {
    min-height: 62px;
    padding: 12px;
  }

  .result-panel {
    min-height: auto;
  }

  .speech-output {
    min-height: 320px;
    padding: 18px;
  }

  .result-heading {
    align-items: flex-start;
  }

  .result-primary-actions,
  .result-actions {
    width: 100%;
  }

  .result-primary-actions .icon-button,
  .result-actions .icon-button {
    flex: 1 1 74px;
    padding-inline: 8px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .workspace-hero,
  .value-strip,
  .composer,
  .result-actions,
  .quality-bar,
  .toast {
    display: none !important;
  }

  main,
  .main-grid,
  .result-panel {
    display: block;
    width: auto;
    padding: 0;
    margin: 0;
    border: 0;
    box-shadow: none;
  }

  .speech-output {
    display: block !important;
    min-height: 0;
    padding: 0;
    border: 0;
    background: #fff;
    color: #000;
  }
}
