/* 日落主題：深橙 → 洋紅 → 深紫 */
:root {
  --cream: #fff8ed;
  --cream-muted: rgba(255, 248, 237, 0.82);
  --flame: #ffc107;
  --flame-hot: #ff9100;
  --accent-ring: rgba(255, 193, 7, 0.55);
  --surface: rgba(26, 10, 46, 0.45);
  --surface-strong: rgba(45, 18, 62, 0.72);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --radius: 20px;
  --tap-min: 48px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--cream);
  background: linear-gradient(
    165deg,
    #c2410c 0%,
    #d9468f 38%,
    #7c1d6e 72%,
    #1e0a2e 100%
  );
  background-attachment: fixed;
  line-height: 1.55;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 1.75rem);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

header {
  text-align: center;
  padding-top: 0.25rem;
}

header h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.35rem, 5vw, 1.75rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.25);
}

header p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--cream-muted);
}

.panel {
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  border: 1px solid rgba(255, 200, 120, 0.18);
  box-shadow: var(--shadow);
}

.panel label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.45rem;
  color: var(--flame);
  letter-spacing: 0.06em;
}

select {
  width: 100%;
  min-height: var(--tap-min);
  padding: 0.65rem 2.25rem 0.65rem 0.85rem;
  font-size: 1rem;
  font-family: inherit;
  color: #2d0a1f;
  background: linear-gradient(180deg, #fff3d6 0%, #ffe0b2 100%);
  border: 2px solid var(--flame-hot);
  border-radius: 14px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='%23c2410c'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  box-shadow: 0 4px 0 rgba(194, 65, 12, 0.35);
}

select:focus {
  outline: 3px solid var(--accent-ring);
  outline-offset: 2px;
}

.status-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  min-height: 3rem;
  padding: 0.65rem 1rem;
  border-radius: 16px;
  font-weight: 700;
  font-size: clamp(0.95rem, 3.5vw, 1.05rem);
  text-align: center;
  transition: background 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
}

.status-banner[data-state="idle"] {
  background: var(--surface-strong);
  border: 1px solid rgba(255, 193, 7, 0.25);
}

.status-banner[data-state="listening"] {
  background: linear-gradient(135deg, rgba(255, 152, 0, 0.45), rgba(255, 87, 34, 0.5));
  border: 2px solid var(--flame);
  box-shadow: 0 0 24px var(--accent-ring);
  animation: pulse-banner 1.2s ease-in-out infinite;
}

.status-banner[data-state="processing"] {
  background: linear-gradient(135deg, rgba(156, 39, 176, 0.5), rgba(233, 30, 99, 0.45));
  border: 2px solid #e1bee7;
}

.status-banner[data-state="done"] {
  background: linear-gradient(135deg, rgba(76, 175, 80, 0.35), rgba(139, 195, 74, 0.4));
  border: 2px solid #c5e1a5;
}

@keyframes pulse-banner {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cream-muted);
  flex-shrink: 0;
}

.status-banner[data-state="listening"] .status-dot {
  background: var(--flame);
  box-shadow: 0 0 12px var(--flame);
  animation: blink 0.8s ease-in-out infinite;
}

.status-banner[data-state="processing"] .status-dot {
  background: #e1bee7;
  animation: blink 1s ease-in-out infinite;
}

.status-banner[data-state="done"] .status-dot {
  background: #aed581;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.progress-wrap {
  margin-top: 0.25rem;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8rem;
  color: var(--cream-muted);
  margin-bottom: 0.35rem;
}

.progress-label strong {
  color: var(--flame);
  font-size: 0.9rem;
}

.progress-track {
  height: 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
  border: 1px solid rgba(255, 193, 7, 0.35);
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--flame-hot), var(--flame), #ffeb3b);
  transition: width 0.35s ease;
  box-shadow: 0 0 16px rgba(255, 193, 7, 0.6);
}

.progress-fill.indeterminate {
  width: 40%;
  animation: indet 1.1s ease-in-out infinite;
}

@keyframes indet {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(350%);
  }
}

.text-blocks {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  flex: 1;
}

.text-block h2 {
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--flame);
}

.text-block .box {
  min-height: 4.5rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: var(--surface-strong);
  border: 1px solid rgba(255, 236, 200, 0.15);
  font-size: 1rem;
  word-break: break-word;
  white-space: pre-wrap;
}

.text-block .box.placeholder {
  color: var(--cream-muted);
  font-style: italic;
}

.hold-hint {
  text-align: center;
  font-size: 0.88rem;
  color: var(--cream-muted);
  margin: 0.25rem 0 0;
}

.ios-hint {
  margin: 0.65rem 0 0;
  padding: 0.65rem 0.75rem;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--cream);
  background: rgba(255, 152, 0, 0.22);
  border: 1px solid rgba(255, 213, 79, 0.45);
  border-radius: 12px;
  text-align: left;
}

.translate-btn-wrap {
  position: sticky;
  bottom: 0;
  padding: 0.75rem 0 calc(0.75rem + env(safe-area-inset-bottom, 0px));
  margin-top: auto;
}

.translate-btn {
  width: 100%;
  min-height: clamp(64px, 18vw, 88px);
  border: none;
  border-radius: 22px;
  font-family: inherit;
  font-size: clamp(1.1rem, 4vw, 1.35rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #3d1300;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  background: linear-gradient(180deg, #ffca28 0%, var(--flame-hot) 55%, #e65100 100%);
  box-shadow:
    0 6px 0 #bf360c,
    0 12px 28px rgba(0, 0, 0, 0.4);
  transition:
    transform 0.08s ease,
    box-shadow 0.08s ease,
    filter 0.15s ease;
}

.translate-btn:active,
.translate-btn.is-pressed {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 #bf360c,
    0 8px 20px rgba(0, 0, 0, 0.35);
  filter: brightness(1.05);
}

.translate-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  filter: grayscale(0.2);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.translate-btn:focus-visible {
  outline: 3px solid var(--cream);
  outline-offset: 4px;
}

.translate-btn .sub {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  opacity: 0.9;
}

.error-toast {
  margin: 0;
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  background: rgba(183, 28, 28, 0.55);
  border: 1px solid #ef9a9a;
  color: #ffebee;
  font-size: 0.88rem;
  display: none;
}

.error-toast.visible {
  display: block;
}

@media (min-width: 480px) {
  .text-blocks {
    flex-direction: row;
    align-items: stretch;
  }

  .text-blocks .text-block {
    flex: 1;
    min-width: 0;
  }
}
