﻿/* =========================================================
   Rotvux shell — side panels and composer tools
   The demo's side rails and tool row, mapped onto the original
   Rotvux palette from styles.css. The center column intentionally
   keeps the original chat styles.
   ========================================================= */

:root {
  --surface: var(--card);
  --surface-2: var(--card-soft);
  --surface-3: color-mix(in srgb, var(--card) 82%, var(--text) 5%);
  --text-2: color-mix(in srgb, var(--text) 80%, var(--muted));
  --border-strong: color-mix(in srgb, var(--border) 72%, var(--text));
  --error: var(--fel);
  --error-tint: color-mix(in srgb, var(--fel) 10%, transparent);
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

.dot-sep {
  color: var(--muted);
  padding: 0 2px;
}

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

.app {
  grid-template-columns: 264px minmax(0, 1fr) 320px;
}

.sidebar,
.insights {
  min-width: 0;
  min-height: 0;
}

/* ---------------------------------------------------------
   Left rail
   --------------------------------------------------------- */

.sidebar {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  gap: 0;
  padding: 16px 12px;
  overflow-y: auto;
  background: var(--pane);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 2px 8px 16px;
  border-radius: 10px;
  color: var(--text);
}

.brand:hover {
  color: var(--text);
}

.brand .seed {
  color: var(--text-2);
}

.brand-word {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.015em;
  color: var(--text);
}

.new-project {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 36px;
  padding: 0 12px;
  margin-bottom: 8px;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease), color 140ms var(--ease);
}

.new-project svg {
  color: var(--muted);
  transition: color 140ms var(--ease);
}

.new-project:hover {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.new-project:hover svg {
  color: var(--accent);
}

.side-section {
  margin-top: 16px;
}

.side-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 6px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}

.side-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 400;
  color: var(--muted);
  opacity: 0.8;
}

.project-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.project-item {
  display: flex;
  flex-direction: column;
}

.project-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 1px 8px;
  align-items: center;
  padding: 8px 10px 8px 12px;
  border-radius: 10px;
  color: var(--text-2);
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}

.project-row:hover {
  background: var(--surface);
  color: var(--text-2);
}

.project-row.is-active {
  background: var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.project-row.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.project-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
}

.project-row.is-active .project-name {
  color: var(--text);
}

.project-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.3;
}

.project-score {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--text-2);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.project-row.is-active .project-score {
  color: var(--text);
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 2px 0 8px 20px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.chat-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 30px;
  padding: 4px 8px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12.5px;
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}

.chat-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-date {
  flex-shrink: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
}

.chat-row:hover {
  background: var(--surface);
  color: var(--text-2);
}

.chat-row.is-active {
  background: var(--surface-2);
  color: var(--text);
}

.chat-row.is-active::before {
  content: "";
  position: absolute;
  left: -16px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--pane);
}

.chat-row--new {
  color: var(--accent);
}

.chat-row--new .chat-title {
  font-weight: 600;
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: auto;
  padding: 16px 10px 0;
  border-top: 1px solid var(--border);
}

.server-status {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11.5px;
}

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
}

.theme-toggle {
  display: flex;
  align-items: center;
  align-self: flex-start;
  gap: 7px;
  padding: 4px 0;
  background: none;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  transition: color 140ms var(--ease);
}

.theme-toggle:hover {
  color: var(--text);
}

html[data-theme="dark"] .theme-icon--moon,
html[data-theme="light"] .theme-icon--sun {
  display: none;
}

/* ---------------------------------------------------------
   Right rail
   --------------------------------------------------------- */

.insights {
  height: 100dvh;
  overflow-y: auto;
  background: var(--pane);
  border-left: 1px solid var(--border);
}

.insights-inner {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  padding: 20px 20px 28px;
}

.panel-section {
  min-width: 0;
}

.panel-section + .panel-section {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-head h2 {
  margin: 0;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.section-head > span {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.4;
  text-align: right;
}

.grade-block {
  padding-top: 1px;
}

.grade-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.grade-ring {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.grade-ring svg {
  display: block;
}

.grade-ring__value {
  stroke-dasharray: 182.2;
  stroke-dashoffset: var(--ring-offset, 182.2);
  animation: ring-in 850ms var(--ease) 120ms both;
}

.grade-matrix {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.grade-matrix svg {
  display: block;
}

.grade-matrix__dot {
  fill: var(--border);
  transform-box: fill-box;
  transform-origin: center;
  animation: grade-dot-in 360ms var(--ease) calc(var(--i) * 14ms) both;
}

.grade-matrix__dot.is-on {
  fill: var(--accent);
}

@keyframes grade-dot-in {
  from {
    opacity: 0;
    transform: scale(0.35);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .grade-matrix__dot {
    animation: none;
  }
}

.grade-copy {
  min-width: 0;
}

.grade-number {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.grade-number strong {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.grade-number span {
  color: var(--muted);
  font-size: 11.5px;
}

.grade-copy p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
}

.mastery {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.mastery-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 10px;
  padding: 4px 0;
}

.mastery-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.35;
}

.mastery-score {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}

.mastery-track {
  grid-column: 1 / -1;
  height: 3px;
  overflow: hidden;
  background: var(--border);
  border-radius: 2px;
}

.mastery-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--muted);
  border-radius: 2px;
  opacity: 0.5;
  transform: scaleX(var(--v, 0));
  transform-origin: left center;
  animation: bar-in 640ms var(--ease) both;
}

.mastery-row.is-empty .mastery-fill {
  opacity: 0.18;
}

.pattern-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.pattern-row + .pattern-row {
  margin-top: 6px;
}

.pattern-label {
  min-width: 0;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.45;
}

.pattern-count {
  flex-shrink: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.source-mode {
  white-space: nowrap;
}

.material-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.material-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  background: var(--surface-2);
  border-radius: 8px;
  color: var(--muted);
}

.material-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.material-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
}

.material-copy small {
  color: var(--muted);
  font-size: 10.5px;
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.review-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1px 10px;
  align-items: baseline;
  padding: 6px 0;
  color: var(--text-2);
}

.review-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.4;
}

.review-score {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.insights .bookmark-link:hover .review-name {
  color: var(--text);
}

.panel-actions {
  display: flex;
  gap: 4px;
  padding-top: 4px;
  border-top: 0;
}

.quiet-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 8px;
  background: none;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.3;
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}

.quiet-button:hover {
  background: var(--surface-2);
  color: var(--text);
}

.quiet-button--small {
  min-height: 26px;
  padding: 3px 6px;
  font-size: 11.5px;
}

.insights .quiet-button {
  justify-content: flex-start;
}

.insights .side-text,
.insights .hint {
  color: var(--muted);
  font-size: 12px;
}

.insights .ai-badge {
  display: inline-flex;
}

/* ---------------------------------------------------------
   Composer tool row (kept from the demo)
   --------------------------------------------------------- */

.composer-tools.chat-tools {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 2px;
  margin-bottom: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.composer-tools.chat-tools::-webkit-scrollbar {
  display: none;
}

.composer-tools form {
  display: contents;
}

.tool.chat-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  min-height: 30px;
  padding: 0 8px;
  background: none;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}

.tool.chat-tool:hover {
  background: var(--surface);
  color: var(--text-2);
}

.chat-tool input[type="file"] {
  display: none;
}

/* ---------------------------------------------------------
   Motion
   --------------------------------------------------------- */

@keyframes ring-in {
  from {
    stroke-dashoffset: 182.2;
  }
  to {
    stroke-dashoffset: var(--ring-offset, 182.2);
  }
}

@keyframes bar-in {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(var(--v, 0));
  }
}

/* ---------------------------------------------------------
   Mobile
   --------------------------------------------------------- */

.mobile-tabs {
  display: none;
}

@media (max-width: 1180px) {
  .app {
    grid-template-columns: 244px minmax(0, 1fr) 296px;
  }

  .insights-inner {
    padding-left: 18px;
    padding-right: 18px;
  }
}

@media (max-width: 1060px) {
  body {
    padding-bottom: calc(56px + env(safe-area-inset-bottom));
  }

  .app {
    display: block;
    height: calc(100dvh - 56px - env(safe-area-inset-bottom));
    overflow: hidden;
  }

  .sidebar,
  .main,
  .insights {
    display: none;
    height: calc(100dvh - 56px - env(safe-area-inset-bottom));
  }

  .app[data-tab="projects"] .sidebar {
    display: flex;
    border-right: 0;
    padding: 18px 16px 16px;
  }

  .app[data-tab="chat"] .main {
    display: flex;
  }

  .app[data-tab="stats"] .insights {
    display: block;
    border-left: 0;
  }

  .mobile-tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--pane);
    border-top: 1px solid var(--border);
  }

  .mobile-tabs button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 56px;
    padding: 6px 0;
    background: none;
    border: 0;
    color: var(--muted);
    font-size: 10.5px;
    line-height: 1.2;
    transition: color 140ms var(--ease);
  }

  .mobile-tabs button.is-active {
    color: var(--accent);
  }

  .insights-inner {
    max-width: 560px;
    padding: 18px 20px 28px;
  }

  .sidebar .brand {
    padding-left: 8px;
  }
}
