/* ============================================================
   StartBy brand layer — loaded after app.css and the inline overrides in
   base.html. Cobalt palette + a fuller, roomier sidebar.
   Delete the <link> in base.html to fall back to the previous look.
   ============================================================ */
:root {
  --sidebar-w: 280px;
  --brand-1: var(--color-primary);
  --brand-2: var(--color-primary);
  --brand-ink: var(--color-primary);
}

/* ---------- Sidebar shell ---------- */
.app-sidebar .brand-monogram__logo { width: 42px !important; height: 42px !important; border-radius: 12px !important; }
.app-sidebar {
  width: var(--sidebar-w) !important;
  background: var(--color-surface) !important;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.app-main-content { margin-left: var(--sidebar-w); }

.app-sidebar__header {
  padding: 1.35rem 1.35rem 1.15rem !important;
  border-bottom: 1px solid var(--color-border-subtle) !important;
}
.brand-monogram { display: flex; align-items: center; gap: 0.8rem; text-decoration: none; min-width: 0; }
.brand-monogram__logo {
  border-radius: 10px !important;
  background: var(--color-primary) !important;
  box-shadow: none !important;
}
.brand-monogram__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand-monogram__name { font-size: 1.3rem !important; }
.brand-monogram__tag {
  font-size: 0.72rem; font-weight: 500; color: var(--color-text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-action-wrap { padding: 1.1rem 1.1rem 0.35rem !important; }
.btn-sidebar-add {
  width: 100%; min-height: 46px; display: flex; align-items: center; justify-content: center; gap: 0.55rem;
  font-size: 0.97rem !important; font-weight: 700 !important; border-radius: 12px !important;
  background: var(--color-primary) !important;
  box-shadow: none !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important; color: #fff !important; text-decoration: none;
}
.btn-sidebar-add:hover { filter: brightness(1.07); }

/* ---------- Navigation ---------- */
.app-sidebar__nav { padding: 0.5rem 0.9rem 0.75rem !important; gap: 0.2rem !important; }
.nav-section-title {
  margin: 1rem 0.55rem 0.35rem; font-size: 0.7rem !important; font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--color-text-faint);
}
.nav-section-title:first-child { margin-top: 0.6rem; }
.nav-item {
  position: relative; min-height: 46px; padding: 0.65rem 0.9rem !important; gap: 0.9rem !important;
  font-size: 0.96rem !important; font-weight: 600 !important; border-radius: 12px !important;
}
.nav-item .icon { width: 22px; height: 22px; display: inline-flex; flex-shrink: 0; }
.nav-item .icon svg { width: 22px; height: 22px; }
.nav-item--active {
  background: var(--color-primary-subtle) !important;
  border-color: transparent !important; color: var(--color-primary-fg) !important;
}
.nav-item--active::before {
  content: ""; position: absolute; left: -0.9rem; top: 10px; bottom: 10px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--color-primary);
}
.nav-item--active .icon svg, .nav-item--active svg { stroke: var(--color-primary-fg) !important; }
[data-theme="dark"] .nav-item--active {
  background: rgba(167, 139, 250, 0.16) !important; color: var(--color-primary-fg) !important; box-shadow: none !important;
}
[data-theme="dark"] .nav-item--active .icon svg, [data-theme="dark"] .nav-item--active svg { stroke: var(--color-primary-fg) !important; }
.nav-item:focus-visible, .btn-sidebar-add:focus-visible { outline: 3px solid var(--color-primary); outline-offset: 2px; }

/* ---------- "Today at a glance" card (fills the space above the footer) ---------- */
.sidebar-today {
  margin: auto 1.1rem 1rem; padding: 0.95rem 1rem; border-radius: 14px;
  background: var(--color-surface-subtle); border: 1px solid var(--color-border-subtle);
}
.sidebar-today[hidden] { display: none; }
.sidebar-today__title { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-muted); margin-bottom: 0.65rem; }
.sidebar-today__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.sidebar-today__stat { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 0.55rem 0.2rem; border-radius: 10px; background: var(--color-surface); border: 1px solid var(--color-border-subtle); }
.sidebar-today__num { font-size: 1.35rem; font-weight: 800; line-height: 1; color: var(--color-text); }
.sidebar-today__lbl { font-size: 0.68rem; font-weight: 600; color: var(--color-text-muted); }
.sidebar-today.has-overdue .sidebar-today__stat--overdue { border-color: rgba(var(--danger-rgb), 0.45); background: var(--color-danger-subtle); }
.sidebar-today.has-overdue .sidebar-today__stat--overdue .sidebar-today__num { color: var(--color-danger-text); }
.sidebar-today__stat--done .sidebar-today__num { color: var(--color-success-text); }

/* ---------- Footer / profile ---------- */
.app-sidebar__footer {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.95rem 1.1rem !important;
  border-top: 1px solid var(--color-border-subtle) !important; background: var(--color-surface-subtle);
}
.user-profile-pill { flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.7rem; }
.user-avatar {
  width: 42px !important; height: 42px !important; flex-shrink: 0; border-radius: 12px !important;
  background: var(--color-primary) !important;
}
.user-meta { min-width: 0; }
.user-meta__name { font-size: 0.94rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta__role { font-size: 0.75rem; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-icon-btn { width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; }

/* ---------- Brand colour on shared controls ---------- */
.btn--primary, .btn-primary {
  background: var(--color-primary) !important;
  color: #fff !important; border-color: rgba(76, 29, 149, 0.9) !important;
}
html:not([data-theme="dark"]) .btn-primary { background: var(--color-primary) !important; }
.focus-pulse-dot { background: var(--brand-1) !important; box-shadow: 0 0 8px var(--brand-1) !important; }
[data-theme="dark"] .btn--primary, [data-theme="dark"] .btn-primary { color: #fff !important; }

/* ---------- Tablet / phone ---------- */
@media (max-width: 1100px) and (min-width: 769px) {
  :root { --sidebar-w: 248px; }
  .nav-item { min-height: 44px; font-size: 0.93rem !important; }
}
@media (max-width: 768px) {
  .app-main-content { margin-left: 0 !important; }
  .app-sidebar { width: min(86vw, 320px) !important; }
  .app-sidebar.is-open { box-shadow: 0 0 40px rgba(0, 0, 0, 0.35); }
  .sidebar-today { margin-top: 1rem; }
  .nav-item { min-height: 50px; }
}
@media (max-height: 640px) and (min-width: 769px) {
  .sidebar-today { display: none; } /* short windows: keep the nav reachable */
}

/* ---------- One-tap "how long did it take?" answers ---------- */
.actual-hours-quick { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.25rem 0 1rem; }
.actual-hours-quick__chip { flex: 1 1 8rem; min-height: 44px; font-weight: 600; }

/* ============================================================
   Voice Notes (notes-app layout: list on the left, note on the right)
   ============================================================ */
.vnotes { display: grid; grid-template-columns: minmax(280px, 400px) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.vnotes__list-panel { min-width: 0; display: flex; flex-direction: column; gap: 1rem; }
.vnotes__recorder { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.2rem; margin: 0; }
.vnotes__recorder-text { min-width: 0; flex: 1; }
.vnotes__recorder-text strong { display: block; font-size: 1.02rem; }
.vnotes__recorder-text .voice-status { margin: 0.2rem 0 0; }
.vnotes__live { margin: 0.4rem 0 0; font-size: 0.92rem; color: var(--color-text-secondary); overflow-wrap: anywhere; }
.vnotes__live:empty { display: none; }

.vnotes__mic {
  position: relative; flex-shrink: 0; width: 64px; height: 64px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; color: #fff; min-height: 0 !important;
  background: var(--color-primary);
  box-shadow: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.vnotes__mic:hover { transform: scale(1.05); }
.vnotes__mic:focus-visible { outline: 3px solid var(--color-primary); outline-offset: 3px; }
.vnotes__mic.is-listening, .vnotes__mic[aria-pressed="true"] { background: var(--color-danger-text) !important; box-shadow: 0 0 0 0 rgba(185, 28, 28, 0.5); animation: vnote-ring 1.4s ease-out infinite; }
.vnotes__mic.is-listening::before { content: none !important; }
@keyframes vnote-ring { to { box-shadow: 0 0 0 18px rgba(185, 28, 28, 0); } }

.vnotes__list-head { display: flex; align-items: center; justify-content: space-between; padding: 0 0.25rem; }
.vnotes__h2 { margin: 0; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-muted); }
.vnotes__count { font-size: 0.78rem; font-weight: 700; padding: 0.1rem 0.55rem; border-radius: 99px; background: var(--color-primary-subtle); color: var(--color-primary-fg); }
.vnotes__count:empty { display: none; }
.vnotes__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.vnotes__item {
  width: 100%; text-align: left; display: flex; flex-direction: column; gap: 0.2rem; padding: 0.85rem 1rem; cursor: pointer;
  border-radius: 14px; border: 1px solid var(--color-border-subtle); background: var(--color-surface); color: var(--color-text);
  font: inherit; min-height: 0; transition: border-color 0.15s ease, background 0.15s ease;
}
.vnotes__item:hover { border-color: var(--color-primary); }
.vnotes__item.is-active { border-color: var(--color-primary); background: var(--color-primary-subtle); }
.vnotes__item-title { font-weight: 700; font-size: 0.97rem; overflow-wrap: anywhere; }
.vnotes__item-preview { font-size: 0.85rem; color: var(--color-text-secondary); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.vnotes__item-time { font-size: 0.74rem; color: var(--color-text-muted); }
.vnotes__empty { text-align: center; color: var(--color-text-muted); padding: 1.5rem 0.5rem; margin: 0; }

.vnotes__detail-panel { min-width: 0; margin: 0; padding: 1.5rem 1.6rem; position: sticky; top: 1rem; }
.vnotes__detail-panel[hidden] { display: none; }
.vnotes__detail-placeholder { display: grid; place-items: center; min-height: 220px; text-align: center; color: var(--color-text-muted); }
.vnotes__back { display: none; margin-bottom: 0.75rem; }
.vnotes__detail-title { margin: 0; font-size: 1.5rem; line-height: 1.25; overflow-wrap: anywhere; }
.vnotes__detail-time { margin: 0.25rem 0 1.1rem; font-size: 0.85rem; color: var(--color-text-muted); }
.vnotes__transcript { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; font-size: 1.02rem; padding: 1rem 1.1rem; border-radius: 12px; background: var(--color-surface-subtle); border: 1px solid var(--color-border-subtle); }
.vnotes__actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.1rem; }
.vnotes__delete { margin-left: auto; color: var(--color-danger-text); }

/* Phone: one column; opening a note replaces the list, with a Back button. */
@media (max-width: 860px) {
  .vnotes { grid-template-columns: minmax(0, 1fr); }
  .vnotes.has-detail .vnotes__list-panel { display: none; }
  .vnotes__detail-placeholder { display: none; }
  .vnotes__back { display: inline-flex; }
  .vnotes__detail-panel { position: static; padding: 1.1rem; }
  .vnotes__detail-title { font-size: 1.25rem; }
  .vnotes__actions .btn { flex: 1 1 8rem; }
}

/* ---------- Floating microphone (every page when the voice flag is on) ---------- */
.fab-mic {
  position: fixed; right: max(1.25rem, env(safe-area-inset-right)); bottom: max(1.25rem, env(safe-area-inset-bottom)); z-index: 90;
  width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; color: #fff; text-decoration: none;
  background: var(--color-primary); box-shadow: none;
  border: 2px solid rgba(255, 255, 255, 0.25);
}
.fab-mic:hover { filter: brightness(1.08); transform: translateY(-1px); }
.fab-mic:focus-visible { outline: 3px solid var(--color-primary); outline-offset: 3px; }
@media (max-width: 768px) {
  .fab-mic { bottom: calc(5.4rem + env(safe-area-inset-bottom)); width: 56px; height: 56px; }
}

/* keep the last buttons on a page clear of the floating microphone */
.app-main { padding-bottom: 6rem; }
