/* ============================================================
   Meeting Recorder Pro — Stylesheet
   Dark theme: bg #1A1A2E | accent #E94560
   ============================================================ */

:root {
  --bg-primary:    #1A1A2E;
  --bg-secondary:  #16213E;
  --bg-tertiary:   #0F3460;
  --accent:        #E94560;
  --accent-dark:   #c73a52;
  --accent-glow:   rgba(233, 69, 96, 0.35);
  --text-primary:  #EAEAEA;
  --text-secondary:#A0A0B8;
  --text-muted:    #60607A;
  --border:        rgba(255,255,255,0.08);
  --surface:       rgba(255,255,255,0.05);
  --success:       #4CAF50;
  --warning:       #FF9800;
  --radius:        12px;
  --radius-lg:     16px;
  --shadow:        0 8px 32px rgba(0,0,0,0.5);
  --transition:    0.2s ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; height: 100%; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang TC',
               'Microsoft JhengHei', 'Noto Sans TC', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ── Header ── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(26, 26, 46, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  user-select: none;
}

.logo-icon { font-size: 1.3rem; }

.header-nav { display: flex; gap: 0.5rem; }

.btn-icon {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 500;
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Main layout ── */
.main {
  max-width: 700px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

/* ── Waveform ── */
.waveform-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.waveform-container {
  width: 100%;
  height: 120px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}

.waveform-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.timer-display {
  font-size: 2.2rem;
  font-weight: 700;
  font-family: 'Courier New', 'SF Mono', monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
  color: var(--text-primary);
  text-shadow: 0 0 20px var(--accent-glow);
}

/* ── Status messages ── */
.status-message {
  font-size: 0.95rem;
  color: var(--text-secondary);
  text-align: center;
  min-height: 1.5em;
  transition: color var(--transition);
}

.status-message.is-error   { color: var(--accent); }
.status-message.is-success { color: var(--success); }
.status-message.is-info    { color: #60a5fa; }

.stt-status {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  min-height: 1.2em;
  letter-spacing: 0.01em;
}

/* ── Record button ── */
.controls-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.btn-record {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  background: none;
  border: none;
  padding: 0;
  position: relative;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-record-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 96px;
  height: 96px;
  border-radius: 50%;
  pointer-events: none;
}

.btn-record-inner {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: background var(--transition), transform var(--transition);
  box-shadow: 0 4px 24px rgba(233, 69, 96, 0.4);
  position: relative;
  z-index: 1;
}

.btn-record:hover .btn-record-inner {
  background: var(--accent-dark);
  transform: scale(1.06);
}

.btn-record:active .btn-record-inner {
  transform: scale(0.96);
}

.btn-record.is-recording .btn-record-inner {
  background: var(--accent-dark);
  animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%   { box-shadow: 0 0 0 0 var(--accent-glow); }
  50%  { box-shadow: 0 0 0 18px rgba(233,69,96,0); }
  100% { box-shadow: 0 0 0 0 rgba(233,69,96,0); }
}

.btn-record-label {
  font-size: 0.88rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  transition: color var(--transition);
}

.btn-record.is-recording .btn-record-label {
  color: var(--accent);
}

/* ── Audio Player ── */
.audio-player-section {
  width: 100%;
  max-width: 600px;
  animation: fade-in 0.3s ease;
}

.audio-player {
  width: 100%;
  height: 44px;
  border-radius: var(--radius);
  outline: none;
}

/* Invert colors for dark theme compatibility */
@supports (filter: invert(1)) {
  .audio-player {
    filter: invert(1) hue-rotate(180deg) brightness(0.85) saturate(1.2);
  }
}

/* ── Transcript ── */
.transcript-section {
  width: 100%;
  max-width: 600px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: fade-in 0.3s ease;
}

.transcript-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.transcript-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.transcript-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-action:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.transcript-content {
  padding: 1.25rem;
  min-height: 140px;
  max-height: 340px;
  overflow-y: auto;
  outline: none;
  line-height: 1.85;
  font-size: 0.95rem;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  transition: background var(--transition);
}

.transcript-content:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
  display: block;
}

.transcript-content:focus {
  background: rgba(255,255,255,0.025);
}

/* Live recording indicator */
.transcript-section.is-live {
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  animation: live-pulse 2s ease-in-out infinite;
}

.transcript-section.is-live .transcript-title::after {
  content: '● 即時辨識中';
  margin-left: 0.6rem;
  font-size: 0.75rem;
  color: var(--accent);
  animation: live-blink 1s step-end infinite;
  font-weight: 400;
}

@keyframes live-pulse {
  0%, 100% { border-color: var(--accent); box-shadow: 0 0 0 0 rgba(233,69,96,0); }
  50% { border-color: rgba(233,69,96,0.5); box-shadow: 0 0 8px 0 rgba(233,69,96,0.15); }
}

@keyframes live-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ── Summary Section ── */
.summary-section {
  margin-top: 1.5rem;
  padding: 0 1.2rem;
}

.summary-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  color: var(--text-primary);
  line-height: 1.7;
  font-size: 0.92rem;
}

.summary-stats {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.6rem 0.8rem;
  background: rgba(233,69,96,0.08);
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.summary-block {
  margin-bottom: 1rem;
}

.summary-block h4 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: var(--accent);
  font-weight: 600;
}

.summary-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.summary-tag {
  display: inline-block;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.2rem 0.7rem;
  font-size: 0.82rem;
  color: var(--text-primary);
}

.summary-tag small {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.summary-list {
  margin: 0;
  padding-left: 1.2rem;
  list-style: disc;
}

.summary-list li {
  margin-bottom: 0.4rem;
  line-height: 1.6;
  color: var(--text-primary);
}

.summary-actions li {
  list-style: '☐ ';
}

.summary-actions li::marker {
  font-size: 1rem;
}

/* ── Modals ── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.72);
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal.is-active { display: flex; }

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  animation: modal-slide-in 0.22s ease;
}

.modal-content-wide { max-width: 620px; }

@keyframes modal-slide-in {
  from { opacity: 0; transform: scale(0.95) translateY(12px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--surface);
  color: var(--text-primary);
}

.modal-body {
  padding: 1.4rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.4rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Form ── */
.form-group { margin-bottom: 1.2rem; }
.form-group:last-child { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input, .form-select {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-hint {
  display: block;
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  line-height: 1.4;
}

/* Custom select arrow */
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23A0A0B8' stroke-width='2'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  padding-right: 2.2rem;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.radio-option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.radio-option.is-selected {
  border-color: var(--accent);
  background: rgba(233, 69, 96, 0.07);
}

.radio-option input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.radio-label {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.radio-label strong { font-size: 0.875rem; font-weight: 600; }
.radio-label small  { font-size: 0.73rem; color: var(--text-muted); line-height: 1.4; }

/* ── Buttons ── */
.btn-primary {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  transition: background var(--transition), transform var(--transition);
}

.btn-primary:hover  { background: var(--accent-dark); }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  transition: background var(--transition);
}

.btn-secondary:hover { background: rgba(255,255,255,0.1); }

.btn-danger {
  background: rgba(233, 69, 96, 0.12);
  border: 1px solid rgba(233, 69, 96, 0.3);
  color: var(--accent);
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  transition: all var(--transition);
}

.btn-danger:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── History ── */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.history-item {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem;
  display: flex;
  gap: 0.875rem;
  align-items: flex-start;
  transition: border-color var(--transition);
  animation: fade-in 0.2s ease;
}

.history-item:hover { border-color: rgba(233, 69, 96, 0.25); }

.history-info { flex: 1; min-width: 0; }

.history-title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.history-preview {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.history-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex-shrink: 0;
}

.history-actions button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.28rem 0.6rem;
  border-radius: 7px;
  font-size: 0.72rem;
  white-space: nowrap;
  transition: all var(--transition);
}

.history-actions button:hover       { background: var(--accent); border-color: var(--accent); color: #fff; }
.history-actions .btn-hist-del:hover{ background: var(--accent); border-color: var(--accent); color: #fff; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2.5rem 1rem;
  font-size: 0.9rem;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 1.75rem;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 0.65rem 1.4rem;
  border-radius: 100px;
  font-size: 0.84rem;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: var(--shadow);
  z-index: 9999;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100vw - 2rem);
  text-align: center;
}

.toast.is-visible { transform: translateX(-50%) translateY(0); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); }

/* ── Animations ── */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .header { padding: 0.6rem 1rem; }
  .logo-text { display: none; }
  .main { padding: 1.25rem 1rem 2rem; gap: 1.25rem; }
  .timer-display { font-size: 1.75rem; }
  .btn-record-inner { width: 80px; height: 80px; }
  .btn-record-ring  { width: 80px; height: 80px; }
  .transcript-actions { gap: 0.3rem; }
  .btn-action { padding: 0.28rem 0.5rem; font-size: 0.72rem; }
  .history-item { flex-direction: column; }
  .history-actions { flex-direction: row; flex-wrap: wrap; }
  .modal-content { max-height: 92vh; }
}

@media (min-width: 601px) {
  .logo-text { display: block; }
}

/* ── Sponsor nav button ── */
.btn-sponsor-nav {
  color: #ff6b8a;
  border-color: rgba(255, 107, 138, 0.3);
}
.btn-sponsor-nav:hover {
  background: #ff6b8a;
  border-color: #ff6b8a;
  color: #fff;
}

.sponsor-badge {
  background: var(--success);
  color: #fff;
  font-size: 0.62rem;
  padding: 0.1rem 0.4rem;
  border-radius: 100px;
  font-weight: 700;
  margin-left: 0.2rem;
}

/* ── App footer ── */
.app-footer {
  width: 100%;
  text-align: center;
  padding: 1.5rem 0 0.5rem;
}

.footer-sponsor-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  transition: color var(--transition);
}
.footer-sponsor-link:hover { color: #ff6b8a; }

/* ── Engine info (settings) ── */
.engine-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(76, 175, 80, 0.06);
  border-color: rgba(76, 175, 80, 0.25);
}
.engine-info strong { font-size: 0.875rem; font-weight: 600; color: var(--success); }
.engine-info small  { font-size: 0.73rem; color: var(--text-muted); line-height: 1.4; }

/* ── Ad Modal ── */
.modal-ad-overlay .modal-ad-content {
  max-width: 420px;
  text-align: center;
}

.modal-ad-header {
  justify-content: center;
  border-bottom-color: var(--accent);
}
.modal-ad-header h3 { color: var(--accent); }

.modal-ad-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
}

.ad-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.btn-ad-link {
  display: inline-block;
  background: linear-gradient(135deg, #ee4d2d, #ff6633);
  color: #fff;
  text-decoration: none;
  padding: 0.7rem 1.6rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 16px rgba(238, 77, 45, 0.35);
}
.btn-ad-link:hover {
  transform: scale(1.04);
  box-shadow: 0 6px 24px rgba(238, 77, 45, 0.5);
}

.ad-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-ad-continue {
  width: 100%;
  max-width: 260px;
  padding: 0.6rem 1.4rem;
}
.btn-ad-continue:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ad-divider {
  width: 100%;
  height: 1px;
  background: var(--border);
  margin: 0.4rem 0;
}

.ad-sponsor-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.btn-ad-sponsor {
  font-size: 0.82rem;
  padding: 0.45rem 1rem;
  color: #ff6b8a;
  border-color: rgba(255, 107, 138, 0.3);
}
.btn-ad-sponsor:hover {
  background: rgba(255, 107, 138, 0.12);
  border-color: #ff6b8a;
}

/* ── Sponsor Modal ── */
.sponsor-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 0.8rem;
}

.btn-sponsor-go {
  display: inline-block;
  background: linear-gradient(135deg, #ff6b8a, #e94560);
  color: #fff;
  text-decoration: none;
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 16px rgba(233, 69, 96, 0.3);
}
.btn-sponsor-go:hover {
  transform: scale(1.04);
  box-shadow: 0 6px 24px rgba(233, 69, 96, 0.45);
}