:root {
  /* surfaces */
  --bg: #0a0e17;
  --panel: #0f1523;
  --panel-2: #131b2c;
  --panel-3: #182238;
  --elevated: #1c2740;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.13);

  /* text */
  --fg: #eef2fb;
  --muted: #93a0bd;
  --faint: #66738f;

  /* brand */
  --accent: #38bdf8;
  --accent-2: #c084fc;
  --plot: #f5b942;
  --road: #38f5c8;
  --danger: #f4547b;
  --ok: #4ade80;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 12px 40px -12px rgba(0, 0, 0, 0.7);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  --topbar-h: 54px;
  --timeline-h: 232px;
  /* độ rộng khung preview bản đồ (cột phải) — kéo được, map mặc định to */
  --map-w: clamp(360px, 50vw, 960px);
  /* khung DỌC: map cột phải chiếm 1/3 màn hình */
  --portrait-map-w: 33.333vw;
}

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}
body {
  font-family: "Manrope", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}
button {
  font-family: inherit;
  cursor: pointer;
  color: inherit;
}
h1,
h2,
h3 {
  font-family: "Sora", "Manrope", sans-serif;
  margin: 0;
}

#app {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr var(--timeline-h);
  height: 100vh;
  height: 100dvh;
}

/* ============ TOP BAR ============ */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 14px;
  background: linear-gradient(180deg, #101728, #0d1421);
  border-bottom: 1px solid var(--line);
  z-index: 40;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 120% at 30% 20%, rgba(56, 189, 248, 0.18), rgba(192, 132, 252, 0.08));
  border: 1px solid var(--line-strong);
  border-radius: 11px;
}
.brand-text strong {
  font-family: "Sora", sans-serif;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.02em;
  display: block;
  line-height: 1;
}
.brand-text strong span {
  background: linear-gradient(90deg, #38bdf8, #2563eb);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-text small {
  display: block;
  white-space: nowrap;
  color: var(--faint);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2px;
}

.topbar-center {
  display: flex;
  justify-content: center;
}
.seg {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  transition: all 0.18s var(--ease);
}
.seg-btn:hover {
  color: var(--fg);
}
.seg-btn.is-active {
  background: linear-gradient(180deg, var(--elevated), var(--panel-3));
  color: var(--fg);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.topbar-right {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--fg);
  padding: 8px 14px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.18s var(--ease);
}
.btn:hover {
  background: var(--panel-3);
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0) scale(0.98);
}
.btn.ghost {
  background: transparent;
}
.btn.primary {
  border: 0;
  background: linear-gradient(135deg, var(--accent), #5b8cf5);
  color: #04121f;
  box-shadow: 0 6px 20px -6px rgba(56, 189, 248, 0.6);
}
.btn.primary:hover {
  filter: brightness(1.06);
}

/* ============ WORKSPACE ============ */
.workspace {
  display: grid;
  /* toolbar | inspector (giữa, co giãn) | preview bản đồ (phải, kéo được) */
  grid-template-columns: 122px minmax(280px, 1fr) var(--map-w);
  min-height: 0;
  background: var(--bg);
}
.workspace > .toolbar { order: 1; }
.workspace > .inspector { order: 2; }
.workspace > .stage { order: 3; }

/* ===== Bố cục KHUNG DỌC (9:16): map thành cột phải full-height (1/3),
   kéo dài qua cả timeline; timeline thu về góc trái-dưới ===== */
#app.is-portrait {
  position: relative;
  grid-template-columns: 1fr var(--portrait-map-w);
  grid-template-areas:
    "topbar   topbar"
    "work     mapcol"
    "timeline mapcol";
}
#app.is-portrait > .topbar { grid-area: topbar; }
#app.is-portrait > .workspace {
  grid-area: work;
  grid-template-columns: 122px minmax(0, 1fr); /* chỉ toolbar | thuộc tính */
}
#app.is-portrait > .timeline { grid-area: timeline; }
#app.is-portrait .stage {
  position: absolute;
  top: var(--topbar-h);
  right: 0;
  bottom: 0;
  width: var(--portrait-map-w);
  z-index: 5;
}
#app.is-portrait .map-resize { display: none; }

/* khung DỌC: thu nhỏ điều khiển map + transport để không che map */
#app.is-portrait .map-controls {
  top: 8px;
  left: 8px;
  right: 8px;
  width: auto;
  gap: 6px;
}
#app.is-portrait .map-controls .seg-btn {
  padding: 3px 8px;
  font-size: 11px;
}
#app.is-portrait .map-controls .seg-btn svg {
  width: 12px;
  height: 12px;
}
#app.is-portrait .loc-search {
  width: 168px; /* ô tìm kiếm ngắn & hẹp hơn */
  max-width: 100%;
}
#app.is-portrait .loc-search input {
  height: 30px;
  font-size: 12px;
  padding: 0 26px 0 30px;
}
#app.is-portrait .loc-search .loc-icon {
  left: 9px;
}
#app.is-portrait .transport {
  gap: 6px;
  padding: 8px;
}
#app.is-portrait .tbtn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}
#app.is-portrait .tbtn svg {
  width: 15px;
  height: 15px;
}
#app.is-portrait .tbtn.play {
  width: 36px;
  height: 36px;
}
#app.is-portrait .tbtn.play svg {
  width: 17px;
  height: 17px;
}
#app.is-portrait .time-read {
  font-size: 11px;
  margin-left: 6px;
}

/* LEFT TOOLBAR — 2 cột cho gọn */
.toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  align-content: start;
  padding: 10px 6px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.toolbar .tool-sep {
  grid-column: 1 / -1;
}
.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 10px 4px;
  border-radius: 10px;
  transition: all 0.16s var(--ease);
}
.tool svg {
  width: 22px;
  height: 22px;
}
.tool span {
  font-size: 10.5px;
  font-weight: 600;
}
.tool:hover {
  background: var(--panel-2);
  color: var(--fg);
}
.tool.is-active {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.16), rgba(56, 189, 248, 0.04));
  border-color: rgba(56, 189, 248, 0.35);
  color: var(--accent);
}
.tool-sep {
  height: 1px;
  background: var(--line);
  margin: 8px 6px;
}

/* CENTER STAGE */
.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  z-index: 1;
  border-left: 1px solid var(--line);
  background:
    radial-gradient(90% 60% at 50% 0%, rgba(56, 189, 248, 0.05), transparent 60%),
    var(--bg);
}
/* kéo mép trái của khung map để đổi độ rộng map / bảng thuộc tính */
.map-resize {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 12px;
  z-index: 16;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.map-resize::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: transparent;
  transition: background 0.15s var(--ease);
}
.map-resize:hover::before,
.map-resize.dragging::before {
  background: var(--accent);
}
.map-resize-grip {
  width: 4px;
  height: 46px;
  border-radius: 3px;
  background: var(--line-strong);
  transition: background 0.15s var(--ease), height 0.15s var(--ease);
}
.map-resize:hover .map-resize-grip,
.map-resize.dragging .map-resize-grip {
  background: var(--accent);
  height: 64px;
}
body.map-resizing {
  cursor: col-resize;
  user-select: none;
}
body.map-resizing #map {
  pointer-events: none;
}
.map-controls {
  position: absolute;
  top: 12px;
  left: 14px;
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  max-width: calc(100% - 28px);
}
/* 2 nút thu gọn */
.mc-toggles {
  display: flex;
  gap: 8px;
}
.mc-toggle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(15, 21, 35, 0.82);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  color: var(--fg);
  transition: all 0.15s var(--ease);
}
.mc-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.mc-toggle.is-open {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.22), rgba(56, 189, 248, 0.06));
  border-color: var(--accent);
  color: var(--accent);
}
/* bảng sổ ra khi bấm */
.mc-pop {
  background: rgba(15, 21, 35, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  border-radius: 12px;
  padding: 8px;
  animation: mcPop 0.14s var(--ease);
}
.mc-pop[hidden] {
  display: none;
}
.mc-pop .loc-search {
  width: 260px;
  max-width: 60vw;
}
@keyframes mcPop {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}
.map-controls .mc-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap; /* cột hẹp (khung dọc): 2D/3D tự xuống hàng thay vì tràn */
}
.map-controls .seg-btn {
  white-space: nowrap;
}
.map-controls .mc-seg {
  background: rgba(15, 21, 35, 0.82);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
}
/* xoay / nghiêng map 360° */
.mc-view {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 6px;
  min-width: 210px;
}
.mc-slider label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}
.mc-slider label b {
  color: var(--fg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.mc-slider input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  height: 18px;
}
.mc-reset {
  justify-self: start;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: rgba(56, 189, 248, 0.08);
  color: var(--fg);
  cursor: pointer;
}
.mc-reset:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.mc-hint {
  font-size: 10.5px;
  color: var(--faint);
  max-width: 230px;
}
.map-controls .seg-btn {
  padding: 6px 11px;
}

/* ---- location search ---- */
.loc-search {
  position: relative;
}
.loc-search .loc-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.loc-search input {
  width: 100%;
  height: 38px;
  padding: 0 34px 0 36px;
  background: rgba(15, 21, 35, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--fg);
  font-size: 13px;
  box-shadow: var(--shadow);
}
.loc-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow), 0 0 0 3px rgba(56, 189, 248, 0.18);
}
.loc-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: 0;
  background: var(--panel-3);
  color: var(--muted);
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
}
.loc-clear:hover {
  color: var(--fg);
}
.loc-suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
  padding: 5px;
}
.loc-hint {
  padding: 12px;
  text-align: center;
  color: var(--faint);
  font-size: 12.5px;
}
.loc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--fg);
  padding: 9px 10px;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
}
.loc-item:hover,
.loc-item.is-active {
  background: var(--panel-3);
}
.loc-item svg {
  flex-shrink: 0;
  color: var(--accent);
}
.loc-item span {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.loc-item b {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.loc-item em {
  font-size: 11px;
  color: var(--faint);
  font-style: normal;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stage-scroll {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 20px 20px 20px;
  min-height: 0;
  overflow: hidden;
}
.canvas-frame {
  position: relative;
  background: #05070c;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: var(--shadow), 0 0 0 1px var(--line-strong);
  max-height: 100%;
  max-width: 100%;
}
.canvas-frame[data-aspect="16:9"] {
  aspect-ratio: 16 / 9;
  width: min(100%, calc((100cqh - 40px) * 16 / 9));
  height: auto;
}
#map {
  position: absolute;
  inset: 0;
}
.overlay-canvas,
.text-host {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.text-host {
  pointer-events: none;
}
.maplibregl-ctrl-attrib,
.maplibregl-ctrl-logo {
  opacity: 0.5;
  font-size: 9px;
}
.frame-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(5, 8, 14, 0.7);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 6px;
  letter-spacing: 0.03em;
  pointer-events: none;
  z-index: 5;
}
.safe-guides {
  position: absolute;
  inset: 6%;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 4;
}
.canvas-frame.show-guides .safe-guides {
  opacity: 1;
}

.stage-hint {
  position: absolute;
  bottom: 74px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 21, 35, 0.94);
  border: 1px solid var(--line-strong);
  color: var(--fg);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  z-index: 20;
}
.stage-hint.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}
.stage-hint b {
  color: var(--accent);
}

/* transport */
.transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  background: linear-gradient(0deg, var(--panel), transparent);
}
.tbtn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--fg);
  transition: all 0.16s var(--ease);
}
.tbtn:hover {
  background: var(--panel-3);
}
.tbtn.play {
  width: 46px;
  height: 46px;
  border: 0;
  background: linear-gradient(135deg, var(--accent), #5b8cf5);
  color: #04121f;
  box-shadow: 0 6px 20px -6px rgba(56, 189, 248, 0.6);
}
.time-read {
  margin-left: 8px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}
.time-read i {
  color: var(--faint);
  margin: 0 4px;
  font-style: normal;
}
.time-read span:first-child {
  color: var(--fg);
}

/* RIGHT INSPECTOR */
.inspector {
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: 14px;
}
.inspector-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  color: var(--faint);
  padding: 48px 12px;
}
.inspector-empty p {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}
.inspector-empty span {
  font-size: 11.5px;
}

.insp-section {
  margin-bottom: 18px;
}
.insp-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.insp-badge {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--panel-3);
  border: 1px solid var(--line-strong);
}
.insp-title {
  font-weight: 700;
  font-size: 13.5px;
}
.insp-sub {
  font-size: 11px;
  color: var(--faint);
}
.field {
  margin-bottom: 12px;
}
.field > label {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
}
.field .row {
  display: flex;
  gap: 8px;
}
input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  color: var(--fg);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s;
}
textarea {
  resize: vertical;
  min-height: 60px;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
input[type="color"] {
  width: 40px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
}
.range-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.range-row output {
  min-width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--muted);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.14s var(--ease);
}
.chip:hover {
  color: var(--fg);
}
.chip.is-active {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.4);
  color: var(--accent);
}
.swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.swatch {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 0;
  cursor: pointer;
  transition: transform 0.12s var(--ease);
}
.swatch:hover {
  transform: scale(1.15);
}
.swatch.is-active {
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent);
}
.insp-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.btn.block {
  width: 100%;
  justify-content: center;
}
.btn.danger {
  border-color: rgba(244, 84, 123, 0.35);
  color: var(--danger);
}
.btn.danger:hover {
  background: rgba(244, 84, 123, 0.12);
}

/* ============ TIMELINE ============ */
.timeline {
  background: var(--panel);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  z-index: 2;
  overflow: hidden;
}
/* drag the top edge to resize the whole timeline panel */
.tl-resize {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 9px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: row-resize;
  touch-action: none;
}
.tl-resize::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: transparent;
  transition: background 0.15s var(--ease);
}
.tl-resize:hover::before,
.tl-resize.dragging::before {
  background: var(--accent);
}
.tl-resize-grip {
  width: 44px;
  height: 4px;
  border-radius: 3px;
  background: var(--line-strong);
  transition: background 0.15s var(--ease), width 0.15s var(--ease);
}
.tl-resize:hover .tl-resize-grip,
.tl-resize.dragging .tl-resize-grip {
  background: var(--accent);
  width: 60px;
}
body.tl-resizing {
  cursor: row-resize;
  user-select: none;
}
body.tl-resizing #map {
  pointer-events: none;
}
.tl-head {
  display: flex;
  align-items: center;
  justify-content: flex-start; /* tool dồn về bên trái, cạnh tiêu đề */
  gap: 18px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
}
.tl-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 13px;
  color: var(--fg);
}
.tl-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tl-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--fg);
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  transition: all 0.15s var(--ease);
}
.tl-btn:hover {
  background: var(--panel-3);
  border-color: var(--accent);
  color: var(--accent);
}
.tl-div {
  width: 1px;
  height: 20px;
  background: var(--line-strong);
  margin: 0 2px;
}
.dur-input {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.dur-input input {
  width: 58px;
  padding: 5px 8px;
  text-align: center;
}
.zoom-ctl {
  display: flex;
  gap: 2px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
}
.zoom-ctl button {
  width: 26px;
  height: 24px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  font-size: 16px;
  line-height: 1;
}
.zoom-ctl button:hover {
  background: var(--panel-3);
  color: var(--fg);
}

.tl-body {
  flex: 1;
  display: grid;
  grid-template-columns: 176px 1fr;
  min-height: 0;
}
.tl-tracks-labels {
  border-right: 1px solid var(--line);
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--panel);
  scrollbar-width: none;
}
.tl-tracks-labels::-webkit-scrollbar {
  display: none;
}
.track-label-spacer {
  height: 24px;
  position: sticky;
  top: 0;
  z-index: 7;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}
.track-label {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  white-space: nowrap;
}
.track-label .lbl-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}
.track-label .lbl-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.track-label .lbl-actions {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}
.track-label .lbl-ico {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  opacity: 0.55;
  cursor: pointer;
  transition: all 0.14s var(--ease);
}
.track-label:hover .lbl-ico {
  opacity: 0.8;
}
.track-label .lbl-ico:hover {
  background: var(--panel-3);
  color: var(--fg);
  opacity: 1;
}
.track-label .lbl-ico.on {
  color: var(--accent);
  opacity: 1;
}
.track-label.camera-label {
  color: var(--accent-2);
}
.track-label.is-selected {
  background: rgba(56, 189, 248, 0.08);
  color: var(--fg);
}
.track-label.is-locked .lbl-name {
  opacity: 0.55;
}

/* ---- hàng track (có thể chứa nhiều lớp cùng hàng) ---- */
.track-row {
  display: flex;
  align-items: stretch;
  height: 40px;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.track-row.is-newtrack {
  align-items: center;
  justify-content: center;
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  opacity: 0.5;
}
.newtrack-hint {
  pointer-events: none;
}
.mini-label {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1 1 0;
  min-width: 0; /* cho phép co lại khi nhiều lớp chung hàng */
  padding: 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-right: 1px solid var(--line);
}
.track-row .mini-label:last-child {
  border-right: 0;
}
.mini-label:hover {
  background: rgba(255, 255, 255, 0.03);
}
.mini-label.is-selected {
  background: rgba(56, 189, 248, 0.1);
  color: var(--fg);
}
.mini-label .lbl-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}
.mini-label .lbl-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mini-label.is-locked .lbl-name {
  opacity: 0.55;
}
.mini-label .lbl-actions {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}
.mini-label .lbl-ico {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  opacity: 0.55;
  cursor: pointer;
  transition: all 0.14s var(--ease);
}
.mini-label:hover .lbl-ico {
  opacity: 0.8;
}
.mini-label .lbl-ico:hover {
  background: var(--panel-3);
  color: var(--fg);
  opacity: 1;
}
.lane-new {
  min-height: 40px;
  background: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.015),
    rgba(255, 255, 255, 0.015) 8px,
    transparent 8px,
    transparent 16px
  );
}
.lane-new.drop-target {
  background: rgba(56, 189, 248, 0.12);
}
/* chỉ báo tự động lưu */
#autosaveInd {
  position: fixed;
  right: 14px;
  bottom: 12px;
  z-index: 400;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(15, 21, 35, 0.92);
  border: 1px solid var(--line-strong);
  color: var(--ok);
  font-size: 11.5px;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  pointer-events: none;
}
#autosaveInd.show {
  opacity: 1;
  transform: translateY(0);
}
/* hộp quét chọn nhiều lớp (rubber-band) */
.sel-box {
  position: absolute;
  z-index: 30;
  border: 1px solid var(--accent);
  background: rgba(56, 189, 248, 0.14);
  border-radius: 3px;
  pointer-events: none;
}

.tl-scroll {
  position: relative;
  overflow: auto;
}
/* thanh cuộn ngang timeline — sáng & to hơn cho dễ kéo */
.tl-scroll::-webkit-scrollbar {
  height: 12px;
  width: 12px;
}
.tl-scroll::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
}
.tl-scroll::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 189, 0.55);
  border-radius: 8px;
  border: 2px solid var(--panel);
}
.tl-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}
.tl-scroll {
  scrollbar-width: auto;
  scrollbar-color: rgba(148, 163, 189, 0.55) rgba(255, 255, 255, 0.04);
}
.tl-ruler {
  position: sticky;
  top: 0;
  height: 24px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  z-index: 6;
}
.tl-ruler .tick {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px solid var(--line);
  padding-left: 5px;
  font-size: 10px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
}
.tl-lanes {
  position: relative;
}
.lane {
  position: relative;
  height: 40px;
  border-bottom: 1px solid var(--line);
}
.lane.camera-lane {
  background: rgba(192, 132, 252, 0.04);
}
.lane.is-selected {
  background: rgba(56, 189, 248, 0.06);
}
.lane.drop-target {
  background: rgba(56, 189, 248, 0.1);
}

/* clips */
.clip {
  position: absolute;
  top: 5px;
  height: 30px;
  border-radius: 7px;
  background: linear-gradient(180deg, var(--elevated), var(--panel-3));
  border: 1px solid var(--line-strong);
  display: flex;
  align-items: center;
  padding: 0 9px;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--fg);
  cursor: grab;
  overflow: hidden;
  user-select: none;
  box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.5);
}
.clip:active {
  cursor: grabbing;
}
.clip.has-thumb {
  background-size: auto 100%;
  background-repeat: repeat-x;
  background-position: center;
}
.clip.has-thumb .clip-name {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}
.clip.dragging {
  z-index: 20;
  opacity: 0.92;
  box-shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.7);
  cursor: grabbing;
}
.clip.is-locked {
  opacity: 0.6;
  cursor: not-allowed;
}
.clip.is-locked .handle {
  display: none;
}
.clip.is-selected {
  outline: 2px solid #ffffff;
  outline-offset: -1px;
  box-shadow: 0 0 0 1px var(--accent);
}
/* audio & video: clip cao hơn 1 chút so với các loại khác */
.clip.av-clip {
  top: 2px;
  height: 36px;
}
/* waveform nền trong clip audio/video */
.clip .clip-wave {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.9;
}
.clip .clip-ico,
.clip .clip-name {
  position: relative;
  z-index: 1;
}
.clip .clip-ico {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  opacity: 0.85;
}
.clip .clip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.clip.av-clip .clip-name {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
.clip .handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10px;
  cursor: ew-resize;
  display: flex;
  align-items: center;
  justify-content: center;
}
.clip .handle::before {
  content: "";
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.75);
  opacity: 0;
  transition: opacity 0.14s var(--ease);
}
.clip:hover .handle::before,
.clip.is-selected .handle::before {
  opacity: 0.85;
}
.clip .handle.l {
  left: 0;
}
.clip .handle.r {
  right: 0;
}
.clip[data-type="plot"] {
  background: linear-gradient(180deg, rgba(245, 185, 66, 0.32), rgba(245, 185, 66, 0.14));
  border-color: rgba(245, 185, 66, 0.5);
}
.clip[data-type="road"] {
  background: linear-gradient(180deg, rgba(56, 245, 200, 0.28), rgba(56, 245, 200, 0.12));
  border-color: rgba(56, 245, 200, 0.5);
}
.clip[data-type="text"] {
  background: linear-gradient(180deg, rgba(91, 140, 245, 0.32), rgba(91, 140, 245, 0.14));
  border-color: rgba(91, 140, 245, 0.5);
}
.clip[data-type="element"] {
  background: linear-gradient(180deg, rgba(192, 132, 252, 0.3), rgba(192, 132, 252, 0.12));
  border-color: rgba(192, 132, 252, 0.5);
}
.clip[data-type="media"] {
  background: linear-gradient(180deg, rgba(74, 222, 128, 0.26), rgba(74, 222, 128, 0.1));
  border-color: rgba(74, 222, 128, 0.5);
}
.clip[data-type="audio"] {
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.26), rgba(34, 211, 238, 0.1));
  border-color: rgba(34, 211, 238, 0.5);
}
.clip[data-type="arrow"] {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.3), rgba(56, 189, 248, 0.12));
  border-color: rgba(56, 189, 248, 0.5);
}

/* ---- sound library modal ---- */
.modal.sound-modal {
  width: 560px;
  max-width: calc(100vw - 24px);
  display: flex;
  flex-direction: column;
  max-height: 82vh;
}
.sound-toolbar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
#soundSearch {
  margin-bottom: 10px;
}
.sound-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 84px;
  overflow-y: auto;
}
.scat {
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s var(--ease);
}
.scat em {
  color: var(--faint);
  font-style: normal;
  font-size: 10px;
}
.scat:hover {
  color: var(--fg);
}
.scat.is-active {
  background: rgba(34, 211, 238, 0.16);
  border-color: rgba(34, 211, 238, 0.5);
  color: #22d3ee;
}
.sound-list {
  overflow-y: auto;
  padding: 8px;
  flex: 1;
  min-height: 200px;
}
.sound-empty {
  text-align: center;
  color: var(--faint);
  padding: 50px 16px;
  font-size: 13px;
  line-height: 1.6;
}
.sound-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  transition: background 0.12s;
}
.sound-row:hover {
  background: var(--panel-2);
}
.sound-row.playing {
  background: rgba(34, 211, 238, 0.1);
}
.sound-play {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--panel-3);
  color: var(--fg);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.sound-row.playing .sound-play {
  background: #22d3ee;
  color: #04121f;
  border-color: #22d3ee;
}
.sound-meta {
  flex: 1;
  min-width: 0;
}
.sound-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sound-cat {
  font-size: 10.5px;
  color: var(--faint);
}
.sound-add {
  flex-shrink: 0;
}

/* keyframe diamonds */
.kf {
  position: absolute;
  top: 50%;
  width: 13px;
  height: 13px;
  transform: translate(-50%, -50%) rotate(45deg);
  background: var(--accent-2);
  border: 1.5px solid #fff;
  border-radius: 2px;
  cursor: grab;
  z-index: 3;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.kf:hover {
  background: #fff;
}
.kf.is-selected {
  background: #fff;
  box-shadow: 0 0 0 3px rgba(192, 132, 252, 0.5);
}

.tl-playhead {
  position: absolute;
  top: 0;
  height: 100%;
  min-height: 100%;
  width: 1px;
  background: var(--accent);
  z-index: 10;
  pointer-events: none;
}
.tl-playhead span {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 12px;
  background: var(--accent);
  clip-path: polygon(50% 100%, 0 0, 100% 0);
}

/* ============ POPOVER / ELEMENTS ============ */
.popover {
  position: fixed;
  z-index: 200;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px;
  width: 320px;
}
.popover-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 12px;
}
.element-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.el-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 4px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  transition: all 0.14s var(--ease);
}
.el-item:hover {
  background: var(--panel-3);
  color: var(--fg);
  transform: translateY(-2px);
}
.el-item svg {
  width: 24px;
  height: 24px;
}
.el-item span {
  font-size: 10px;
  font-weight: 600;
}

/* ============ MODAL ============ */
.modal-scrim {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 12, 0.68);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 300;
  animation: fade 0.2s var(--ease);
}
.modal {
  width: 440px;
  max-width: calc(100vw - 32px);
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: var(--shadow);
  animation: pop 0.28s var(--ease);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 {
  font-size: 16px;
}
.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
}
.icon-btn:hover {
  background: var(--panel-3);
  color: var(--fg);
}
.modal-body {
  padding: 18px;
}
.export-options {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.opt {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.export-progress {
  margin-top: 8px;
}
.export-progress .bar {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.export-progress .bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.2s;
}
.export-status {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}
.modal.export-modal {
  width: 620px;
}
.modal.export-modal .modal-body {
  max-height: 66vh;
  overflow-y: auto;
}
.modal.auth-modal {
  width: 400px;
}

/* ---- auth ---- */
.google-signin {
  margin-bottom: 14px;
}
.google-signin #googleBtn {
  display: flex;
  justify-content: center;
  min-height: 40px;
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 2px;
  color: var(--faint);
  font-size: 11px;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 16px;
}
.auth-tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 9px;
  border-radius: 7px;
  font-weight: 700;
  font-size: 13px;
}
.auth-tab.is-active {
  background: var(--panel-3);
  color: var(--fg);
}
.auth-error {
  background: rgba(244, 84, 123, 0.12);
  border: 1px solid rgba(244, 84, 123, 0.35);
  color: #ffb3c6;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  margin-bottom: 12px;
}
.auth-note {
  font-size: 11.5px;
  color: var(--faint);
  text-align: center;
  margin: 14px 0 0;
}
.auth-back {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 0;
  margin-bottom: 12px;
  cursor: pointer;
}
.auth-back:hover {
  color: var(--fg);
}
.auth-code-msg {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin: 4px 0 16px;
  line-height: 1.5;
}
.auth-code-msg b {
  color: var(--fg);
}
.code-input {
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 14px;
  font-family: "Sora", monospace;
  padding: 12px !important;
}
.auth-resend {
  text-align: center;
  font-size: 12px;
  color: var(--faint);
  margin-top: 14px;
}
.auth-resend button {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}
.dev-code {
  margin: 12px 0 0;
  font-size: 11.5px;
  color: var(--plot);
  background: rgba(245, 185, 66, 0.08);
  border: 1px solid rgba(245, 185, 66, 0.25);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: center;
}

/* ---- account bar ---- */
.account-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.account-bar:empty {
  display: none;
}
.acc-email {
  font-weight: 700;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.acc-usage {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
}
.btn.sm {
  padding: 6px 11px;
  font-size: 12px;
}
.plan-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}
.plan-badge.free {
  background: var(--panel-3);
  color: var(--muted);
}
.plan-badge.pro {
  background: linear-gradient(135deg, var(--accent), #5b8cf5);
  color: #04121f;
}
.plan-badge.promax {
  background: linear-gradient(135deg, #f5b942, #f97316);
  color: #1a1204;
}

/* ---- nút tài khoản trên thanh trên ---- */
.top-account {
  position: relative;
}
.top-account .top-acc-btn {
  gap: 7px;
}
.top-account .acc-avatar {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04121f;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}
.top-account .acc-name {
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.acc-pop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 500;
  animation: pop 0.14s var(--ease);
}
.acc-pop[hidden] {
  display: none;
}
.acc-pop-email {
  font-size: 11.5px;
  color: var(--muted);
  padding: 6px 10px 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
  word-break: break-all;
}
.acc-pop-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--fg);
  font-size: 12.5px;
  font-weight: 600;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.acc-pop-item:hover {
  background: var(--panel-3);
}
.acc-pop-item.danger {
  color: var(--danger);
}

/* ---- plans ---- */
.plans-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}
.cycle-toggle {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.cycle-toggle button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
}
.cycle-toggle button em {
  color: var(--ok);
  font-style: normal;
  font-size: 10px;
}
.cycle-toggle button.is-active {
  background: var(--panel-3);
  color: var(--fg);
}
.plan-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.plan-card {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 14px 13px;
  display: flex;
  flex-direction: column;
}
.plan-card.featured {
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.25);
}
.plan-card.current {
  border-color: var(--ok);
}
.plan-tag {
  position: absolute;
  top: -8px;
  right: 10px;
  background: linear-gradient(135deg, var(--accent), #5b8cf5);
  color: #04121f;
  font-size: 9.5px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}
.plan-name {
  font-weight: 800;
  font-size: 14px;
  font-family: "Sora", sans-serif;
}
.plan-price {
  font-size: 19px;
  font-weight: 800;
  margin: 6px 0 2px;
  font-family: "Sora", sans-serif;
}
.plan-price small {
  font-size: 11px;
  color: var(--faint);
  font-weight: 600;
}
.plan-sub {
  font-size: 10.5px;
  color: var(--faint);
  margin-bottom: 8px;
}
.plan-feats {
  list-style: none;
  padding: 0;
  margin: 6px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}
.plan-feats li {
  font-size: 11.5px;
  color: var(--muted);
  padding-left: 16px;
  position: relative;
}
.plan-feats li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--ok);
  font-weight: 800;
}
.mock-note {
  font-size: 11px;
  color: var(--plot);
  background: rgba(245, 185, 66, 0.08);
  border: 1px solid rgba(245, 185, 66, 0.25);
  border-radius: 8px;
  padding: 8px 10px;
  margin: 14px 0 4px;
}
.export-options-title {
  font-weight: 700;
  font-size: 13px;
  margin: 4px 0 10px;
  color: var(--fg);
}
@media (max-width: 680px) {
  .plan-grid {
    grid-template-columns: 1fr;
  }
  .modal.export-modal {
    width: calc(100vw - 24px);
  }
}

/* ============ TOAST ============ */
.toast-host {
  position: fixed;
  bottom: 22px;
  right: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 400;
}
.toast {
  background: var(--panel-3);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--accent);
  color: var(--fg);
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s var(--ease);
  max-width: 320px;
}
.toast.ok {
  border-left-color: var(--ok);
}
.toast.err {
  border-left-color: var(--danger);
}

/* text overlay element */
.text-item {
  position: absolute;
  transform: translate(-50%, -50%);
  white-space: pre-wrap;
  text-align: center;
  pointer-events: auto;
  cursor: move;
  line-height: 1.15;
  font-family: "Sora", "Manrope", sans-serif;
  max-width: 80%;
}
.text-item.is-selected {
  outline: 1px dashed var(--accent);
  outline-offset: 6px;
}
/* corner handle to resize text / media directly on the canvas */
.ov-resize {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  cursor: nwse-resize;
  pointer-events: auto;
  z-index: 3;
}
.media-item .ov-resize {
  right: -8px;
  bottom: -8px;
}
/* callout speech-box with a pointed tail — khung góc vuông, mặc định nền trắng */
.text-item.callout {
  background: var(--callout-bg, #ffffff);
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 0;
  padding: 0.5em 0.8em;
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.5);
}
.text-item.callout::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -0.5em;
  transform: translateX(-50%);
  border-left: 0.5em solid transparent;
  border-right: 0.5em solid transparent;
  border-top: 0.5em solid var(--callout-bg, #ffffff);
}
/* khung callout cho ảnh/video — góc vuông + mũi tên chỉ xuống */
.media-item.framed::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 100%);
  border-left: var(--arrow-w, 14px) solid transparent;
  border-right: var(--arrow-w, 14px) solid transparent;
  border-top: var(--arrow-h, 14px) solid var(--frame-bg, #fff);
  filter: drop-shadow(0 5px 3px rgba(0, 0, 0, 0.25));
}
.text-item.callout.is-selected {
  outline-offset: 3px;
}

/* right-click context menu */
.ctx-menu {
  position: fixed;
  z-index: 500;
  min-width: 190px;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 5px;
  animation: pop 0.14s var(--ease);
}
.ctx-menu button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--fg);
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
}
.ctx-menu button:hover {
  background: var(--panel-3);
}
.ctx-menu button.danger {
  color: var(--danger);
}
.ctx-menu .sep {
  height: 1px;
  background: var(--line);
  margin: 4px 2px;
}
/* while drawing plots/roads or placing elements, let clicks reach the map */
.canvas-frame.drawing .text-item {
  pointer-events: none !important;
}
.canvas-frame.drawing #map {
  cursor: crosshair;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}
@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(8px);
  }
}
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
}

/* scrollbars */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--panel-3);
  border-radius: 999px;
  border: 2px solid var(--panel);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--elevated);
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 110px minmax(240px, 1fr) var(--map-w);
  }
}
