*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  min-width: 320px;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, h4, p { margin: 0; }
img { max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
::selection { background: rgba(48, 131, 255, 0.2); }
* { scrollbar-width: thin; scrollbar-color: #c8d4ea transparent; }
.muted { color: var(--text-3); }
.mono, .mono-input { font-family: var(--mono); font-size: 0.9em; letter-spacing: 0; }
.mono-small { font-family: var(--mono); font-size: 11.5px; word-break: break-all; }
.text-work { color: var(--work); font-weight: 500; }
.text-blocked { color: var(--blocked); font-weight: 500; }

/* ---- Shell ------------------------------------------------------------ */

.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); height: 100vh; }
.app.is-loading .side { opacity: 0.6; }

.side {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100vh;
  padding: 18px 12px 12px;
  overflow-y: auto;
}
.side-top { display: grid; gap: 16px; padding: 0 4px 6px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px; text-decoration: none; }
.brand img { height: 23px; width: auto; display: block; }
.brand__divider { width: 1px; height: 18px; background: var(--blue-300); }
.brand__name { font-size: 13px; font-weight: 500; color: var(--text-2); letter-spacing: -0.005em; }

.search-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  padding: 0 8px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-3);
  font-size: 13px;
  text-align: left;
  box-shadow: var(--shadow-1);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-trigger span { flex: 1; }
.search-trigger:hover { border-color: var(--blue-300); color: var(--text-2); }

.nav { display: grid; gap: 2px; }
.nav__group { display: grid; gap: 2px; }
.nav__label { padding: 16px 12px 6px; font-size: 11.5px; font-weight: 500; color: var(--text-3); }
.nav__item {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 36px;
  padding: 0 10px 0 12px;
  border-radius: 9px;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav__item .i { color: #7f8db0; flex: none; transition: color 0.15s; }
.nav__item:hover { background: rgba(19, 52, 102, 0.045); color: var(--navy); }
.nav__item.is-active { background: var(--surface); color: var(--navy); box-shadow: 0 0 0 1px var(--line), var(--shadow-1); }
.nav__item.is-active .i { color: var(--blue); }
.nav__count { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--text-3); }
.nav__flag { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--work-bg); color: var(--work); font-size: 11.5px; font-weight: 600; line-height: 19px; text-align: center; }

.side-foot { display: grid; gap: 4px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }
.save { display: flex; align-items: center; gap: 8px; padding: 6px 12px 2px; font-size: 12px; color: var(--text-3); }
.save__dot { width: 7px; height: 7px; border-radius: 50%; background: #7cc4a5; }
.save[data-phase="saving"] .save__dot, .save[data-phase="pending"] .save__dot { background: var(--blue); animation: pulse 1s ease-in-out infinite; }
.save[data-phase="error"] { color: var(--blocked); font-weight: 500; }
.save[data-phase="error"] .save__dot { background: var(--blocked); }

.stage { min-width: 0; height: 100vh; padding: 8px 8px 8px 0; }
.main {
  position: relative;
  height: 100%;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.view { max-width: 1260px; margin: 0 auto; padding: 34px 44px 96px; }
.mobile-bar, .nav-scrim { display: none; }
.save-warning { position: sticky; top: 0; z-index: 6; padding: 10px 44px; border-bottom: 1px solid var(--work-line); background: var(--work-bg); color: var(--work-ink); font-size: 13px; font-weight: 500; }

.boot { height: 3px; margin: 120px auto; max-width: 240px; overflow: hidden; border-radius: 2px; background: var(--chip); }
.boot__bar { display: block; width: 35%; height: 100%; background: var(--blue); animation: boot 1.1s var(--ease) infinite; }
.boot-error { max-width: 560px; margin: 80px auto; display: grid; gap: 12px; }
.boot-error h1 { font-size: 22px; color: var(--navy); }

@keyframes boot { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes flash { from { background-color: var(--blue-100); } to { background-color: transparent; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -6px) scale(0.985); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.view.is-entering > * { animation: rise 0.28s var(--ease) both; }
.view.is-entering > *:nth-child(2) { animation-delay: 0.03s; }
.view.is-entering > *:nth-child(3) { animation-delay: 0.06s; }
.view.is-entering > *:nth-child(n + 4) { animation-delay: 0.09s; }
.is-flash { animation: flash 1.8s var(--ease); border-radius: var(--radius); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
