/* ============================================================================
   AVELIS — dark theme
   Top-bar navigation (no left rail), compact density, dark ground.
   ========================================================================== */

@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url("../assets/fonts/inter-400.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url("../assets/fonts/inter-500.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url("../assets/fonts/inter-600.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap; src: url("../assets/fonts/inter-700.woff2") format("woff2"); }

:root {
  --bg:        #1a1a1e;
  --bg-soft:   #1e1e22;
  --panel:     #222226;
  --panel-2:   #2a2a2f;
  --panel-3:   #333338;
  --line:      #2a2a2f;
  --line-2:    #3a3a42;

  --ink:       #e8e8ec;
  --ink-dim:   #8a8a94;
  --ink-faint: #5a5a64;

  --accent:     #7c6cff;
  --accent-lo:  #9d90ff;
  --accent-glow: rgba(124, 108, 255, 0.16);

  --primary:     #e8e8ec;
  --primary-ink: #1a1a1e;

  --ok:   #35c46a;
  --warn: #e0a53a;
  --err:  #ff5a5f;

  --radius:    6px;
  --radius-lg: 10px;

  --elev-1: 0 1px 2px rgba(0,0,0,0.4);
  --elev-2: 0 8px 24px rgba(0,0,0,0.5);

  --mono: "Cascadia Code", "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;

  --bar-h: 36px;

  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --dur:  160ms;
}

:root[data-theme="light"] {
  --bg:        #f2f2f4;
  --bg-soft:   #ebebee;
  --panel:     #ffffff;
  --panel-2:   #f6f6f8;
  --panel-3:   #eeeef1;
  --line:      #e2e2e6;
  --line-2:    #d2d2d8;
  --ink:       #131316;
  --ink-dim:   #55555f;
  --ink-faint: #8a8a94;
  --primary:     #131316;
  --primary-ink: #ffffff;
  --elev-1: 0 1px 2px rgba(16,16,20,0.06);
  --elev-2: 0 10px 30px rgba(16,16,20,0.12);
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 12.5px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  user-select: none;
}

::selection { background: var(--accent-glow); color: var(--ink); }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #3a3944; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

button { font-family: inherit; cursor: pointer; color: inherit; border: none; background: none; }
input, textarea { font-family: inherit; }
a { color: var(--accent-lo); text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.mono { font-family: var(--mono); }
.eyebrow {
  font-size: 10px; font-weight: 600; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--ink-faint);
}
.tnum { font-variant-numeric: tabular-nums; }

/* ============================================================================
   Shell — single column: titlebar on top, content below
   ========================================================================== */
#app {
  display: grid;
  grid-template-rows: var(--bar-h) 1fr;
  grid-template-columns: 1fr;
  grid-template-areas: "bar" "main";
  height: 100vh;
  border-radius: 8px;
  overflow: hidden;
}

/* --- Titlebar --------------------------------------------------------------*/
.titlebar {
  grid-area: bar;
  display: flex; align-items: center;
  padding: 0 8px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 40;
}

.tb-left {
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0;
  padding-right: 10px;
}
.tb-mark { width: 18px; height: 18px; flex-shrink: 0; display: grid; place-items: center; }
.tb-mark img { width: 18px; height: 18px; border-radius: 4px; object-fit: cover; }
.tb-word {
  font-weight: 700; font-size: 13px; letter-spacing: -0.01em; color: var(--ink);
  position: static; transform: none; pointer-events: none;
}

/* Segmented nav control in the titlebar center */
.tb-nav {
  position: relative;
  display: flex; align-items: center; gap: 1px;
  flex-shrink: 0;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 2px;
}
.tb-nav-ind { display: none; }
.tb-nav-btn {
  position: relative; z-index: 1;
  width: 32px; height: 24px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--ink-faint);
  background: transparent;
  transition: color 0.18s var(--ease), background 0.22s var(--ease), transform var(--dur) var(--ease);
}
.tb-nav-btn svg { width: 15px; height: 15px; transition: transform var(--dur) var(--ease); }
.tb-nav-btn:hover { color: var(--ink-dim); }
.tb-nav-btn:hover svg { transform: scale(1.1); }
.tb-nav-btn:active svg { transform: scale(0.92); }
.tb-nav-btn.active { color: #fff; background: var(--accent); }

.tb-drag { flex: 1; align-self: stretch; }

.tb-controls { display: flex; align-items: center; gap: 2px; }
.tb-btn { width: 32px; height: 28px; display: grid; place-items: center; border-radius: 6px; color: var(--ink-dim); transition: background var(--dur), color var(--dur); }
.tb-btn:hover { background: var(--panel-2); color: var(--ink); }
.tb-btn.close:hover { background: var(--err); color: #fff; }
.tb-btn svg { width: 17px; height: 17px; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

/* --- Main / views ----------------------------------------------------------*/
.main { grid-area: main; position: relative; overflow: hidden; background: var(--bg); }
.view {
  position: absolute; inset: 0; overflow: auto;
  padding: 16px 20px 20px;
  opacity: 0; pointer-events: none;
}
.view.active { opacity: 1; pointer-events: auto; animation: viewIn 0.34s var(--ease); }
.view.no-pad { padding: 0; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(10px) scale(0.994); }
  to   { opacity: 1; transform: none; }
}

.view-head { margin-bottom: 14px; }
.view-head h1 { font-size: 18px; font-weight: 650; letter-spacing: -0.02em; color: var(--ink); margin-top: 4px; }
.view-head p { color: var(--ink-dim); font-size: 11.5px; margin-top: 2px; max-width: 60ch; }

/* Staggered entrance for direct children of a view */
.view.active > * { animation: riseIn 0.3s var(--ease) both; }
.view.active > *:nth-child(2) { animation-delay: 0.03s; }
.view.active > *:nth-child(3) { animation-delay: 0.06s; }
.view.active > *:nth-child(4) { animation-delay: 0.09s; }
@keyframes riseIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============================================================================
   Panels
   ========================================================================== */
.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--elev-1);
}
.panel-hd { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.panel-bd { padding: 12px; }

/* ============================================================================
   Controls
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 10px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-dim);
  font-size: 12px; font-weight: 500;
  box-shadow: none;
  transition: background var(--dur), color var(--dur), transform var(--dur) var(--ease);
}
.btn svg { width: 13px; height: 13px; opacity: 0.7; }
.btn:hover { background: var(--panel-2); color: var(--ink); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--ink); color: var(--bg); font-weight: 600; }
.btn.primary:hover { background: #fff; }
.btn.primary svg { opacity: 1; }
.btn.ghost { background: transparent; color: var(--ink-dim); }
.btn.ghost:hover { background: var(--panel-2); color: var(--ink); }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: rgba(255,90,95,0.12); }
.btn.accent { background: var(--accent); color: #fff; }
.btn.accent:hover { background: var(--accent-lo); }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn.icon-only { width: 24px; padding: 0; justify-content: center; }

.input {
  height: 24px;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 5px;
  color: var(--ink);
  font-size: 12px; padding: 0 8px;
  transition: border-color var(--dur), box-shadow var(--dur), background var(--dur);
}
.input::placeholder { color: var(--ink-faint); }
.input:focus { outline: none; border-color: var(--accent); background: var(--panel); box-shadow: 0 0 0 3px var(--accent-glow); }

/* Toggle — pill, accent when on */
.switch { position: relative; width: 30px; height: 16px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track { position: absolute; inset: 0; background: var(--panel-3); border: 1px solid var(--line-2); border-radius: 999px; transition: background var(--dur), border-color var(--dur); }
.switch .track::before { content: ""; position: absolute; left: 2px; top: 2px; width: 10px; height: 10px; background: var(--ink-faint); border-radius: 50%; transition: transform var(--dur) var(--ease), background var(--dur); }
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::before { transform: translateX(14px); background: #fff; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 16px; padding: 0 6px;
  border: 1px solid var(--line-2); border-radius: 999px;
  font-size: 9.5px; font-weight: 600; color: var(--ink-dim);
}
.chip .d { width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.chip.ok  { color: var(--ok);  border-color: rgba(53,196,106,0.35);  background: rgba(53,196,106,0.08); }
.chip.warn{ color: var(--warn);border-color: rgba(224,165,58,0.35); background: rgba(224,165,58,0.08); }
.chip.ember { color: var(--accent-lo); border-color: rgba(124,108,255,0.4); background: var(--accent-glow); }

/* ============================================================================
   Context menu (shared)
   ========================================================================== */
.ctx-menu {
  position: fixed; z-index: 9500;
  min-width: 170px; padding: 4px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  box-shadow: var(--elev-2);
  transform-origin: top left;
  animation: ctxIn 0.14s var(--ease);
}
@keyframes ctxIn { from { opacity: 0; transform: scale(0.94) translateY(-4px); } to { opacity: 1; transform: none; } }
.ctx-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; height: 28px; padding: 0 8px;
  border-radius: 5px; color: var(--ink-dim);
  font-size: 12px; text-align: left;
  transition: background var(--dur), color var(--dur);
}
.ctx-item svg { width: 14px; height: 14px; opacity: 0.85; }
.ctx-item:hover { background: var(--panel-3); color: var(--ink); }
.ctx-item.danger { color: var(--err); }
.ctx-item.danger:hover { background: rgba(255,90,95,0.12); }
.ctx-item .kbd { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--ink-faint); }
.ctx-sep { height: 1px; background: var(--line); margin: 3px 5px; }

/* ============================================================================
   Toasts
   ========================================================================== */
#toasts { position: fixed; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 9999; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 8px;
  min-width: 200px; max-width: 320px; padding: 8px 10px;
  background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: var(--radius); box-shadow: var(--elev-2);
  color: var(--ink); font-size: 11.5px;
  transform: translateX(120%); opacity: 0;
  transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
  pointer-events: auto;
}
.toast.show { transform: none; opacity: 1; }
.toast .ic { flex-shrink: 0; width: 14px; height: 14px; color: var(--ink-dim); }
.toast.ok .ic { color: var(--ok); }
.toast.err .ic { color: var(--err); }
.toast.info .ic { color: var(--accent-lo); }
.toast .msg { flex: 1; line-height: 1.35; }

/* Note: we intentionally do NOT globally disable animations under
   prefers-reduced-motion — the app's motion is core to its feel and users
   asked for it. Only the ambient status pulse is toned down. */
@media (prefers-reduced-motion: reduce) {
  .tb-status.live .tb-dot { animation: none; }
}
