:root {
  --blue: #2563eb;
  --teal: #34d399;
  --ink: #0f172a;
  --muted: #64748b;
  --card: rgba(255, 255, 255, 0.92);
  --line: #e2e8f0;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
  font-family: "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #f8fafc;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 420px at 12% -10%, rgba(37, 99, 235, 0.18), transparent 60%),
    radial-gradient(700px 380px at 100% 0%, rgba(52, 211, 153, 0.16), transparent 55%),
    linear-gradient(180deg, #eef4ff 0%, #f8fafc 42%, #f1f5f9 100%);
}

.hero {
  text-align: center;
  padding: 2.4rem 1.25rem 0.5rem;
}

.logo {
  width: min(280px, 72vw);
  height: auto;
  display: block;
  margin: 0 auto 0.75rem;
  filter: drop-shadow(0 8px 24px rgba(15, 23, 42, 0.12));
}

.tagline {
  margin: 0;
  font-size: clamp(1.15rem, 2.4vw, 1.45rem);
  font-weight: 650;
  letter-spacing: 0.02em;
}

.panel {
  width: min(1100px, calc(100% - 2rem));
  margin: 1.25rem auto 2rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr 1.15fr;
}

@media (max-width: 900px) {
  .panel { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.15rem 1.2rem 1.25rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.card h2 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
  color: var(--muted);
  font-weight: 600;
}

.out-help {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.75rem;
}

.text-label-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem 0.65rem;
}

.text-label .hint {
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--muted);
}

input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

textarea { resize: vertical; min-height: 6rem; }

.row {
  display: flex;
  gap: 0.75rem;
}

.grow { flex: 1; min-width: 0; }

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.25rem;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 1.15rem;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

button.primary {
  background: linear-gradient(135deg, var(--blue), #1d4ed8);
  color: #fff;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.28);
}

button.primary:disabled {
  opacity: 0.55;
  cursor: wait;
}

button.ghost {
  background: #fff;
  color: #334155;
  border: 1px solid var(--line);
}

.status {
  min-height: 1.35rem;
  margin: 0.85rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.status.err { color: #dc2626; }
.status.ok { color: #047857; }

.history-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

@media (max-width: 640px) {
  .history-split { grid-template-columns: 1fr; }
}

.history-col h3 {
  margin: 0 0 0.55rem;
  font-size: 0.9rem;
  font-weight: 650;
  color: var(--ink);
}

.history {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: min(62vh, 560px);
  overflow: auto;
  padding-right: 0.15rem;
  min-height: 4.5rem;
}

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

.history-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.75rem 0.8rem;
  background: #fff;
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.history-text {
  margin: 0 0 0.55rem;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-item audio {
  width: 100%;
  display: block;
}

footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0 1rem 2rem;
  color: var(--muted);
  font-size: 0.82rem;
}

footer img {
  opacity: 0.85;
  object-fit: contain;
}
