/* ============================================================
   Canvas — design tokens & shared primitives
   Dark, near-black canvas product UI
   ============================================================ */

:root {
  --bg: #0b0b0c;
  --bg-canvas: #0c0c0d;
  --bg-panel: #171718;
  --bg-panel-2: #1c1c1e;
  --bg-input: #131314;
  --bg-hover: #232326;
  --bg-active: #2a2a2e;

  --line: rgba(255, 255, 255, 0.075);
  --line-2: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.9);

  --text: #ececee;
  --text-2: #a2a2a8;
  --text-3: #6e6e76;
  --text-4: #4a4a50;

  --accent: #6ea8ff;
  --accent-2: #4d8dff;
  --accent-soft: rgba(96, 156, 255, 0.16);
  --gold: #e9c98d;
  --gold-2: #c9a566;
  --danger: #ff6b6b;
  --ok: #57d39b;

  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;

  --shadow-menu: 0 18px 50px rgba(0, 0, 0, 0.62), 0 0 0 1px rgba(255, 255, 255, 0.055);
  --shadow-panel: 0 24px 80px rgba(0, 0, 0, 0.6);
  --shadow-node: 0 20px 50px rgba(0, 0, 0, 0.42);

  --font: "Inter", "SF Pro Text", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, monospace;

  --topbar-h: 56px;
  --rail-w: 46px;
  --ease: cubic-bezier(0.22, 0.7, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

body { overflow: hidden; }

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

input, textarea {
  font-family: inherit;
  color: inherit;
}

a { color: inherit; text-decoration: none; }

::selection { background: rgba(110, 168, 255, 0.32); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

.hidden { display: none !important; }

/* ---------- icons ---------- */
.ic {
  display: inline-block;
  flex: none;
  vertical-align: middle;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ic-fill { fill: currentColor; stroke: none; }

/* ---------- generic icon button ---------- */
.icon-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  color: var(--text-2);
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.is-active { background: var(--bg-active); color: var(--text); }
.icon-btn.square {
  background: var(--bg-panel);
  box-shadow: inset 0 0 0 1px var(--line);
}
.icon-btn.square:hover { background: var(--bg-hover); }

.btn {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-md);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text);
  background: var(--bg-panel);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background 0.16s var(--ease), box-shadow 0.16s var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); }
.btn.primary {
  background: #f1f1f2;
  color: #151516;
  box-shadow: none;
  font-weight: 600;
}
.btn.primary:hover { background: #fff; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { color: var(--text); background: var(--bg-hover); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

/* ---------- brand ---------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.brand-mark {
  width: 22px;
  height: 22px;
  position: relative;
  flex: none;
}
.brand-mark svg { display: block; width: 100%; height: 100%; }
.brand-name {
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: #f4f4f5;
}
.brand-name .thin { font-weight: 400; color: #c9c9cd; }

/* ---------- menus ---------- */
.menu {
  position: fixed;
  z-index: 900;
  min-width: 196px;
  padding: 6px;
  background: #1b1b1d;
  border-radius: 12px;
  box-shadow: var(--shadow-menu);
  animation: menu-in 0.13s var(--ease);
  backdrop-filter: blur(18px);
}
@keyframes menu-in {
  from { opacity: 0; transform: translateY(4px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
.menu-header {
  padding: 7px 9px 6px;
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.02em;
}
.menu-item {
  width: 100%;
  min-height: 34px;
  padding: 6px 9px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  text-align: left;
  transition: background 0.12s var(--ease);
}
.menu-item .ic { color: var(--text-2); }
.menu-item:hover, .menu-item.is-hover { background: #2a2a2d; }
.menu-item.is-hover .ic { color: var(--text); }
.menu-item .sub {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--text-3);
}
.menu-item .badge {
  margin-left: auto;
  font-size: 9px;
  padding: 2px 5px;
  border-radius: 4px;
  color: #0f0f10;
  background: #d9d9dc;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.menu-item .kbd {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--text-3);
  font-family: var(--mono);
}
.menu-sep { height: 1px; margin: 6px 7px; background: var(--line); }
.menu-item.danger { color: #ff8b8b; }
.menu-item.danger .ic { color: #ff8b8b; }
.menu-item[disabled] { opacity: 0.4; pointer-events: none; }

.submenu-host { position: relative; }
.submenu-host > .menu { top: -6px; left: calc(100% + 6px); }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(3px);
  animation: fade-in 0.16s var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(440px, calc(100vw - 48px));
  background: #18181a;
  border-radius: 14px;
  box-shadow: var(--shadow-panel), inset 0 0 0 1px var(--line);
  overflow: hidden;
  animation: modal-in 0.18s var(--ease);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px 12px;
}
.modal-title { font-size: 14px; font-weight: 600; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 4px 18px 18px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,0.012);
}
.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 11.5px;
  color: var(--text-2);
  margin-bottom: 6px;
}
.field input, .field textarea, .field select {
  width: 100%;
  background: #101011;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 12.5px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus, .field textarea:focus { border-color: rgba(110,168,255,0.7); }
.field .hint { font-size: 10.5px; color: var(--text-3); margin-top: 6px; line-height: 1.5; }

/* ---------- toast ---------- */
.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 12.5px;
  color: var(--text);
  background: #202022;
  border-radius: 9px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5), inset 0 0 0 1px var(--line);
  animation: toast-in 0.2s var(--ease);
}
.toast.leaving { animation: toast-out 0.18s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ---------- misc ---------- */
.divider-v { width: 1px; height: 16px; background: var(--line-2); }
.spacer { flex: 1; }
.muted { color: var(--text-2); }
.tiny { font-size: 11px; }
.row { display: flex; align-items: center; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }

.tooltip {
  position: fixed;
  z-index: 1500;
  padding: 6px 8px;
  font-size: 11px;
  color: var(--text);
  background: #242427;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45), inset 0 0 0 1px var(--line);
  pointer-events: none;
  white-space: nowrap;
  animation: fade-in 0.1s var(--ease);
}

.avatar {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background:
    radial-gradient(120% 120% at 20% 10%, #9dc2ff 0%, #5577e8 42%, #6c3fbf 78%, #2b1d55 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16);
  flex: none;
}

.scroll-y { overflow-y: auto; }
