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

:root {
  --bg-900: #0d0d1a;
  --bg-850: #101123;
  --bg-800: #13132a;
  --bg-700: #1a1b35;
  --line: #2a2a4e;
  --line-strong: #3a3a5e;
  --text: #e0e6f0;
  --muted: #8892a4;
  --accent: #7c83fd;
  --danger: #e94560;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(124, 131, 253, 0.18), transparent 30%),
    radial-gradient(circle at bottom left, rgba(80, 200, 180, 0.12), transparent 25%),
    var(--bg-900);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-shell {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  padding-top: 88px;
}

.capture-launcher {
  position: fixed;
  top: 20px;
  right: 20px;
  width: min(320px, calc(100vw - 24px));
  padding: 14px;
  border: 1px solid rgba(124, 131, 253, 0.35);
  border-radius: 20px;
  background: rgba(16, 17, 35, 0.92);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.45);
  z-index: 1100;
}

.launcher-grip {
  width: 52px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  margin: 0 auto 12px;
}

.launcher-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.launcher-kicker {
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #9aa3ff;
  margin-bottom: 4px;
}

.launcher-head h1 {
  font-size: 1.05rem;
  line-height: 1.2;
}

.launcher-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, #88f6d8, #7c83fd);
  box-shadow: 0 0 0 5px rgba(124, 131, 253, 0.12);
  margin-top: 6px;
}

.launcher-toggle {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 6px;
  margin: 14px 0 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.mode-btn {
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
}

.mode-btn.active {
  background: rgba(124, 131, 253, 0.16);
  border-color: rgba(124, 131, 253, 0.35);
  color: #eef0ff;
}

.launcher-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.launcher-primary {
  justify-content: center;
}

.launcher-status {
  margin-top: 10px;
  color: #aab0c2;
  font-size: 0.78rem;
  line-height: 1.5;
}

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(19, 19, 42, 0.88);
  padding: 16px 24px;
  border-bottom: 1px solid rgba(124, 131, 253, 0.28);
  flex-shrink: 0;
  flex-wrap: wrap;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 900;
}
.topbar .title { font-size: 1.1rem; font-weight: 700; color: var(--accent); }
.topbar .back  { color: var(--muted); text-decoration: none; font-size: 0.9rem; white-space: nowrap; }
.topbar .back:hover { color: var(--accent); }
.toolbar-group { display: flex; gap: 10px; }

.title-wrap {
  display: flex;
  flex: 1;
  min-width: 220px;
  flex-direction: column;
  gap: 4px;
}

.subtitle {
  color: #a7adc7;
  font-size: 0.82rem;
}

.surface-group {
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (min-width: 961px) {
  /* the launcher is fixed to the top-right; keep topbar content clear of it */
  .topbar {
    padding-right: 356px;
  }
}

.surface-pill {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(124, 131, 253, 0.22);
  background: rgba(255, 255, 255, 0.04);
  color: #cfd4f8;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.desktop-pill {
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.desktop-pill:hover {
  border-color: rgba(124, 131, 253, 0.45);
  color: #eef0ff;
}

/* ── Buttons ── */
[hidden] { display: none !important; }

button, .upload-label {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 9px 16px;
  transition: opacity 0.2s, transform 0.15s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
button:hover, .upload-label:hover { opacity: 0.85; transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-outline  { background: transparent; border: 1px solid var(--line-strong); color: #a0a8d8; }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger   { background: var(--danger); color: #fff; }
.sm { padding: 6px 12px; font-size: 0.78rem; }
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ── Main Layout ── */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── Tools Panel ── */
.tools-panel {
  width: 200px;
  flex-shrink: 0;
  background: rgba(19, 19, 42, 0.84);
  border-right: 1px solid var(--line);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.tools-panel h3 { color: var(--accent); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; }
.section-label  { color: var(--accent); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; display: block; margin-bottom: 6px; }

.tool-list { display: flex; flex-direction: column; gap: 4px; }
.tool-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  text-align: left;
}
.tool-btn:hover, .tool-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(124,131,253,0.08);
}
.tool-btn:hover { transform: none; opacity: 1; }

.tool-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}
.tool-options input[type="color"] { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 6px; padding: 2px; background: var(--bg-900); cursor: pointer; }
.tool-options input[type="range"] { width: 100%; accent-color: var(--accent); }
.tool-options span { font-size: 0.75rem; color: #6a72b0; text-align: right; }

.tool-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.tool-actions-extra { margin-top: 8px; }
.session-notice {
  margin: 14px 0 4px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(80, 200, 180, 0.28);
  background: rgba(80, 200, 180, 0.08);
  color: #9ee9d7;
  font-size: 0.78rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.session-notice[hidden] { display: none; }

.snapshot-section { margin-top: 18px; }

/* ── Snapshot list ── */
.snapshot-list { display: flex; flex-direction: column; gap: 8px; }
.snapshot-thumb {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s;
  position: relative;
}
.snapshot-thumb:hover { border-color: var(--accent); }
.snapshot-thumb img { display: block; width: 100%; max-height: 80px; object-fit: cover; }
.snap-label {
  font-size: 0.7rem;
  color: var(--muted);
  padding: 4px 6px;
  background: var(--bg-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.snap-del {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(13,13,26,0.8);
  color: var(--danger);
  border: none;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.7rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}
.snapshot-thumb:hover .snap-del { opacity: 1; }

/* ── Canvas ── */
.canvas-wrap {
  flex: 1;
  overflow: auto;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 200px), var(--bg-900);
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  position: relative;
  transition: filter 0.25s ease, opacity 0.25s ease;
}
.canvas-container {
  position: relative;
  margin: 16px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
#baseCanvas, #annoCanvas {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
}
#baseCanvas { z-index: 1; }
#annoCanvas { z-index: 2; }

/* ── Placeholder ── */
.canvas-placeholder {
  width: 640px;
  height: 480px;
  border: 2px dashed var(--line);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #4a4e7e;
  text-align: center;
  padding: 30px;
  background: rgba(255, 255, 255, 0.02);
}
.ph-icon { font-size: 4rem; }
.canvas-placeholder p { font-size: 0.9rem; line-height: 1.6; }
.upload-label { background: transparent; border: 1px solid var(--line-strong); color: #a0a8d8; }
.hidden-file-input { display: none; }
.placeholder-capture-btn { margin-top: 10px; }

/* ── Recording badge ── */
.recording-badge {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(233,69,96,0.92);
  color: #fff;
  border-radius: 30px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.9rem;
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(233,69,96,0.4);
  display: none;
}
.rec-dot {
  width: 10px; height: 10px;
  background: #fff;
  border-radius: 50%;
  animation: blink 1s ease-in-out infinite;
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* ── Text popup ── */
.text-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-800);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 20px;
  width: 320px;
  z-index: 500;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
  display: none;
}
.text-popup-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.text-popup textarea {
  width: 100%;
  background: var(--bg-900);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  padding: 10px;
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
}
.text-popup textarea:focus { border-color: var(--accent); }

@media (max-width: 960px) {
  /* no room to float anything: the launcher and topbar simply stack */
  .app-shell {
    padding-top: 0;
  }

  .topbar {
    position: static;
  }

  .capture-launcher {
    position: static;
    width: auto;
    margin: 12px;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .main-layout {
    flex-direction: column;
  }

  .tools-panel {
    width: 100%;
    max-height: 240px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-900); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
