:root {
  color-scheme: light;
  --navy: #08213f;
  --navy-2: #123d68;
  --teal: #16b3a5;
  --mint: #dff8f2;
  --aqua: #eaf7fb;
  --ink: #142034;
  --muted: #657184;
  --line: #d8e6ef;
  --panel: #ffffff;
  --surface: #f3f7fa;
  --soft: #f8fbfc;
  --warning: #a64018;
  --warning-bg: #fff5ed;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --success: #13795b;
  --shadow: 0 18px 55px rgba(8, 39, 80, 0.13);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  scrollbar-color: rgba(15, 44, 84, 0.34) transparent;
  scrollbar-width: thin;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(15, 44, 84, 0.28);
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 44, 84, 0.44);
  background-clip: content-box;
}

html {
  min-width: 320px;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(135deg, rgba(245, 250, 252, 0.98), rgba(235, 247, 249, 0.92) 48%, rgba(230, 249, 244, 0.88)),
    var(--surface);
  color: var(--ink);
}

button,
textarea,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

p,
h1,
h2,
h3,
dl,
dd {
  margin: 0;
}

.workspace {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  min-height: 100vh;
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: auto;
  min-height: 100vh;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  padding: 24px 16px;
  backdrop-filter: blur(20px);
  box-shadow: 12px 0 40px rgba(8, 33, 63, 0.04);
  overflow: visible;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 4px 10px;
}

.brand-word {
  color: var(--navy);
  font-size: 1.48rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.brand-word span {
  color: var(--teal);
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(22, 179, 165, 0.16), rgba(8, 33, 63, 0.08)),
    #f6fbfc;
  border: 1px solid #cce7ed;
  color: var(--navy);
  box-shadow: 0 10px 22px rgba(8, 33, 63, 0.08);
  overflow: hidden;
}

.brand-mark svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.chat-history {
  display: grid;
  gap: 10px;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fbfefe, #f4fafb);
  padding: 12px;
  box-shadow: 0 10px 26px rgba(8, 33, 63, 0.04);
}

.chat-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chat-history-head h2 {
  color: var(--navy);
  font-size: 0.92rem;
}

.chat-history-head button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  border: 1px solid #b7ece3;
  border-radius: 8px;
  background: #e7fbf6;
  padding: 0 8px;
  color: var(--navy);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 900;
}

.chat-list {
  display: grid;
  gap: 6px;
  max-height: none;
  overflow: visible;
  padding-right: 2px;
}

.chat-list-item {
  position: relative;
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 50px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #fff;
  padding: 8px 30px 8px 9px;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}

.chat-list-item:hover,
.chat-list-item.active {
  border-color: #9de1d7;
  background: #ecfffb;
  color: var(--navy);
}

.chat-list-title,
.chat-list-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-list-title {
  color: inherit;
  font-size: 0.84rem;
  font-weight: 900;
}

.chat-list-meta {
  font-size: 0.72rem;
  font-weight: 700;
}

.chat-close {
  position: absolute;
  top: 7px;
  right: 7px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  color: #6b7a91;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  opacity: 0;
}

.chat-list-item:hover .chat-close,
.chat-list-item.active .chat-close {
  opacity: 1;
}

.chat-close:hover {
  background: rgba(6, 36, 82, 0.08);
  color: var(--navy);
}

.nav-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 12px;
  color: #33445e;
  font-size: 0.92rem;
  font-weight: 700;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.nav-item:hover,
.nav-item.active {
  background: #e7fbf6;
  color: var(--navy);
}

.nav-item:hover {
  transform: translateX(2px);
}

.icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-status {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.sidebar-status strong,
.sidebar-status span:last-child {
  display: block;
}

.sidebar-status strong {
  color: var(--ink);
  font-size: 0.9rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(27, 183, 167, 0.18);
}

.dashboard {
  display: grid;
  grid-template-rows: auto minmax(720px, calc(100vh - 104px));
  gap: 12px;
  min-width: 0;
  padding: 22px 26px 30px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 54px;
  margin-bottom: 0;
}

.topbar-title p {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar-title h1 {
  color: var(--navy);
  font-size: 1.62rem;
  line-height: 1.1;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.icon-button,
.profile-button,
.memory-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--navy);
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(8, 33, 63, 0.06);
}

.icon-button {
  width: 42px;
}

.profile-button {
  gap: 8px;
  padding: 0 8px 0 12px;
  color: var(--muted);
}

.memory-button {
  gap: 7px;
  padding: 0 12px;
  color: var(--navy);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 900;
}

.memory-button:hover,
.icon-button:hover,
.profile-button:hover {
  background: #e7fbf6;
  border-color: #a8e3dc;
}

.profile-button strong {
  color: var(--ink);
}

.avatar-photo {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--navy), var(--teal));
  color: #fff;
  font-size: 0.75rem;
  font-weight: 900;
}

.welcome-band {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 92px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 94% 30%, rgba(27, 183, 167, 0.28), transparent 24%),
    linear-gradient(135deg, #082754, #0a3b70 58%, #0d5d81);
  padding: 16px 20px;
  color: #fff;
  box-shadow: var(--shadow);
}

.welcome-band p {
  margin-bottom: 6px;
  color: #bcefea;
  font-size: 0.88rem;
  font-weight: 800;
}

.welcome-band h2 {
  max-width: 780px;
  font-size: clamp(1.25rem, 2vw, 1.8rem);
  line-height: 1.18;
}

.knowledge-mini {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 180px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  padding: 12px;
  color: #eafffb;
  font-size: 0.9rem;
  font-weight: 800;
}

.quick-grid {
  display: none;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
}

.tool-tile {
  display: grid;
  gap: 10px;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 13px;
  box-shadow: 0 10px 32px rgba(6, 36, 82, 0.07);
}

.tool-tile.mint {
  background: #eefcf6;
}

.tool-tile.blue {
  background: #edf7ff;
}

.tool-tile > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tile-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
}

.tool-tile h3 {
  font-size: 1rem;
}

.tool-tile p {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: stretch;
  min-height: min(820px, calc(100vh - 104px));
}

.chat-panel,
.right-rail section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 46px rgba(8, 33, 63, 0.08);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(320px, 1fr) auto;
  min-height: min(820px, calc(100vh - 104px));
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 252, 253, 0.95));
  padding: 13px 16px;
}

.panel-head p {
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.panel-head h2 {
  margin-top: 2px;
  font-size: 1.08rem;
}

.safety-strip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 430px;
  border: 1px solid #b7ece3;
  border-radius: 8px;
  background: #ecfffb;
  padding: 9px 11px;
  color: #0d5f56;
  font-size: 0.84rem;
  line-height: 1.3;
}

.safety-strip.urgent {
  border-color: #fecaca;
  background: var(--danger-bg);
  color: var(--danger);
}

.safety-strip.caution {
  border-color: #fed7aa;
  background: var(--warning-bg);
  color: var(--warning);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.92)),
    linear-gradient(90deg, rgba(8, 33, 63, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(8, 33, 63, 0.035) 1px, transparent 1px);
  background-size: auto, 34px 34px, 34px 34px;
}

.message {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  max-width: 860px;
}

.message.user {
  align-self: end;
  grid-template-columns: minmax(0, 1fr) 38px;
}

.message.user .avatar {
  grid-column: 2;
  grid-row: 1;
  background: var(--navy);
}

.message.user .bubble {
  grid-column: 1;
  border-color: #092e61;
  background: #092e61;
  color: #fff;
}

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-weight: 900;
}

.bubble {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
  white-space: pre-wrap;
  line-height: 1.52;
  box-shadow: 0 10px 24px rgba(8, 33, 63, 0.06);
}

.bubble p {
  margin-bottom: 8px;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.message-actions button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 0 9px;
  color: var(--navy);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 900;
}

.source-panel {
  margin-top: 10px;
  border: 1px solid #d8e5ec;
  border-radius: 8px;
  background: #f8fbfc;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.82rem;
  white-space: normal;
}

.source-panel strong {
  display: block;
  margin-bottom: 6px;
  color: var(--navy);
}

.source-panel ol {
  margin: 0;
  padding-left: 18px;
}

.source-panel a {
  color: var(--navy);
  font-weight: 800;
}

.small {
  color: var(--muted);
  font-size: 0.9rem;
}

.composer {
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, #f8fbfc, #f2f8fa);
  padding: 12px 14px 14px;
}

.mode-row,
.audience-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mode-row {
  margin-bottom: 8px;
}

.audience-row {
  align-items: center;
}

.audience-row {
  margin-bottom: 10px;
}

.mode-row label,
.audience-row label {
  cursor: pointer;
}

.mode-row input,
.audience-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-row label > span,
.audience-row label > span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 10px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.mode-row input:checked + span,
.audience-row input:checked + span {
  border-color: #85d8cc;
  background: #e7fbf6;
  color: var(--navy);
}

.control-caption {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding-right: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.prompt-box {
  display: grid;
  grid-template-rows: auto minmax(104px, auto) auto;
  min-width: 0;
  border: 1px solid #c7dce7;
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.focus-book-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #e4edf3;
  padding: 8px 10px;
  color: var(--navy);
  font-size: 0.82rem;
  font-weight: 850;
}

.focus-book-bar button {
  border-radius: 999px;
  background: #eef8fb;
  padding: 4px 9px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 900;
}

.prompt-box:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(27, 183, 167, 0.16);
}

textarea {
  width: 100%;
  height: 104px;
  min-height: 104px;
  max-height: 220px;
  resize: none;
  overflow-y: hidden;
  border: 0;
  border-radius: 8px 8px 0 0;
  background: #fff;
  padding: 13px 13px 4px;
  color: var(--ink);
  outline: none;
}

textarea:focus {
  box-shadow: none;
}

.prompt-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 42px;
  padding: 0 9px 9px;
}

.system-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.system-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  border: 1px solid #dbe4ec;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #eef7f6);
  box-shadow: 0 6px 16px rgba(6, 36, 82, 0.09);
  padding: 0 10px 0 12px;
  color: #3c4658;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 800;
}

.system-trigger:hover,
.system-trigger:focus-visible,
.system-picker.open .system-trigger {
  border-color: #8fded3;
  background: #e7fbf6;
  color: var(--navy);
  outline: none;
}

.system-picker .picker-icon {
  width: 14px;
  height: 14px;
  color: #5d6878;
  pointer-events: none;
}

.system-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 20;
  display: none;
  width: min(258px, calc(100vw - 48px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 44px rgba(6, 36, 82, 0.18);
  padding: 7px;
}

.system-picker.open .system-menu {
  display: grid;
  gap: 4px;
}

.system-menu button {
  display: grid;
  gap: 2px;
  width: 100%;
  border-radius: 8px;
  background: transparent;
  padding: 9px 10px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.system-menu button:hover,
.system-menu button:focus-visible {
  background: #eef8fb;
  outline: none;
}

.system-menu button[aria-selected="true"] {
  background: #e7fbf6;
  color: var(--navy);
}

.system-menu strong {
  font-size: 0.88rem;
}

.system-menu span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.3;
}

#sendButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 126px;
  min-height: 48px;
  border-radius: 8px;
  background: linear-gradient(180deg, #1bc3b4, #10998e);
  color: #fff;
  cursor: pointer;
  font-weight: 900;
  box-shadow: 0 12px 24px rgba(22, 179, 165, 0.26);
}

#sendButton:hover {
  background: #129d90;
}

#sendButton:disabled {
  cursor: progress;
  opacity: 0.68;
}

.right-rail {
  display: grid;
  gap: 12px;
  align-content: start;
  min-height: 0;
  overflow: visible;
  padding-right: 2px;
}

.visual-panel {
  position: relative;
  overflow: hidden;
  min-height: auto;
  background: linear-gradient(180deg, #ffffff, #f6fbfb);
  padding: 14px;
}

.scan-frame {
  position: relative;
  height: 120px;
  border: 1px solid rgba(166, 224, 231, 0.34);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 50%, rgba(228, 250, 255, 0.18), transparent 44%),
    #07172e;
  overflow: hidden;
}

.scan-grid {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 26px 26px;
  opacity: 0.55;
}

.scan-lung {
  position: absolute;
  top: 26px;
  width: 68px;
  height: 78px;
  border: 2px solid rgba(214, 245, 249, 0.85);
  background: rgba(214, 245, 249, 0.12);
}

.scan-lung.left {
  left: 60px;
  border-radius: 56% 40% 48% 62%;
  transform: rotate(-9deg);
}

.scan-lung.right {
  right: 60px;
  border-radius: 40% 56% 62% 48%;
  transform: rotate(9deg);
}

.scan-focus {
  position: absolute;
  top: 52px;
  right: 88px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 176, 83, 0.86);
  box-shadow: 0 0 0 8px rgba(255, 176, 83, 0.2);
  z-index: 1;
}

.ai-card {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-top: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  padding: 11px;
  color: #dffefa;
}

.visual-panel .ai-card {
  border: 1px solid #d8e8ee;
  background: #eef8fb;
  color: var(--navy);
}

.ai-card strong,
.ai-card span {
  display: block;
}

.ai-card span {
  color: #a9d9e0;
  font-size: 0.82rem;
}

.visual-panel .ai-card span {
  color: var(--muted);
}

.rail-card {
  padding: 16px;
}

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

.rail-head h2 {
  font-size: 1rem;
}

.badge {
  border-radius: 999px;
  background: #e7fbf6;
  padding: 5px 9px;
  color: var(--success);
  font-size: 0.72rem;
  font-weight: 900;
}

.badge.danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.rail-card p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.48;
}

.case-memory-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.case-memory-list div {
  display: grid;
  gap: 2px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.case-memory-list strong {
  color: var(--navy);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.metric-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 13px;
}

.metric-list div {
  border-radius: 8px;
  background: var(--soft);
  padding: 10px;
}

.metric-list dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.metric-list dd {
  margin-top: 3px;
  color: var(--navy);
  font-size: 1rem;
  font-weight: 900;
}

.alert-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 19px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.38;
}

.library-dashboard {
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.library-filter-card {
  display: grid;
  gap: 10px;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
}

.category-list {
  display: grid;
  gap: 5px;
}

.category-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 36px;
  border-radius: 8px;
  background: transparent;
  padding: 0 8px;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}

.category-item:hover,
.category-item.active {
  background: #e7fbf6;
  color: var(--navy);
}

.category-label {
  overflow: hidden;
  font-size: 0.84rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-count {
  border-radius: 999px;
  background: #fff;
  padding: 3px 7px;
  font-size: 0.72rem;
  font-weight: 900;
}

.library-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(6, 36, 82, 0.96), rgba(9, 64, 108, 0.94) 58%, rgba(27, 183, 167, 0.78)),
    var(--navy);
  padding: 18px;
  color: #fff;
  box-shadow: var(--shadow);
}

.library-hero p,
.library-section-head p {
  color: #aeece4;
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
}

.library-hero h2 {
  max-width: 760px;
  margin-top: 4px;
  font-size: 1.35rem;
  line-height: 1.2;
}

.library-stat-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(90px, 1fr));
  gap: 8px;
  min-width: 360px;
}

.library-stat-strip div {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  padding: 10px;
}

.library-stat-strip dt {
  color: #c6f5ef;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.library-stat-strip dd {
  margin-top: 2px;
  font-size: 1.2rem;
  font-weight: 900;
}

.library-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 165px 190px 150px;
  gap: 10px;
}

.library-search {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 12px;
  color: var(--muted);
}

.library-search input,
#languageFilter,
#sourceTypeFilter,
#yearFilter {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  outline: none;
}

#languageFilter,
#sourceTypeFilter,
#yearFilter {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 10px;
  cursor: pointer;
}

.library-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: start;
}

.library-main {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.library-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  padding: 14px 16px;
  box-shadow: 0 12px 32px rgba(6, 36, 82, 0.06);
}

.library-section-head h2 {
  margin-top: 3px;
  font-size: 1.1rem;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.book-card {
  display: grid;
  gap: 10px;
  min-height: 255px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  box-shadow: 0 12px 32px rgba(6, 36, 82, 0.07);
}

.book-meta {
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.book-card h3 {
  color: var(--navy);
  font-size: 1rem;
  line-height: 1.3;
}

.book-publisher {
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.4;
}

.topic-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.topic-chip {
  border-radius: 999px;
  background: #eef8fb;
  padding: 5px 8px;
  color: #35516c;
  font-size: 0.72rem;
  font-weight: 800;
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.book-actions a,
.book-actions button,
.form-actions button,
.form-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 900;
  cursor: pointer;
}

.book-primary {
  background: var(--teal);
  color: #fff;
}

.book-secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
}

.danger-action {
  color: var(--danger);
}

.book-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 9px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.empty-library {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 240px;
  border: 1px dashed #b9cbd8;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  padding: 26px;
  text-align: center;
}

.empty-library .icon {
  width: 34px;
  height: 34px;
  color: var(--teal);
}

.empty-library .icon svg {
  width: 34px;
  height: 34px;
}

.empty-library p {
  color: var(--muted);
}

.case-workspace,
.study-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: start;
}

.study-layout {
  grid-template-columns: 360px minmax(0, 1fr);
}

.case-editor,
.study-form,
.study-output {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  padding: 16px;
}

.case-editor label,
.study-form label {
  display: grid;
  gap: 6px;
  color: var(--navy);
  font-size: 0.82rem;
  font-weight: 900;
}

.case-editor input,
.case-editor textarea,
.study-form input,
.study-form textarea,
.study-form select {
  width: 100%;
  border: 1px solid #c8d8e4;
  border-radius: 8px;
  background: #fff;
  padding: 10px 11px;
  color: var(--ink);
  outline: none;
}

.case-editor textarea,
.study-form textarea {
  min-height: 96px;
  max-height: 210px;
  resize: none;
  overflow-y: auto;
}

.form-grid {
  display: grid;
  gap: 10px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.case-list {
  display: grid;
  gap: 6px;
}

.case-list-item {
  border: 1px solid transparent;
  border-radius: 8px;
  background: #fff;
  padding: 9px 10px;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  font-weight: 850;
}

.case-list-item:hover,
.case-list-item.active {
  border-color: #9de1d7;
  background: #ecfffb;
  color: var(--navy);
}

.study-answer {
  min-height: 430px;
  border: 1px solid #e0e9ef;
  border-radius: 8px;
  background: #fff;
  padding: 16px;
  white-space: pre-wrap;
  line-height: 1.55;
}

.study-sources {
  margin-top: 0;
}

.favorite-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.favorite-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  padding: 15px;
}

.favorite-card h2 {
  color: var(--navy);
  font-size: 1rem;
  line-height: 1.3;
}

.favorite-card p {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 8;
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: start;
}

.auth-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  padding: 16px;
  box-shadow: 0 14px 34px rgba(6, 36, 82, 0.07);
}

.auth-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  width: min(100%, 340px);
  border: 1px solid #dbe4ec;
  border-radius: 999px;
  background: #eef6f8;
  padding: 4px;
}

.auth-tabs button {
  min-height: 34px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 900;
}

.auth-tabs button.active,
.auth-tabs button[aria-selected="true"] {
  background: #fff;
  color: var(--navy);
  box-shadow: 0 6px 16px rgba(6, 36, 82, 0.1);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.oauth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.oauth-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 42px;
  border: 1px solid #dbe4ec;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 900;
}

.oauth-button span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.82rem;
}

.oauth-button.google span {
  background: #fff4f1;
  color: #c5221f;
}

.oauth-button.microsoft span {
  background: #eef6ff;
  color: #146fc6;
}

.oauth-button:hover {
  border-color: #8fded3;
  background: #f8fbfc;
}

.auth-divider {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
  height: 1px;
  background: var(--line);
  content: "";
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--navy);
  font-size: 0.82rem;
  font-weight: 900;
}

.auth-form input,
.auth-form select,
.auth-form textarea {
  width: 100%;
  border: 1px solid #c8d8e4;
  border-radius: 8px;
  background: #fff;
  padding: 11px;
  color: var(--ink);
  outline: none;
}

.auth-form textarea {
  min-height: 160px;
  max-height: 260px;
  resize: none;
  overflow-y: auto;
}

.auth-form input:focus,
.auth-form select:focus,
.auth-form textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(27, 183, 167, 0.16);
}

.auth-form button,
.account-actions button {
  min-height: 40px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
}

.auth-form button:disabled,
.account-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.form-note {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.account-state-card {
  display: grid;
  gap: 12px;
}

.account-actions {
  margin-top: 2px;
}

.work-form {
  align-content: start;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

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

  .content-grid {
    grid-template-columns: minmax(0, 1fr) 280px;
  }
}

@media (max-width: 920px) {
  body {
    height: auto;
    overflow-x: hidden;
  }

  .workspace {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
    overflow: visible;
  }

  .chat-list {
    max-height: none;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-item {
    justify-items: center;
    grid-template-columns: 1fr;
    gap: 5px;
    padding: 9px 6px;
    text-align: center;
  }

  .sidebar-status {
    display: none;
  }

  .dashboard {
    height: auto;
    overflow: visible;
    padding: 16px;
  }

  .welcome-band {
    display: flex;
  }

  .quick-grid {
    display: grid;
  }

  .content-grid {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .library-hero,
  .library-layout,
  .case-workspace,
  .study-layout,
  .library-toolbar,
  .auth-layout {
    grid-template-columns: 1fr;
  }

  .library-stat-strip {
    min-width: 0;
  }

  .chat-panel {
    min-height: 720px;
  }

  .messages {
    min-height: 380px;
  }

  .right-rail {
    grid-template-columns: 1fr;
    overflow: visible;
  }
}

@media (max-width: 720px) {
  .topbar,
  .welcome-band {
    align-items: flex-start;
    flex-direction: column;
  }

  .quick-grid,
  .nav-list {
    grid-template-columns: 1fr;
  }

  .library-stat-strip {
    grid-template-columns: 1fr;
  }

  .oauth-grid {
    grid-template-columns: 1fr;
  }

  .form-grid.two {
    grid-template-columns: 1fr;
  }

  .book-grid {
    grid-template-columns: 1fr;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .safety-strip {
    max-width: 100%;
  }

  .input-row {
    grid-template-columns: 1fr;
  }

  textarea {
    height: 150px;
    min-height: 150px;
    max-height: 150px;
  }

  #sendButton {
    width: 100%;
  }

  .profile-button span:first-child {
    display: none;
  }

  .memory-button span:last-child {
    display: none;
  }
}

@media (max-width: 480px) {
  .dashboard {
    padding: 12px;
  }

  .welcome-band,
  .tool-tile,
  .rail-card,
  .panel-head,
  .composer {
    padding: 13px;
  }

  .chat-panel {
    min-height: 680px;
  }

  .messages {
    padding: 13px;
  }

  .message {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .message.user {
    grid-template-columns: minmax(0, 1fr) 32px;
  }

  .avatar {
    width: 32px;
    height: 32px;
    font-size: 0.82rem;
  }
}
