:root {
  --bg: #0f172a;
  --surface: #111827;
  --card: #0b1220;
  --accent: #22c55e;
  --accent-2: #38bdf8;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: rgba(255,255,255,0.06);
  --shadow: 0 20px 50px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Space Grotesk", "Inter", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 20% 20%, rgba(56,189,248,0.08), transparent 28%),
              radial-gradient(circle at 80% 0%, rgba(34,197,94,0.08), transparent 30%),
              var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  z-index: 100;
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, #22c55e, #38bdf8);
  display: grid; place-items: center; color: #0b1220;
  font-weight: 800; letter-spacing: 0.5px; box-shadow: 0 4px 15px rgba(34,197,94,0.2);
  font-size: 11px;
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.title { font-size: 16px; font-weight: 700; letter-spacing: 0.1px; white-space: nowrap; }

.status-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 2px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.header-spacer {
  flex: 1;
}

.lang-switcher {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 8px;
  transition: all 0.2s;
  height: 32px;
}

.lang-switcher:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.lang-switcher select {
  appearance: none;
  background: transparent;
  color: var(--text);
  border: none;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  width: 30px;
  text-align: center;
}

.lang-icon {
  color: var(--muted);
  display: flex;
  align-items: center;
  opacity: 0.8;
}

.btn-header {
  padding: 0 16px;
  font-size: 12px;
  border-radius: 8px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-rag {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0 12px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 8px;
  height: 32px;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-rag:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.status-dot { 
  width: 8px; 
  height: 8px; 
  border-radius: 50%; 
  background: var(--accent-2); 
  box-shadow: 0 0 10px var(--accent-2); 
  display: inline-block;
}

.status-pill {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
  background: rgba(56,189,248,0.12); color: #bae6fd; border: 1px solid rgba(56,189,248,0.3);
  padding: 6px 10px; border-radius: 999px; font-size: 12px; letter-spacing: 0.1px;
  flex-shrink: 0;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 8px var(--accent-2); }

.btn {
  border: 1px solid transparent; border-radius: 10px; padding: 8px 14px; font-weight: 600; font-size: 13px;
  cursor: pointer; transition: transform 0.15s, box-shadow 0.2s, background 0.2s; color: #0b1220;
  display: inline-flex; align-items: center; gap: 6px;
  flex-shrink: 0;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: #22c55e; color: #064e3b; box-shadow: none; }
.btn-primary:hover { background: #4ade80; }
.btn-danger { background: linear-gradient(135deg, #f43f5e, #e11d48); color: #fff; box-shadow: 0 10px 30px rgba(244,63,94,0.28); }
.btn-ghost { background: rgba(255,255,255,0.04); color: var(--text); border-color: var(--border); }
.btn.highlight { border-color: var(--accent); color: #a7f3d0; box-shadow: 0 0 0 8px rgba(34,197,94,0.12); animation: pulse 1.4s infinite; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.layout { 
  display: grid; 
  grid-template-columns: 2fr 1fr; 
  gap: 12px; 
  flex: 1;
  overflow: hidden;
  padding: 12px;
}

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel h2 { margin: 0 0 8px; font-size: 14px; letter-spacing: 0.2px; color: #e5e7eb; }

.subtext { color: var(--muted); font-size: 12px; margin-bottom: 6px; }

#transcript-content { 
  flex: 1; 
  overflow-y: auto; 
  padding-right: 4px; 
  display: flex; 
  flex-direction: column; 
  gap: 10px;
  min-height: 0;
}

.suggestions-scroll { 
  flex: 1; 
  overflow-y: auto; 
  padding-right: 4px; 
  display: flex; 
  flex-direction: column; 
  gap: 10px;
  min-height: 0;
}

#suggestions-content { 
  flex: 1; 
  overflow-y: auto; 
  padding-right: 4px; 
  display: flex; 
  flex-direction: column; 
  gap: 10px;
}

.live-line {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(56,189,248,0.14);
  border: 1px solid rgba(56,189,248,0.28);
  color: #e0f2fe;
  font-size: 12px;
  line-height: 1.4;
  display: flex !important;
  flex-direction: column !important;
  gap: 6px;
  box-shadow: 0 10px 30px rgba(56,189,248,0.15);
  word-break: break-word;
  white-space: pre-wrap;
  margin-bottom: 10px;
  animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 10px 30px rgba(56,189,248,0.15); }
  50% { box-shadow: 0 10px 40px rgba(56,189,248,0.3); }
}

.live-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 10px #38bdf8;
  flex-shrink: 0;
  animation: blink 1.5s ease-in-out infinite;
}

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

.btn-instant-analyze {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.25);
}

.btn-instant-analyze:hover {
  background: linear-gradient(135deg, #16a34a, #15803d);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

.btn-instant-analyze:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(34, 197, 94, 0.3);
}

.btn-instant-analyze svg {
  flex-shrink: 0;
  transition: transform 0.15s ease;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

.btn-instant-analyze:hover svg {
  transform: translateX(1px);
}

.transcript-line {
  padding: 10px 60px 10px 12px;
  border: 1px solid var(--border); 
  border-radius: 10px; 
  background: rgba(255,255,255,0.02);
  line-height: 1.4; 
  display: flex; 
  flex-direction: column; 
  gap: 6px; 
  width: 100%;
  font-size: 12px;
  position: relative;
  transition: all 0.2s ease;
}

.transcript-line:hover {
  background: rgba(255,255,255,0.05);
  border-color: var(--accent-2);
}

.transcript-line.selected {
  background: rgba(34, 197, 94, 0.15);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.message-checkbox {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 2px solid var(--border);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  opacity: 0;
}

.transcript-line:hover .message-checkbox {
  opacity: 1;
}

.transcript-line.selected .message-checkbox {
  opacity: 1;
  background: var(--accent);
  border-color: var(--accent);
}

.message-checkbox .check-icon {
  width: 14px;
  height: 14px;
  fill: transparent;
  transition: fill 0.2s ease;
}

.transcript-line.selected .message-checkbox .check-icon {
  fill: #0b1220;
}

.floating-panel {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  min-width: 200px;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.floating-panel-header {
  padding: 8px 12px;
  background: rgba(34, 197, 94, 0.1);
  border-bottom: 1px solid rgba(34, 197, 94, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.floating-panel-header:active {
  cursor: grabbing;
}

.floating-panel-content {
  padding: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.drag-handle {
  display: flex;
  gap: 3px;
  opacity: 0.5;
}

.drag-handle span {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--accent);
}

@keyframes slideUp {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.selection-count {
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.selection-count strong {
  color: var(--accent);
}

.btn-small {
  padding: 6px 10px;
  font-size: 11px;
}
.line-header { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12px; }
.line-text, .line-translation { 
  width: 100%; 
  word-break: break-word; 
  white-space: pre-wrap; 
  display: block;
}
.line-translation { 
  color: #9ca3af; 
  font-size: 11px; 
  margin-top: 4px;
  padding-left: 0;
}

.bubble { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: 14px; color: #0b1220; font-weight: 700; }
.speaker-0 { background: #22c55e; }
.speaker-1 { background: #f59e0b; }

.suggestion-card { background: var(--card); border-radius: 10px; padding: 12px; border: 1px solid var(--border); box-shadow: 0 12px 32px rgba(0,0,0,0.25); animation: fadeIn 0.25s ease; font-size: 12px; }
.suggestion-question { font-weight: 600; color: #c7d2fe; margin-bottom: 6px; font-size: 12px; letter-spacing: 0.1px; }
.suggestion-text { color: #e5e7eb; line-height: 1.4; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.04); } 100% { transform: scale(1); } }

.hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

.ai-input-section {
  display: flex; gap: 6px; margin-top: 8px; padding-top: 8px; 
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.ai-input {
  flex: 1; 
  background: var(--card); 
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  font-family: inherit;
  transition: border 0.2s, box-shadow 0.2s;
}

.ai-input::placeholder {
  color: var(--muted);
}

.ai-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.1);
}

.btn-send {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  box-shadow: 0 10px 30px rgba(34, 197, 94, 0.35);
  padding: 8px 12px;
  white-space: nowrap;
  font-size: 12px;
}

.btn-send:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

@media (max-width: 640px) {
  header {
    padding: 8px 12px;
    gap: 8px;
  }
  .brand {
    gap: 8px;
  }
  .logo {
    width: 28px;
    height: 28px;
    font-size: 10px;
    border-radius: 6px;
  }
  .title {
    font-size: 15px;
  }
  header .subtext {
    display: none;
  }
  .settings-btn {
    width: 32px;
    height: 32px;
  }
  .settings-btn svg {
    width: 16px;
    height: 16px;
  }
  .toolbar {
    padding: 8px 12px;
    gap: 6px;
  }
  select {
    padding: 6px 10px;
    font-size: 12px;
    min-width: 110px;
  }
  .btn {
    padding: 6px 10px;
    font-size: 12px;
  }
  .status-pill {
    padding: 4px 8px;
    font-size: 11px;
    margin-left: 0;
  }
}

/* Settings button & dialog */
.settings-btn {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border);
  background: rgba(255,255,255,0.04); cursor: pointer; display: grid; place-items: center;
  transition: background 0.2s, transform 0.15s; margin-left: auto; flex-shrink: 0;
}
.settings-btn:hover { background: rgba(255,255,255,0.08); }
.settings-btn:active { transform: scale(0.95); }
.settings-btn svg { width: 18px; height: 18px; fill: var(--text); }
.settings-btn:active { transform: scale(0.95); }
.settings-btn svg { width: 20px; height: 20px; fill: var(--text); }

.settings-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.settings-dialog {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  width: 90%; max-width: 600px; max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.settings-header {
  display: flex; align-items: center; justify-content: space-between; padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.settings-header h2 { margin: 0; font-size: 18px; font-weight: 700; }
.settings-close {
  background: none; border: none; color: var(--muted); font-size: 28px; cursor: pointer;
  width: 32px; height: 32px; display: grid; place-items: center; border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}
.settings-close:hover { background: rgba(255,255,255,0.08); color: var(--text); }

.settings-content {
  flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 20px;
}
.settings-field {
  display: flex; flex-direction: column; gap: 8px;
}
.settings-field input[type="checkbox"] {
  width: 18px; height: 18px; cursor: pointer; accent-color: var(--accent);
}
.settings-field label {
  font-weight: 600; font-size: 14px; color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
.settings-textarea {
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; font-family: 'Fira Code', monospace; font-size: 13px;
  line-height: 1.5; resize: vertical; min-height: 60px; transition: border 0.2s;
}
.settings-textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.1);
}
.settings-textarea:disabled { opacity: 0.4; cursor: not-allowed; }

.settings-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  padding: 16px 24px; border-top: 1px solid var(--border);
}

/* API Configuration Styles */
.settings-section {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.settings-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}
.settings-section h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin: 0 0 16px 0;
  font-weight: 700;
}

.form-group {
  margin-bottom: 16px;
}
.form-group:last-child {
  margin-bottom: 0;
}
.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.settings-input, .settings-select {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.settings-input:focus, .settings-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}
.settings-input::placeholder {
  color: var(--muted);
}

.quick-analyze-btn {
  position: absolute;
  top: 8px;
  right: 36px;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 2;
  padding: 0;
}

.transcript-line:hover .quick-analyze-btn {
  opacity: 1;
}

.quick-analyze-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1220;
  transform: scale(1.1);
}
