/* ============================================================
   Video Assist Tool — Dark Theme CSS
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:     #0a0a0a;
  --bg-sidebar:  #111111;
  --bg-panel:    #161616;
  --bg-card:     #1c1c1c;
  --border:      #2a2a2a;
  --accent:      #e84040;
  --accent-dim:  #8a2020;
  --text-primary:#f0f0f0;
  --text-muted:  #888;
  --text-dim:    #555;
  --btn-bg:      #242424;
  --btn-hover:   #333;
  --green:       #27ae60;
  --font-mono:   'JetBrains Mono', 'Courier New', monospace;
  --font-ui:     'Inter', system-ui, sans-serif;
  --sidebar-w:   260px;
}

html, body {
  height: 100%; width: 100%; overflow: hidden;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

/* ===================== LAYOUT ===================== */
#app {
  display: flex;
  height: 100vh;
}

/* ===================== SIDEBAR ===================== */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 1rem;
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

.logo {
  padding: 1rem 1.2rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: #fff;
  border-bottom: 1px solid var(--border);
  background: #0d0d0d;
}
.logo span { color: var(--accent); }

.panel-section {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.section-title {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.current-project {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-primary);
  background: var(--bg-card);
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===================== BUTTONS ===================== */
button {
  cursor: pointer;
  border: none;
  outline: none;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  transition: background 0.15s, transform 0.05s;
}

.btn-sm {
  background: var(--btn-bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.7rem;
  width: 100%;
  text-align: left;
}
.btn-sm:hover { background: var(--btn-hover); }

.btn-primary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  padding: 0.4rem 0.7rem;
  width: 100%;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.btn-primary:hover { background: #2a2a2a; border-color: #555; }
.btn-primary:active { transform: scale(0.98); }

.btn-capture {
  background: var(--accent);
  color: #fff;
  border-radius: 5px;
  padding: 0.55rem 0.7rem;
  width: 100%;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}
.btn-capture:hover { background: #c03030; }
.btn-capture:active { transform: scale(0.97); }

.btn-group {
  display: flex;
  gap: 0.3rem;
}
.mode-btn {
  flex: 1;
  background: var(--btn-bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem 0.2rem;
  font-size: 0.75rem;
}
.mode-btn.active {
  background: var(--accent-dim);
  color: #fff;
  border-color: var(--accent);
}
.mode-btn:hover:not(.active) { background: var(--btn-hover); color: var(--text-primary); }

/* ===================== SELECT ===================== */
.select-full {
  width: 100%;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  outline: none;
  cursor: pointer;
}
.select-full:hover { border-color: #444; }

.select-ratio {
  flex: 1;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  outline: none;
  cursor: pointer;
}
.select-ratio:hover { border-color: #444; }

.onion-base-info {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  padding: 0.2rem 0;
  text-align: center;
}

/* ===================== TOGGLES ===================== */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.2rem 0;
}
.toggle-row span:first-child { flex: 1; color: var(--text-muted); }
.toggle-row input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }
.toggle-label { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-dim); background: var(--bg-card); border: 1px solid var(--border); border-radius: 3px; padding: 0 4px; }

/* ===================== PARAMS ===================== */
.param-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.param-row label {
  width: 38px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  flex-shrink: 0;
}
.param-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  height: 3px;
  cursor: pointer;
}
.param-row span {
  width: 40px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: right;
}

/* ===================== REPLAY ===================== */
.replay-status {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--green);
  letter-spacing: 0.12em;
  text-align: center;
  padding: 0.25rem;
  background: #0a1f0a;
  border: 1px solid #1a3a1a;
  border-radius: 4px;
}
.replay-status.replay-mode { color: #e8a040; background: #1f1500; border-color: #3a2800; }

.replay-controls { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.2rem; }
.replay-controls input[type="range"] { width: 100%; accent-color: #e8a040; cursor: pointer; }
.replay-btns { display: flex; gap: 0.3rem; }
.replay-btns button {
  flex: 1;
  background: var(--btn-bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem;
  font-size: 0.8rem;
}
.replay-btns button:hover { background: var(--btn-hover); }
.replay-pos {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  text-align: center;
}

.shot-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: center;
}

/* ===================== VIEW AREA ===================== */
#viewArea {
  flex: 1;
  background: #000;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.view-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 0; left: 0;
}
.view-container.hidden { display: none; }
.view-container.active { display: flex; }

/* Normal / Crop only view */
#normalView canvas,
#cropView canvas {
  max-width: 100%;
  max-height: calc(100vh - 32px);
  display: block;
  cursor: crosshair;
}

/* Dual view */
.dual {
  flex-direction: row;
  gap: 0;
}
.dual-left, .dual-right {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  overflow: hidden;
}
.dual-left {
  border-right: none; /* dividerが境界を担う */
  flex: 1 1 50%;
}
.dual-right {
  position: relative;
  background: #050505;
  flex: 1 1 50%;
}
/* ドラッグ可能な分割線 */
.dual-divider {
  width: 8px;
  min-width: 8px;
  height: 100%;
  background: var(--border);
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: background 0.15s;
  flex-shrink: 0;
}
.dual-divider:hover, .dual-divider.dragging {
  background: var(--accent);
}
.divider-handle {
  width: 3px;
  height: 40px;
  background: #666;
  border-radius: 2px;
  pointer-events: none;
}
.dual-left canvas,
.dual-right canvas {
  max-width: 100%;
  max-height: calc(100vh - 32px);
  display: block;
  cursor: crosshair;
}
.dual-label {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  background: rgba(0,0,0,0.6);
  padding: 2px 8px;
  border-radius: 3px;
  pointer-events: none;
}
.dual-right .dual-label { top: 8px; }

/* ===================== STATUS BAR ===================== */
#statusBar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 32px;
  background: rgba(0,0,0,0.85);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  z-index: 10;
}
#statusMode { color: var(--text-muted); letter-spacing: 0.08em; }
#statusMsg { color: #e8a040; flex: 1; text-align: right; }

/* ===================== MODAL ===================== */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }

.modal-box {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2rem;
  width: 420px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.modal-box h2 {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}
.modal-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.modal-section label {
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}
.modal-row { display: flex; gap: 0.5rem; }
.modal-row input[type="text"] {
  flex: 1;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 0.7rem;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  outline: none;
}
.modal-row input[type="text"]:focus { border-color: var(--accent); }
.modal-row button {
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  padding: 0.4rem 1rem;
  font-weight: 500;
}
.modal-row button:hover { background: #c03030; }
.modal-section select {
  width: 100%;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}
.modal-section > button {
  background: var(--btn-bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 1rem;
  width: 100%;
}
.modal-section > button:hover { background: var(--btn-hover); }

/* ===================== UTILS ===================== */
.hidden { display: none !important; }

/* ===================== SNS SAFE ZONE ===================== */
.safezone-btns {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}
.sz-btn {
  flex: 1 1 auto;
  min-width: 40px;
  background: var(--btn-bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.2rem;
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  text-align: center;
}
.sz-btn:hover:not(.active) { background: var(--btn-hover); color: var(--text-primary); }
.sz-btn.active[data-platform="none"] { background: var(--btn-bg); color: var(--text-muted); border-color: #555; }
.sz-btn.active[data-platform="tiktok"] { background: #1a1a2a; color: #69c9d0; border-color: #69c9d0; }
.sz-btn.active[data-platform="instagram"] { background: #2a1525; color: #e1306c; border-color: #e1306c; }
.sz-btn.active[data-platform="youtube"] { background: #2a0a0a; color: #ff0000; border-color: #ff0000; }

.safezone-note {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ===================== SOURCE ROTATION ===================== */
.rot-btn {
  flex: 1;
  background: var(--btn-bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .3rem .1rem;
  font-size: .72rem;
  font-family: var(--font-mono);
}
.rot-btn:hover:not(.active) { background: var(--btn-hover); color: var(--text-primary); }
.rot-btn.active { background: #1a3a1a; color: #4caf50; border-color: #4caf50; }
.rot-btn.hidden { display: none !important; }

/* ===================== ORIENTATION ===================== */
.orient-btn {
  flex: 1;
  background: var(--btn-bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .3rem .1rem;
  font-size: .72rem;
  font-family: var(--font-mono);
  cursor: pointer;
}
.orient-btn:hover:not(.active) { background: var(--btn-hover); color: var(--text-primary); }
.orient-btn.active { background: #1a1a3a; color: #64b5f6; border-color: #64b5f6; }

/* ===================== REPLAY PLAY BUTTON ===================== */
.replay-play-btn {
  min-width: 2.4rem !important;
}
.replay-play-btn.playing {
  color: #e8a040 !important;
  border-color: #e8a040 !important;
  background: #1f1500 !important;
}
