/* ============================================================
   ThirdEyeOS — App Shell + Component Library
   ============================================================ */

/* ---------- App layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar rail (desktop) ---------- */
.rail {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 22px 16px;
  background: linear-gradient(180deg, rgba(22,17,14,0.92), rgba(12,9,8,0.92));
  border-right: 1px solid var(--hairline);
  backdrop-filter: blur(18px);
  z-index: 40;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 10px 18px;
}
.brand-mark {
  width: 38px; height: 38px;
  flex: none;
  filter: drop-shadow(0 4px 14px var(--orange-glow));
}
.brand-word { line-height: 1; }
.brand-word .logo { display: block; }
.brand-word b {
  display: block;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.3px;
}
.brand-word b span { color: var(--orange); }
.brand-word small {
  display: block;
  margin-top: 8px;
  font-size: 9.5px;
  letter-spacing: 2.6px;
  text-transform: uppercase;
  color: var(--text-3);
}

.nav-group-label {
  font-size: 9.5px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--text-3); padding: 14px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 13.5px; font-weight: 500;
  transition: background .2s var(--ease), color .2s var(--ease), transform .15s var(--ease);
  text-align: left;
}
.nav-item .ic { width: 19px; height: 19px; flex: none; opacity: .85; }
.nav-item:hover { background: var(--panel); color: var(--text-1); }
.nav-item.active {
  background: linear-gradient(100deg, var(--orange-soft), rgba(var(--accent-rgb),0.04));
  color: #fff;
  box-shadow: inset 0 0 0 1px var(--card-border-warm);
}
.nav-item.active .ic { opacity: 1; color: var(--orange-bright); }
.nav-spacer { flex: 1; }

.rail-cta {
  margin-top: 8px;
  padding: 14px;
  border-radius: var(--r-md);
  background: linear-gradient(150deg, rgba(var(--accent-rgb),0.18), rgba(var(--accent-rgb),0.04));
  border: 1px solid var(--card-border-warm);
}
.rail-cta p { font-size: 12px; color: var(--text-2); margin-bottom: 10px; }

/* ---------- collapsible sidebar ---------- */
.app { transition: grid-template-columns .22s var(--ease); }
.brand-eye {
  display: none;            /* condensed logo, shown only when collapsed */
  width: 40px; height: 40px; flex: none;
  border: none; border-radius: 50%; cursor: pointer;
  place-items: center;
  background: rgb(var(--accent-rgb)); color: #fff;
  box-shadow: 0 6px 18px -4px var(--orange-glow);
  transition: filter .15s var(--ease);
}
.brand-eye:hover { filter: brightness(1.07); }
.brand-eye svg { width: 21px; height: 21px; }
html[data-theme="mono"] .brand-eye { color: #15110e; }   /* keep the eye visible on a light grey accent */
.rail-toggle {
  display: grid; place-items: center; margin-left: auto; flex: none;
  width: 28px; height: 28px; border-radius: 8px;
  background: none; border: 1px solid transparent; color: var(--text-3); cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.rail-toggle:hover { background: var(--panel); color: var(--text-1); border-color: var(--card-border); }
.rail-toggle svg { width: 15px; height: 15px; }

html.rail-collapsed { --rail: 76px; }
html.rail-collapsed .rail { padding: 22px 0; align-items: center; }
html.rail-collapsed .brand { padding: 6px 0 16px; justify-content: center; }
html.rail-collapsed .brand-word,
html.rail-collapsed .rail-toggle,
html.rail-collapsed .nav-group-label,
html.rail-collapsed .nav-item span,
html.rail-collapsed .rail-cta p,
html.rail-collapsed .rail-cta .btn span { display: none; }
html.rail-collapsed .brand-eye { display: grid; }
html.rail-collapsed .nav-item { width: 46px; margin: 0 auto; justify-content: center; gap: 0; padding: 12px 0; }
html.rail-collapsed .rail-cta { margin-top: 10px; padding: 0; background: none; border: none; }
html.rail-collapsed .rail-cta .btn { width: 46px; height: 46px; padding: 0; margin: 0 auto; border-radius: 50%; }

/* ---------- Main column ---------- */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 14px clamp(16px, 3vw, 34px);
  background: linear-gradient(180deg, rgba(12,9,8,0.86), rgba(12,9,8,0.4));
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--hairline);
}
.topbar .clock { font-weight: 600; font-size: 15px; letter-spacing: .4px; }
.topbar .clock span { color: var(--text-3); font-weight: 500; margin-left: 8px; font-size: 12.5px; }
.search {
  flex: 1; max-width: 420px;
  display: flex; align-items: center; gap: 9px;
  padding: 9px 14px;
  background: var(--panel);
  border: 1px solid var(--card-border);
  border-radius: var(--r-pill);
  color: var(--text-3); font-size: 13px;
}
.search input { flex: 1; border: none; background: none; outline: none; font-size: 13px; color: var(--text-1); }
.search input::placeholder { color: var(--text-3); }
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: var(--r-pill);
  background: var(--panel); border: 1px solid var(--card-border);
  color: var(--text-2); transition: .2s var(--ease);
}
.icon-btn:hover { color: #fff; border-color: var(--card-border-warm); transform: translateY(-1px); }
.icon-btn .dot { position: absolute; }
.avatar {
  width: 40px; height: 40px; border-radius: var(--r-pill);
  display: grid; place-items: center; font-weight: 600; font-size: 14px;
  background: linear-gradient(140deg, var(--orange), var(--orange-deep));
  color: #fff; box-shadow: 0 6px 18px -6px var(--orange-glow);
}

/* ---------- Screen container ---------- */
.screen {
  width: 100%; max-width: none;
  margin: 0;
  padding: clamp(18px, 3vw, 34px) clamp(16px, 3vw, 34px) 120px;
  animation: rise .45s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: clamp(22px, 3vw, 30px); font-weight: 600; letter-spacing: -0.4px; }
.page-head p { color: var(--text-2); margin-top: 6px; font-size: 14px; max-width: 60ch; }

/* ---------- Grid helpers ---------- */
.grid { display: grid; gap: var(--gap); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.span-2 { grid-column: span 2; }
.bento { grid-template-columns: 1.5fr 1fr; align-items: start; }
@media (max-width: 920px) {
  .cols-3, .cols-4, .bento { grid-template-columns: 1fr 1fr; }
  .span-2 { grid-column: span 2; }
}
@media (max-width: 620px) {
  .cols-2, .cols-3, .cols-4, .bento { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
}

/* ---------- Card ---------- */
.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--card-border);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(8px);
}
.card.warm { border-color: var(--card-border-warm); background: linear-gradient(160deg, var(--orange-soft), rgba(255,255,255,0.02)); }
.card.tight { padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h3 { font-size: 12px; font-weight: 700; letter-spacing: 1.6px; text-transform: uppercase; color: var(--text-2); }
.link { font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--orange-bright); transition: .15s; }
.link:hover { color: var(--orange-bright); filter: brightness(1.2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: var(--r-pill);
  font-size: 13.5px; font-weight: 600; letter-spacing: .2px;
  transition: .2s var(--ease);
  border: 1px solid transparent;
}
.btn .ic { width: 17px; height: 17px; }
.btn-primary {
  background: linear-gradient(135deg, var(--orange-bright), var(--orange-deep));
  color: #fff;
  box-shadow: 0 12px 30px -12px var(--orange-glow);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 38px -12px var(--orange-glow); }
.btn-ghost { background: var(--panel); border-color: var(--card-border); color: var(--text-1); }
.btn-ghost:hover { border-color: var(--card-border-warm); background: var(--panel-2); }
.btn-soft { background: var(--orange-soft); color: var(--orange-bright); border-color: var(--orange-line); }
.btn-soft:hover { background: rgba(var(--accent-rgb),0.2); }
.btn-block { width: 100%; }
.btn-lg { padding: 16px 26px; font-size: 15px; }

/* ---------- Pills / chips ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 600; letter-spacing: .3px;
  background: var(--panel-2); color: var(--text-2);
  border: 1px solid var(--card-border);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--orange); }
.pill.high { color: var(--orange-bright); border-color: var(--orange-line); background: var(--orange-soft); }
.pill.high .dot { background: var(--orange-bright); }
.pill.med { color: var(--warn); border-color: var(--warn-soft); background: var(--warn-soft); }
.pill.med .dot { background: var(--warn); }
.pill.low { color: var(--calm); border-color: var(--calm-soft); background: var(--calm-soft); }
.pill.low .dot { background: var(--calm); }

.tag { font-size: 10.5px; letter-spacing: .4px; padding: 3px 9px; border-radius: var(--r-pill);
  background: var(--panel-2); color: var(--text-3); border: 1px solid var(--hairline); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 5px; vertical-align: middle; }

/* segmented control (toggles) */
.seg {
  display: inline-flex; gap: 4px; padding: 4px;
  background: var(--panel); border: 1px solid var(--card-border);
  border-radius: var(--r-pill);
}
.seg button {
  padding: 8px 16px; border-radius: var(--r-pill);
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
  transition: .18s var(--ease);
}
.seg button.on { background: linear-gradient(135deg, var(--orange-bright), var(--orange-deep)); color: #fff; box-shadow: 0 8px 20px -10px var(--orange-glow); }
.seg button:not(.on):hover { color: #fff; }

/* full-width segmented tab bar (dashboard mode switcher) with icons */
.dashmodes-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 20px; }
.dashmodes-wrap::-webkit-scrollbar { height: 0; }
.seg.seg-full { display: flex; min-width: 100%; width: max-content; }
.seg-full button {
  flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; white-space: nowrap; padding: 10px 12px;
}
.seg-full button .ic { width: 15px; height: 15px; flex: none; opacity: .9; }
.seg-full button.on .ic { opacity: 1; }

/* ---------- List rows ---------- */
.row {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--hairline);
  transition: .15s var(--ease);
}
.row:last-child { border-bottom: none; }
.row:hover { background: var(--panel); border-radius: 12px; padding-left: 12px; padding-right: 12px; }
.row .check {
  width: 22px; height: 22px; flex: none; border-radius: 7px;
  border: 1.5px solid var(--text-3); display: grid; place-items: center;
  transition: .15s; cursor: pointer;
}
.row .check:hover { border-color: var(--orange-bright); }
.row .check.done { background: var(--orange); border-color: var(--orange); }
.row .check.done svg { opacity: 1; }
.row .check svg { width: 13px; height: 13px; opacity: 0; color: #fff; }
.row .body { flex: 1; min-width: 0; }
.row .body .t { font-size: 14px; font-weight: 500; }
.row .body .s { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.row.done .body .t { color: var(--text-3); text-decoration: line-through; }

/* date block */
.datechip {
  width: 50px; min-height: 44px; flex: none; padding: 6px 0;
  border-radius: 14px; background: var(--panel-2); border: 1px solid var(--card-border);
  display: grid; place-items: center; gap: 1px;
}
.datechip .m { font-size: 9.5px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--orange-bright); font-weight: 700; }
.datechip .d { font-size: 18px; font-weight: 600; line-height: 1.1; }
.datechip > .ic { width: 22px; height: 22px; color: var(--orange-bright); }

/* metric tiles */
.metric { text-align: center; padding: 18px 10px; }
.metric .n { font-size: 30px; font-weight: 600; letter-spacing: -1px; }
.metric .l { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-3); margin-top: 2px; }

/* mood / feeling chips */
.feelings { display: flex; flex-wrap: wrap; gap: 9px; }
.feel {
  padding: 9px 16px; border-radius: var(--r-pill);
  background: var(--panel); border: 1px solid var(--card-border);
  font-size: 13px; font-weight: 500; color: var(--text-2);
  transition: .18s var(--ease);
}
.feel:hover { color: #fff; border-color: var(--card-border-warm); transform: translateY(-1px); }
.feel.sel { background: var(--orange-soft); border-color: var(--orange-line); color: var(--orange-bright); }

/* quick action grid */
.qa { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 620px) { .qa { grid-template-columns: repeat(2, 1fr); } }
.qa button {
  display: flex; flex-direction: column; align-items: center; gap: 9px;
  padding: 16px 8px; border-radius: var(--r-md);
  background: var(--panel); border: 1px solid var(--card-border);
  color: var(--text-2); font-size: 11.5px; font-weight: 600; text-align: center;
  transition: .18s var(--ease);
}
.qa button .ic { width: 22px; height: 22px; color: var(--orange-bright); }
.qa button:hover { color: #fff; border-color: var(--card-border-warm); transform: translateY(-2px); background: var(--panel-2); }

/* profile cards */
.person {
  display: flex; flex-direction: column; gap: 10px; padding: 16px;
  border-radius: var(--r-md); background: var(--panel); border: 1px solid var(--card-border);
  transition: .18s var(--ease); text-align: left; width: 100%;
}
.person:hover { border-color: var(--card-border-warm); transform: translateY(-2px); background: var(--panel-2); }
.person .ava {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  font-weight: 600; font-size: 17px; color: #fff;
}
/* profile-picture avatars on a theme-colored background (recolors with the theme) */
.ava-theme { background: linear-gradient(145deg, rgba(var(--accent-rgb),0.92), rgba(var(--accent-rgb),0.26)); color: #fff; }
.ava-sm { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.av-ic svg { width: 58%; height: 58%; }
.ava.pfp, .avatar.pfp, .msg-ava.pfp, .cav.pfp { padding: 0; overflow: hidden; position: relative; }
.ava.pfp img, .avatar.pfp img, .msg-ava.pfp img, .cav.pfp img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; }
.person .nm { font-weight: 600; font-size: 15px; }
.person .rl { font-size: 11.5px; color: var(--text-3); }
.person .note { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* brain-dump textarea */
.dump-wrap {
  position: relative;
  background: linear-gradient(160deg, rgba(var(--accent-rgb),0.07), rgba(255,255,255,0.02));
  border: 1px solid var(--card-border-warm);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}
.dump-wrap textarea {
  width: 100%; min-height: 130px; resize: vertical;
  background: none; border: none; outline: none;
  font-size: 16px; line-height: 1.6; color: var(--text-1);
}
.dump-wrap textarea::placeholder { color: var(--text-3); }
.dump-tools { display: flex; align-items: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.dump-tool {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 13px; border-radius: var(--r-pill);
  background: var(--panel); border: 1px solid var(--card-border);
  font-size: 12px; font-weight: 500; color: var(--text-2); transition: .15s;
}
.dump-tool:hover { color: #fff; border-color: var(--card-border-warm); }
.dump-tool .ic { width: 15px; height: 15px; }

/* divider */
.divider { height: 1px; background: var(--hairline); margin: 18px 0; }

/* note card */
.note-card {
  padding: 14px; border-radius: var(--r-md);
  background: var(--panel); border: 1px solid var(--card-border);
}
.note-card .meta { font-size: 11px; color: var(--text-3); margin-top: 8px; }

/* empty state */
.empty { text-align: center; padding: 40px 20px; color: var(--text-3); }

/* progress */
.bar { height: 7px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--orange-bright), var(--orange-deep)); }

/* mobile bottom nav */
.botnav { display: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }
  .botnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    justify-content: space-around; align-items: center;
    padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(16,12,10,0.8), rgba(10,8,7,0.98));
    backdrop-filter: blur(20px); border-top: 1px solid var(--hairline);
  }
  .botnav button {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    color: var(--text-3); font-size: 9.5px; font-weight: 600; flex: 1;
  }
  .botnav button .ic { width: 22px; height: 22px; }
  .botnav button.active { color: var(--orange-bright); }
  .botnav .fab {
    width: 52px; height: 52px; border-radius: 50%; flex: none; margin-top: -22px;
    background: linear-gradient(135deg, var(--orange-bright), var(--orange-deep));
    color: #fff; box-shadow: 0 10px 26px -8px var(--orange-glow); justify-content: center;
  }
  .botnav .fab .ic { width: 26px; height: 26px; }
}
