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

:root {
  --bg: #f0f2f8;
  --surface: #ffffff;
  --surface2: #f5f6fb;
  --border: rgba(0,0,0,0.07);
  --border2: rgba(0,0,0,0.13);
  --text: #1a1a2e;
  --text2: #5a5a7a;
  --text3: #9898b8;
  --accent: #5b4de8;
  --accent-bg: rgba(91,77,232,0.08);
  --teal: #0d9e78;
  --teal-bg: rgba(13,158,120,0.08);
  --red: #e03e3e;
  --red-bg: rgba(224,62,62,0.08);
  --amber: #c97c10;
  --amber-bg: rgba(251,191,36,0.12);
  --radius: 14px;
  --radius-sm: 9px;
  --radius-pill: 999px;
  --shadow: 0 2px 12px rgba(80,70,180,0.07);
  --shadow-md: 0 4px 24px rgba(80,70,180,0.11);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 36px 16px 64px;
}

.app { width: 100%; max-width: 680px; }

.header { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.header h1 { font-size: 20px; font-weight: 700; color: var(--text); }
.badge { font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: var(--radius-pill); letter-spacing: 0.04em; transition: all 0.2s; }
.badge-jp { background: rgba(91,77,232,0.1); color: var(--accent); border: 1.5px solid rgba(91,77,232,0.22); }
.badge-en { background: rgba(13,158,120,0.1); color: var(--teal); border: 1.5px solid rgba(13,158,120,0.22); }
.arrow { color: var(--text3); font-size: 16px; }

.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius-sm); padding: 4px; margin-bottom: 14px; width: fit-content; box-shadow: var(--shadow); }
.tab { padding: 7px 22px; border-radius: 7px; border: none; background: transparent; color: var(--text2); font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.15s; font-family: inherit; }
.tab.active { background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(91,77,232,0.25); border: none; }

.dir-row { display: flex; gap: 8px; margin-bottom: 22px; }
.dir-btn { padding: 8px 20px; border-radius: var(--radius-pill); border: 1.5px solid var(--border2); background: var(--surface); color: var(--text2); font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; transition: all 0.15s; box-shadow: var(--shadow); }
.dir-btn:hover { border-color: var(--accent); color: var(--accent); }
.dir-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 2px 10px rgba(91,77,232,0.28); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; box-shadow: var(--shadow-md); }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 11px 16px; border-bottom: 1px solid var(--border); background: var(--surface2); }
.card-label { font-size: 11px; font-weight: 700; color: var(--text3); letter-spacing: 0.08em; text-transform: uppercase; }
.icon-btn { background: var(--surface); border: 1.5px solid var(--border2); border-radius: 7px; color: var(--text2); font-size: 12px; padding: 3px 12px; cursor: pointer; transition: all 0.15s; font-family: inherit; font-weight: 600; }
.icon-btn:hover { background: var(--red-bg); border-color: var(--red); color: var(--red); }

textarea { width: 100%; background: transparent; border: none; padding: 16px; color: var(--text); font-size: 15px; font-family: inherit; resize: none; outline: none; min-height: 100px; line-height: 1.7; }
textarea::placeholder { color: var(--text3); }

.char-row { padding: 6px 16px 12px; }
.char-count { font-size: 12px; color: var(--text3); }

.btn-row { display: flex; gap: 8px; margin-bottom: 16px; }
.btn { padding: 10px 22px; border-radius: var(--radius-sm); border: 1.5px solid var(--border2); background: var(--surface); color: var(--text2); font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; transition: all 0.15s; box-shadow: var(--shadow); }
.btn:hover { background: var(--surface2); color: var(--text); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 3px 14px rgba(91,77,232,0.3); }
.btn.primary:hover { background: #4a3dd4; box-shadow: 0 4px 18px rgba(91,77,232,0.38); }

.voice-panel { padding: 20px 16px; }
.voice-row { display: flex; align-items: center; gap: 16px; }
.mic-btn { width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer; font-size: 24px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all 0.2s; }
.mic-idle { background: var(--accent-bg); color: var(--accent); border: 2px solid rgba(91,77,232,0.2); box-shadow: 0 2px 10px rgba(91,77,232,0.12); }
.mic-listening { background: var(--red-bg); color: var(--red); border: 2px solid rgba(224,62,62,0.3); animation: pulse 1.2s infinite; box-shadow: 0 2px 12px rgba(224,62,62,0.18); }
.mic-processing { background: var(--amber-bg); color: var(--amber); border: 2px solid rgba(201,124,16,0.25); }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.08)} }

.voice-info { flex: 1; }
.voice-status { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.voice-hint { font-size: 12px; color: var(--text3); }
.waveform { display: flex; align-items: center; gap: 3px; height: 28px; margin-top: 6px; }
.wave-bar { width: 3px; background: var(--red); border-radius: 2px; transition: height 0.1s ease; }

.transcript-box { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.transcript-label { font-size: 11px; font-weight: 700; color: var(--text3); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 8px; }
.interim-text { font-size: 14px; color: var(--text2); font-style: italic; min-height: 22px; line-height: 1.5; }

.subtitle-bar {
  background: linear-gradient(135deg, #eef3ff 0%, #e8f4ff 100%);
  border: 1.5px solid rgba(91,77,232,0.18);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 16px;
  min-height: 76px;
  box-shadow: 0 4px 20px rgba(91,77,232,0.08);
}
.sub-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sub-label { font-size: 10px; font-weight: 800; color: var(--accent); letter-spacing: 0.12em; text-transform: uppercase; }
.sub-copy-btn { background: rgba(91,77,232,0.08); border: 1.5px solid rgba(91,77,232,0.2); border-radius: 7px; color: var(--accent); font-size: 12px; padding: 3px 11px; cursor: pointer; font-family: inherit; font-weight: 600; transition: all 0.15s; }
.sub-copy-btn:hover { background: rgba(91,77,232,0.16); }
.sub-text { font-size: 18px; color: var(--text); line-height: 1.55; min-height: 28px; font-weight: 500; }
.sub-text.empty { color: var(--text3); font-size: 14px; font-style: italic; font-weight: 400; }
.loading-dots { display: inline-flex; gap: 5px; align-items: center; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite; }
.dot:nth-child(2){animation-delay:.2s} .dot:nth-child(3){animation-delay:.4s}
@keyframes blink{0%,80%,100%{opacity:.15}40%{opacity:1}}

.history-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-top: 8px; overflow: hidden; box-shadow: var(--shadow); }
.history-box-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface2); }
.history-box-title { font-size: 11px; font-weight: 700; color: var(--text3); letter-spacing: 0.08em; text-transform: uppercase; }
.history-count { font-size: 11px; color: var(--text3); background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius-pill); padding: 2px 9px; }
.history-scroll { height: 260px; overflow-y: auto; padding: 8px; scrollbar-width: thin; scrollbar-color: var(--border2) transparent; }
.history-scroll::-webkit-scrollbar { width: 4px; }
.history-scroll::-webkit-scrollbar-track { background: transparent; }
.history-scroll::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
.history-item { padding: 10px 13px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 6px; cursor: pointer; transition: border-color 0.15s, background 0.15s, box-shadow 0.15s; background: var(--surface); }
.history-item:last-child { margin-bottom: 0; }
.history-item:hover { border-color: rgba(91,77,232,0.25); background: #f8f7ff; box-shadow: 0 2px 8px rgba(91,77,232,0.07); }
.history-item.active-item { border-color: rgba(91,77,232,0.4); background: rgba(91,77,232,0.05); }
.history-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.history-dir-badge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-pill); letter-spacing: 0.04em; }
.dir-badge-jaen { background: rgba(91,77,232,0.09); color: var(--accent); border: 1px solid rgba(91,77,232,0.2); }
.dir-badge-enja { background: rgba(13,158,120,0.09); color: var(--teal); border: 1px solid rgba(13,158,120,0.2); }
.history-time { font-size: 11px; color: var(--text3); }
.history-src { font-size: 12px; color: var(--text2); margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-tl { font-size: 13px; color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-empty { text-align: center; padding: 32px 16px; color: var(--text3); font-size: 13px; }

.error-bar { background: var(--red-bg); border: 1.5px solid rgba(224,62,62,0.25); border-radius: var(--radius-sm); color: var(--red); font-size: 13px; padding: 10px 14px; margin-bottom: 16px; font-weight: 500; }
.free-badge { display: inline-flex; align-items: center; gap: 6px; background: rgba(13,158,120,0.08); border: 1.5px solid rgba(13,158,120,0.2); border-radius: var(--radius-pill); padding: 5px 14px; font-size: 12px; color: var(--teal); margin-bottom: 22px; font-weight: 600; }
