:root {
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-2: #eef3f0;
  --border: #dce3df;
  --text: #18221d;
  --muted: #5a6b62;
  --primary: #007a33;
  --primary-hover: #006128;
  --accent: #8cc63f;
  --danger: #dc2626;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(0, 40, 18, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 3px solid var(--primary);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bn-logo {
  height: 38px;
  width: auto;
  display: block;
}

.brand-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}

.brand h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
}

.badge {
  font-size: 0.75rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
}

.badge-ok {
  color: var(--primary);
  background: rgba(0, 122, 51, 0.08);
  border-color: rgba(0, 122, 51, 0.3);
}

.badge-accent {
  color: var(--primary);
  background: rgba(140, 198, 63, 0.18);
  border-color: rgba(140, 198, 63, 0.5);
}

.container {
  max-width: 1360px;
  margin: 22px auto;
  padding: 0 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 10px;
}

.card-header h2,
.card-header h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--text);
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.inline-form {
  display: flex;
  gap: 10px;
}

.live-form {
  display: grid;
  grid-template-columns: 1fr 150px auto auto;
  gap: 10px;
}

.mode-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 8px;
}

.mode-option {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.mode-option:hover {
  border-color: rgba(0, 122, 51, 0.4);
}

.mode-option.active {
  border-color: var(--primary);
  background: rgba(0, 122, 51, 0.06);
}

.mode-option input {
  display: none;
}

.mode-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--text);
}

.mode-option small {
  color: var(--muted);
  font-size: 0.8rem;
}

.mode-icon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.mode-icon.live {
  background: var(--danger);
}

.mode-icon.buffer {
  background: var(--accent);
}

.mode-hint {
  margin: 4px 0 12px;
  font-size: 0.8rem;
}

@media (max-width: 760px) {
  .mode-selector {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .live-form {
    grid-template-columns: 1fr;
  }
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.live-status-bar {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 0.88rem;
  font-weight: 600;
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #dc2626;
  animation: pulse 1.2s infinite;
}

.live-dot.stopped {
  background: var(--primary);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

input[type="text"],
input[type="url"],
input[type="password"],
input[type="search"],
select {
  width: 100%;
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.92rem;
}

input:focus,
select:focus {
  outline: 2px solid rgba(0, 122, 51, 0.25);
  border-color: var(--primary);
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: #e2ebe6;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.btn-mini {
  padding: 6px 9px;
  font-size: 0.78rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-mini:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  font-size: inherit;
  padding: 0;
  text-decoration: underline;
}

.full-width {
  width: 100%;
  margin-top: 12px;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 26px;
  text-align: center;
  background: var(--bg);
  transition: border-color 0.2s, background 0.2s;
}

.dropzone.dragover {
  border-color: var(--primary);
  background: rgba(0, 122, 51, 0.06);
}

.alert {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
}

.alert.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.alert.info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}

.alert.success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #047857;
}

.hidden {
  display: none !important;
}

.workspace {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 20px;
  align-items: start;
}

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

.col-left {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.player-wrapper video,
.player-wrapper audio {
  width: 100%;
  border-radius: 8px;
  background: #000;
  max-height: 360px;
}

.cut-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.input-with-btn {
  display: flex;
  gap: 6px;
}

.transcribe-controls {
  display: grid;
  grid-template-columns: 1.5fr 0.9fr auto;
  gap: 8px;
  margin-bottom: 12px;
}

.transcript-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.transcript-list {
  max-height: 540px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

.segment-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.segment-item:hover {
  border-color: var(--border);
  background: var(--surface-2);
}

.segment-item.active {
  border-color: var(--primary);
  background: rgba(0, 122, 51, 0.1);
}

.seg-time {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  padding-top: 2px;
}

.seg-text {
  font-size: 0.92rem;
}

.seg-actions {
  display: flex;
  gap: 4px;
}

.clips-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.clip-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.clip-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.clip-actions {
  display: flex;
  gap: 6px;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 20px 10px;
  font-size: 0.9rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 480px;
  width: 100%;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.modal-lg {
  max-width: 680px;
}

.gdrive-modal-toolbar {
  display: flex;
  gap: 8px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  color: var(--primary);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.gdrive-auth-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.gdrive-auth-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gdrive-auth-actions {
  display: flex;
  gap: 8px;
}

.gdrive-files-box {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gdrive-files-list {
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gdrive-file-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.gdrive-file-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.gdrive-file-meta strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 40, 18, 0.1);
  padding: 28px 24px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.auth-card h2 {
  margin: 4px 0 0;
  color: var(--primary);
}

.google-signin-wrap {
  margin-top: 6px;
  min-height: 44px;
  display: flex;
  justify-content: center;
}
