:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-soft: rgba(30, 41, 59, 0.72);
  --border: #334155;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --en-text: #cbd5e1;
  --blue: #3b82f6;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --zh-size: 18px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei UI", sans-serif;
  overscroll-behavior: none;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.96);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

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

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-idle { background: #4ade80; }
.dot-live { background: #ef4444; box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.25); }
.dot-paused { background: #facc15; }

.brand-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
}

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

.timer {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  font-weight: 600;
  color: #93c5fd;
}

.meter-track {
  width: 54px;
  height: 8px;
  background: #1e293b;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.meter-fill {
  width: 0%;
  height: 100%;
  background: #22c55e;
  transition: width 80ms linear;
}

.wake-badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.16);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.4);
}

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

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(180, 83, 9, 0.35);
  border-bottom: 1px solid rgba(245, 158, 11, 0.45);
  color: #fef3c7;
  font-size: 13px;
}

.controls-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid var(--border);
}

.title-input {
  flex: 1 1 200px;
  min-height: 44px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 15px;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

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

.btn-sm {
  min-height: 34px;
  padding: 4px 10px;
  font-size: 13px;
}

.btn-primary {
  background: var(--green);
  border-color: #22c55e;
}

.btn-secondary {
  background: #1e293b;
  border-color: #475569;
}

.btn-danger {
  background: var(--red);
  border-color: #ef4444;
}

.btn-amber {
  background: var(--amber);
  border-color: #f59e0b;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
}

.subtitle-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 14px;
  -webkit-overflow-scrolling: touch;
}

.empty-state {
  max-width: 540px;
  margin: 36px auto;
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
  border: 1px dashed var(--border);
  border-radius: 16px;
}

.empty-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.empty-state h2 {
  color: var(--text);
  font-size: 18px;
  margin: 4px 0 10px;
}

.empty-tip {
  font-size: 13px;
  color: #93c5fd;
}

.cards-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 960px;
  margin: 0 auto;
}

.sub-card {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
}

.sub-ts {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: #60a5fa;
  margin-bottom: 4px;
}

.sub-en {
  font-size: 14px;
  color: var(--en-text);
  line-height: 1.45;
  margin-bottom: 5px;
}

.sub-zh {
  font-size: var(--zh-size);
  color: #ffffff;
  font-weight: 600;
  line-height: 1.5;
}

.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.96);
}

.live-hint {
  font-size: 13px;
  color: #fde047;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 50;
}

.modal-backdrop[hidden],
[hidden] {
  display: none !important;
}

.modal-sheet {
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  background: #111827;
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-wide {
  max-width: 860px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
}

.modal-body {
  padding: 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.wrap-footer {
  flex-wrap: wrap;
}

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

.field label {
  font-size: 13px;
  color: #cbd5e1;
  font-weight: 600;
}

.field input[type="text"],
.field input[type="password"],
.field select {
  width: 100%;
  min-height: 44px;
  background: #1f2937;
  color: var(--text);
  border: 1px solid #374151;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 15px;
}

.input-row {
  display: flex;
  gap: 8px;
}

.help-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.help-row a {
  color: #60a5fa;
  text-decoration: none;
}

.status-msg {
  font-size: 13px;
  color: var(--text-muted);
}

.tabs-bar {
  display: flex;
  gap: 8px;
}

.tab-btn {
  flex: 1;
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
}

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

.md-preview {
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  min-height: 260px;
  max-height: 48dvh;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.65;
  color: #e2e8f0;
}

.md-preview h1, .md-preview h2, .md-preview h3 {
  color: #93c5fd;
  margin-top: 14px;
  margin-bottom: 6px;
}

.md-preview h1 { font-size: 19px; margin-top: 0; }
.md-preview h2 { font-size: 16px; border-bottom: 1px solid #1e293b; padding-bottom: 4px; }
.md-preview h3 { font-size: 14px; }

.md-preview table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
}

.md-preview th, .md-preview td {
  border: 1px solid #334155;
  padding: 6px 8px;
  text-align: left;
}

.md-preview th {
  background: #1e293b;
}

.md-preview code {
  background: #1e293b;
  padding: 2px 5px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
}

@media (max-width: 640px) {
  .top-header { padding: 8px 10px; }
  .controls-bar { padding: 8px 10px; }
  .btn { padding: 8px 11px; font-size: 13px; }
}
