:root {
    color-scheme: dark;
    --bg: #080b12;
    --panel: #111722;
    --panel-2: #161e2b;
    --line: #283344;
    --muted: #8d99aa;
    --text: #f6f8fb;
    --accent: #ff5b45;
    --accent-2: #ff816f;
    --blue: #5ac8fa;
    font-family: Inter, "Noto Sans JP", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 1080px; background: radial-gradient(circle at 25% -10%, #1a263a 0, transparent 34%), var(--bg); color: var(--text); font-size: 14px; }
button, input { font: inherit; }
button { color: inherit; }

.topbar { height: 64px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 24px; border-bottom: 1px solid var(--line); background: #090d15e8; backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 10; }
.topbar > div { text-align: center; }
.topbar > div strong, .topbar > div small { display: block; }
.topbar > div small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.brand { justify-self: start; display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; font-weight: 800; }
.brand span { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--accent); color: white; }
.file-button { justify-self: end; border: 1px solid #526078; border-radius: 10px; padding: 9px 14px; font-weight: 750; cursor: pointer; background: #182131; }
.file-button input { display: none; }

.workspace { display: grid; grid-template-columns: minmax(720px, 1fr) 390px; gap: 18px; max-width: 1680px; margin: 0 auto; padding: 18px; }
.player-column, .rally-panel { min-width: 0; }
.video-stage { position: relative; aspect-ratio: 16 / 9; display: grid; place-items: center; overflow: hidden; background: #000; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 24px 60px #0008; }
.video-stage video { width: 100%; height: 100%; object-fit: contain; }
.video-stage.drag { outline: 3px solid var(--blue); outline-offset: -4px; }
.empty-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; background: linear-gradient(135deg, #101827, #070a10); color: var(--muted); }
.empty-state strong { font-size: 22px; color: var(--text); }
.empty-state small { font-size: 11px; }

.timeline-row { display: grid; grid-template-columns: 68px 1fr 68px; align-items: center; gap: 10px; margin: 13px 4px 8px; font-variant-numeric: tabular-nums; color: #c7d0dc; }
.timeline-row span:last-child { text-align: right; }
.timeline-row input, .speed-panel input { accent-color: var(--accent); }
.transport { display: grid; grid-template-columns: repeat(3, 1fr) 1.4fr repeat(3, 1fr); gap: 7px; }
.transport button, .speed-buttons button { border: 1px solid var(--line); border-radius: 9px; background: var(--panel); color: #cbd5e1; min-height: 42px; cursor: pointer; }
.transport button:hover, .speed-buttons button:hover { background: #202b3b; }
.transport .play-button { background: #f5f7fb; color: #111827; border-color: #f5f7fb; font-weight: 850; }

.speed-panel { display: grid; grid-template-columns: auto auto minmax(120px, 1fr) 58px; align-items: center; gap: 12px; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); }
.speed-panel > span { color: var(--muted); font-size: 12px; }
.speed-buttons { display: flex; gap: 5px; }
.speed-buttons button { min-height: 30px; padding: 3px 9px; font-size: 11px; }
.speed-buttons button.active { border-color: var(--accent); background: #ff5b4520; color: #ff9a8d; }
.speed-panel output { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }

.manual-markers { margin-top: 12px; padding: 12px; border: 1px solid #344055; border-radius: 14px; background: linear-gradient(145deg, #111927, #0c111a); }
.marker-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.marker-button { min-height: 70px; border: 1px solid transparent; border-radius: 12px; cursor: pointer; display: flex; justify-content: center; align-items: center; gap: 12px; transition: transform .12s ease, filter .12s ease; }
.marker-button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.08); }
.marker-button span { font-size: 20px; font-weight: 900; }
.marker-button small { border: 1px solid #ffffff70; border-radius: 6px; padding: 3px 7px; }
.marker-button:disabled { opacity: .35; cursor: not-allowed; }
.start-marker { background: linear-gradient(135deg, #16835b, #0d6847); box-shadow: 0 12px 28px #16a36a22; }
.start-marker.active { border-color: #8bffd0; box-shadow: 0 0 0 3px #34d39928, 0 12px 28px #16a36a28; }
.end-marker { background: linear-gradient(135deg, var(--accent), #d93628); box-shadow: 0 12px 28px #ff5b4525; }
.marker-values { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 9px; }
.marker-values strong { padding: 9px 12px; border-radius: 8px; background: #080c13; color: #cbd5e1; text-align: center; font-variant-numeric: tabular-nums; }

.preview-controls { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px; margin-top: 10px; padding: 10px 12px; border: 1px solid #2c7898; border-radius: 11px; background: #102532; }
.preview-controls div { min-width: 0; }
.preview-controls strong, .preview-controls span { display: block; }
.preview-controls span { margin-top: 2px; color: #9fdcf2; font-size: 11px; font-variant-numeric: tabular-nums; }
.preview-controls button { min-height: 34px; border: 1px solid #376b80; border-radius: 8px; background: #16394a; color: #d8f4ff; cursor: pointer; font-size: 11px; font-weight: 800; padding: 0 10px; }
.preview-controls button:last-child { background: #f5f7fb; color: #111827; border-color: #f5f7fb; }

.source-options { display: flex; align-items: center; margin: 10px 2px 0; color: var(--muted); font-size: 12px; }
.source-options > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-line { min-height: 20px; margin: 8px 2px 0; color: var(--muted); font-size: 12px; }
.shortcut-help { margin-top: 6px; color: var(--muted); font-size: 11px; }
.shortcut-help summary { cursor: pointer; }
.shortcut-help div { padding-top: 8px; }
.shortcut-help kbd { border: 1px solid #485365; border-bottom-width: 2px; border-radius: 5px; background: #161d28; color: #dce4ee; padding: 2px 5px; }

.rally-panel { border: 1px solid var(--line); border-radius: 16px; background: #0f141e; min-height: calc(100vh - 100px); display: flex; flex-direction: column; overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 18px; border-bottom: 1px solid var(--line); }
.eyebrow { display: block; color: var(--accent-2); font-size: 9px; letter-spacing: .16em; font-weight: 900; }
.panel-heading h1 { margin: 3px 0 0; font-size: 19px; }
.panel-actions { display: flex; align-items: center; gap: 8px; }
.rally-count { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: #1d2735; font-size: 17px; }
.new-work-button { min-height: 34px; border: 1px solid #5a3440; border-radius: 8px; background: #2a1820; color: #ffb2a7; cursor: pointer; padding: 0 10px; font-size: 11px; font-weight: 800; }
.new-work-button:hover { border-color: #a74f5f; background: #3a1d27; }
.restore-panel { margin: 10px 10px 0; padding: 10px; border: 1px solid #79611d; border-radius: 9px; background: #2a2411; color: #f8dfa0; font-size: 11px; }
.restore-panel strong, .restore-panel span { display: block; }
.restore-panel span { margin-top: 3px; color: #d9c994; }
.restore-panel ul { margin: 6px 0 0; padding-left: 18px; }
.backup-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding: 10px 10px 0; }
.backup-actions button, .backup-actions label { min-height: 33px; display: grid; place-items: center; padding: 5px; border: 1px solid #3c4a5e; border-radius: 8px; background: #17202d; color: #bdc9d8; cursor: pointer; font-size: 10px; text-align: center; }
.backup-actions input { display: none; }
.rally-empty { margin: auto; text-align: center; line-height: 1.8; color: #667386; }
.rally-list { list-style: none; margin: 0; padding: 8px 10px; overflow: auto; max-height: calc(100vh - 320px); counter-reset: rally; }
.rally-item { counter-increment: rally; display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 9px; padding: 11px 8px; border-bottom: 1px solid #222c3a; cursor: pointer; border-radius: 8px; }
.rally-item:hover, .rally-item:focus-visible { background: #182231; outline: none; }
.rally-item.previewing { background: #123044; box-shadow: inset 3px 0 #5ac8fa; }
.rally-item::before { content: counter(rally, decimal-leading-zero); font-weight: 900; color: #64748b; }
.rally-times { min-width: 0; font-variant-numeric: tabular-nums; }
.rally-times strong, .rally-times small { display: block; }
.rally-times small { margin-top: 3px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rally-adjust { grid-column: 2 / 3; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.rally-adjust button { min-height: 25px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); color: #aeb9c8; cursor: pointer; font-size: 9px; }
.rally-adjust button:hover { border-color: #55647a; color: white; }
.delete-rally { grid-column: 3; grid-row: 1 / 3; border: 0; background: transparent; color: #8290a2; cursor: pointer; font-size: 18px; }
.delete-rally:hover { color: #ff7b68; }

.export-panel { margin-top: auto; padding: 16px; border-top: 1px solid var(--line); background: #121925; }
.total-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; color: var(--muted); }
.total-row strong { color: var(--text); font-variant-numeric: tabular-nums; }
.export-policy { margin: 0 0 10px; padding: 9px; border: 1px solid #344055; border-radius: 10px; background: #0c121b; color: #cbd5e1; font-size: 10px; line-height: 1.55; }
.export-choice { border: 1px solid var(--line); border-radius: 10px; padding: 11px; background: #0d131d; }
.export-choice + .export-choice { margin-top: 9px; }
.export-choice h2 { margin: 0; font-size: 13px; }
.export-choice p { margin: 4px 0 10px; }
.append-choice { border-color: #3e4b61; }
.export-button, .download-link { display: grid; place-items: center; width: 100%; min-height: 44px; border: 0; border-radius: 10px; background: #f5f7fb; color: #111827; font-weight: 900; cursor: pointer; text-decoration: none; }
.export-button.secondary { border: 1px solid #55708f; background: #19314a; color: #d9ecff; }
.export-button:disabled { opacity: .35; cursor: not-allowed; }
.export-panel progress { width: 100%; margin-top: 12px; accent-color: var(--accent); }
.progress-details { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; color: #cbd5e1; font-size: 10px; }
.progress-details strong { color: #f8fafc; }
.progress-details span { color: var(--muted); text-align: right; }
.export-range { display: block; min-height: 15px; margin-top: 4px; color: #aeb9c8; font-size: 10px; font-variant-numeric: tabular-nums; }
.export-panel p { margin: 9px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.download-link { margin-top: 10px; background: #173a2c; color: #a7f3d0; border: 1px solid #2c684e; }
.confirm-dialog { width: min(480px, calc(100vw - 32px)); border: 1px solid #46556b; border-radius: 14px; background: #111925; color: var(--text); box-shadow: 0 24px 80px #000c; }
.confirm-dialog::backdrop { background: #03060bb8; backdrop-filter: blur(2px); }
.confirm-dialog-inner { margin: 0; }
.confirm-dialog p { margin: 0; white-space: pre-line; line-height: 1.7; }
.confirm-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.confirm-dialog-actions button { min-height: 38px; border: 1px solid #46556b; border-radius: 8px; background: #1a2432; color: #d7e0ea; cursor: pointer; padding: 0 14px; font-weight: 800; }
.confirm-dialog-actions button:last-child { border-color: var(--accent); background: var(--accent); color: white; }
.hidden { display: none !important; }

@media (max-width: 1200px) {
    .workspace { grid-template-columns: minmax(680px, 1fr) 360px; }
    .transport { gap: 5px; }
    .transport button { font-size: 12px; }
    .speed-panel { grid-template-columns: auto 1fr 55px; }
    .speed-buttons { grid-row: 2; grid-column: 1 / 4; }
    .speed-buttons button { flex: 1; }
}
