* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
:root {
  --bg: #f7f8fa; --card: #ffffff; --ink: #1a2233; --muted: #7a8499;
  --accent: #ff6b35; --accent2: #1f3a5f; --line: #e5e8ef;
  --ok: #1fa060; --warn: #d97706; --err: #dc2626;
}
body { font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif; background: var(--bg); color: var(--ink); }
a { color: inherit; text-decoration: none; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.logo { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.logo span { color: var(--accent); }
.proj-title { font-weight: 600; color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-info { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.balance { background: #fff3ec; color: var(--accent); border-radius: 20px; padding: 4px 12px; font-size: 13px; font-weight: 600; }

.btn { border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 9px 18px; border-radius: 10px; font-size: 14px; cursor: pointer; font-family: inherit; transition: 0.15s; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.sm { padding: 6px 12px; font-size: 13px; }

.center-card { display: flex; justify-content: center; padding: 12vh 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 44px 40px; width: 380px; text-align: center; box-shadow: 0 10px 40px rgba(26,34,51,0.06); }
.card h1 { font-size: 36px; font-weight: 800; }
.card .accent { color: var(--accent); }
.card .sub { color: var(--muted); margin: 8px 0 28px; font-size: 14px; }
.card input { width: 100%; padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; font-size: 16px; margin-bottom: 12px; font-family: inherit; text-align: center; }
.card .btn { width: 100%; padding: 12px; }
.err { color: var(--err); font-size: 13px; margin-top: 10px; min-height: 18px; }

main { max-width: 860px; margin: 28px auto; padding: 0 20px; }
.upload-zone { background: var(--card); border: 2px dashed var(--line); border-radius: 18px; padding: 40px; text-align: center; cursor: pointer; transition: 0.2s; }
.upload-zone:hover, .upload-zone.over { border-color: var(--accent); background: #fff9f6; }
.dz-icon { font-size: 34px; color: var(--accent); margin-bottom: 8px; }
.dz-hint { color: var(--muted); font-size: 13px; margin-top: 6px; }
.progress { height: 8px; background: var(--line); border-radius: 4px; margin-top: 18px; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

.section-title { font-size: 17px; margin: 30px 0 14px; }
.project-card { display: flex; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 20px; margin-bottom: 10px; }
.pc-main { flex: 1; min-width: 0; }
.pc-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-meta { color: var(--muted); font-size: 13px; margin-top: 3px; }
.pc-actions { display: flex; align-items: center; gap: 8px; }
.tag { font-size: 12px; padding: 4px 10px; border-radius: 20px; background: var(--line); color: var(--muted); }
.tag.ready { background: #e6f7ee; color: var(--ok); }
.tag.processing { background: #fef6e7; color: var(--warn); animation: pulse 1.4s infinite; }
.tag.error { background: #fdecec; color: var(--err); }
@keyframes pulse { 50% { opacity: 0.5; } }
.empty { color: var(--muted); text-align: center; padding: 30px; }

.admin-row { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.admin-row input { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; font-family: inherit; flex: 1; min-width: 0; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); }
code { background: var(--bg); padding: 2px 8px; border-radius: 6px; font-size: 13px; }

/* ---------- editor ---------- */
.editor-body { overflow: hidden; height: 100vh; display: flex; flex-direction: column; }
.editor-main { flex: 1; display: grid; grid-template-columns: minmax(380px, 54%) 1fr; gap: 0; min-height: 0; max-width: none; margin: 0; padding: 0; width: 100%; }
.left-pane { padding: 18px 20px; overflow-y: auto; border-right: 1px solid var(--line); }
.right-pane { display: flex; flex-direction: column; min-height: 0; background: var(--card); }

.video-wrap { position: relative; background: #000; border-radius: 14px; overflow: hidden; }
.video-wrap video { display: block; width: 100%; max-height: 46vh; }
.sub-overlay { position: absolute; left: 5%; right: 5%; text-align: center; pointer-events: none; line-height: 1.35; }
.safe-guides { position: absolute; inset: 0; pointer-events: none; }
.guide-line { position: absolute; left: 0; right: 0; border-top: 1px dashed rgba(255,107,53,0.85); }
.transport { display: flex; align-items: center; gap: 12px; margin: 12px 0; font-size: 14px; color: var(--muted); }
.transport .hint { font-size: 12px; }

.style-panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin-top: 14px; }
.style-panel h3 { font-size: 14px; margin-bottom: 12px; }
.style-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; font-size: 13px; color: var(--muted); }
.style-grid label { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.style-grid input[type=range] { flex: 1; }
.style-grid select { padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; font-family: inherit; }

.vocab-list { display: flex; flex-wrap: wrap; gap: 6px; }
.vocab-chip { background: var(--bg); border: 1px solid var(--line); border-radius: 20px; padding: 4px 12px; font-size: 13px; }
.vocab-chip b { cursor: pointer; color: var(--muted); margin-left: 4px; }

.cue-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.cue-list { flex: 1; overflow-y: auto; padding: 10px 14px 60px; }
.cue-row { display: grid; grid-template-columns: 120px 1fr 92px; gap: 10px; padding: 8px 10px; border-radius: 10px; align-items: start; }
.sub-overlay .kw { color: var(--hl, #FFD400); }
.kw-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.kw-chip { font-size: 11px; background: #fff8e1; color: #9a7b00; border: 1px solid #f2e3a1; border-radius: 10px; padding: 1px 8px; cursor: pointer; }
.kw-chip:hover { text-decoration: line-through; }
.cue-row.active { background: #fff3ec; }
.cue-row textarea { width: 100%; border: 1px solid transparent; background: transparent; font-family: inherit; font-size: 15px; resize: none; border-radius: 8px; padding: 6px 8px; line-height: 1.5; }
.cue-row textarea:focus { outline: none; border-color: var(--accent); background: #fff; }
.cue-times { display: flex; flex-direction: column; gap: 4px; }
.t-btn { border: none; background: none; color: var(--muted); font-size: 12px; cursor: pointer; padding: 2px 4px; border-radius: 6px; font-family: inherit; }
.t-btn:hover { color: var(--accent); background: var(--bg); }
.seek { font-weight: 700; font-size: 13px; color: var(--accent2); text-align: left; }
.nudge { display: flex; align-items: center; color: var(--line); }
.cue-ops { display: flex; gap: 2px; padding-top: 4px; }
.save-state { font-size: 12px; color: var(--muted); }
.export-group { display: flex; gap: 6px; }

.burn-mask { position: fixed; inset: 0; background: rgba(20,25,40,0.55); display: flex; align-items: center; justify-content: center; z-index: 100; }
.burn-mask .card { width: auto; padding: 30px 40px; display: flex; align-items: center; gap: 16px; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .editor-main { grid-template-columns: 1fr; overflow-y: auto; }
  .editor-body { overflow: auto; height: auto; }
  .left-pane { border-right: none; }
}
