@import url("https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap");
:root {
  --bg: #f7f7f8;
  --text: #0f172a;
  --muted: #6b7280;
  --border: rgba(15, 23, 42, 0.08);
  --chip: #ffffff;
  --chip-hover: #ffffff;
  --accent: #111827;
  --accent-2: #0f172a;
  --card: #ffffff;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  transition: opacity 200ms ease;
}
.login-wrap {
  background: #1f2431;
}
.page {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 220ms ease, transform 220ms ease;
}
.page.is-ready {
  opacity: 1;
  transform: translateY(0);
}
.page.is-leaving {
  opacity: 0;
  transform: translateY(6px);
}
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 18px 56px;
}
.menu {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 18px;
  margin-bottom: 18px;
}
.menu-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.menu-logo {
  width: 55px;
  height: 55px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.menu-logo img { width: 100%; height: 100%; object-fit: cover; }
.menu-title { font-weight: 700; font-size: 16px; }
.menu-sub { color: var(--muted); font-size: 12px; }
.menu-links { display: flex; gap: 10px; }
.menu-link {
  text-decoration: none;
  color: var(--text);
  border: 2px solid rgb(238, 238, 240);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  background: #ffffff;
}
.menu-link.active {
  color: #ffffff;
  background: var(--accent);
  border-color: transparent;
}
.hero {
  margin-bottom: 18px;
  padding: 8px 0 10px;
}
.hero-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  border: 2px solid rgb(238, 238, 240);
  overflow: hidden;
}
.hero-icon img { width: 100%; height: 100%; object-fit: cover; }
.hero-title { font-size: 34px; font-weight: 700; letter-spacing: -0.2px; }
.hero-subtitle { color: var(--muted); margin-top: 6px; }

.input-card {
  border-radius: 20px;
  padding: 10px 12px;
  background: var(--card);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  margin-bottom: 10px;
}
.row { display: flex; gap: 10px; align-items: center; }
.row input {
  flex: 1;
  border-radius: 999px;
  border: 2px solid rgb(238, 238, 240);
  background: #fff;
  padding: 12px 16px;
  font-size: 15px;
}
.row input:focus {
  outline: none;
  border-color: rgba(15, 23, 42, 0.18);
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.06);
}
.row button {
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
}
.row .send-btn:after { content: " ->"; font-family: "JetBrains Mono", monospace; }
.row .clear-btn {
  background: #ffffff;
  color: var(--text);
  border: 2px solid rgb(238, 238, 240);
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  border: 2px solid rgb(238, 238, 240);
  border-radius: 999px;
  padding: 7px 12px;
  background: var(--chip);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.chip:hover { background: var(--chip-hover); }

.msg {
  border: none;
  border-radius: 16px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--card);
  animation: floatIn 280ms ease-out;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
}
.msg.user { background: #f8fafc; }
.msg-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.action-btn {
  border: 2px solid rgb(238, 238, 240);
  background: #ffffff;
  color: var(--text);
  padding: 6px 8px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}
.action-btn.text-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
}
.action-btn.is-busy {
  opacity: 0.6;
  pointer-events: none;
}
.action-btn svg { width: 16px; height: 16px; }
.qa-humanized {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(15, 23, 42, 0.12);
}
.action-btn.selected,
.action-btn.saved {
  color: #ffffff;
  background: var(--accent);
  border-color: transparent;
}
.confidence {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border: 2px solid rgb(238, 238, 240);
  border-radius: 999px;
  margin-top: 8px;
}
.bar {
  height: 6px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}
.bar span { display: block; height: 100%; background: var(--accent); }
details { margin-top: 8px; }
summary { cursor: pointer; }
.meta { color: var(--muted); font-size: 12px; margin-top: 12px; }
.legal { color: var(--muted); font-size: 12px; margin-top: 16px; }
.legal-italic { font-style: italic; }
.error { color: #b91c1c; background: #fef2f2; border: 1px solid #fee2e2; padding: 8px 10px; border-radius: 10px; }
.notice { color: #166534; background: #f0fdf4; border: 1px solid #bbf7d0; padding: 8px 10px; border-radius: 10px; }
.loading {
  display: none;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 14px;
}
.loading .dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  animation: pulse 1s infinite ease-in-out;
}
.loading .dot:nth-child(2) { animation-delay: 0.2s; }
.loading .dot:nth-child(3) { animation-delay: 0.4s; }
body.is-loading .loading { display: inline-flex; }
.saved-card {
  border: none;
  border-radius: 18px;
  background: var(--card);
  padding: 18px;
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.08);
}
.saved-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.group-create {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.group-create input {
  border-radius: 999px;
  border: 2px solid rgb(238, 238, 240);
  padding: 8px 12px;
  font-size: 13px;
  background: #ffffff;
}
.group-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
}
.group-card {
  border-radius: 18px;
  border: 2px solid rgb(238, 238, 240);
  background: #ffffff;
  padding: 14px;
  display: flex;
  flex-direction: column;
  min-height: 200px;
}
.group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.group-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.group-title {
  font-weight: 700;
  font-size: 15px;
}
.group-meta {
  color: var(--muted);
  font-size: 12px;
}
.group-dropzone {
  display: grid;
  gap: 10px;
  flex: 1;
  padding: 6px;
  border-radius: 12px;
  border: 2px dashed transparent;
  transition: border-color 160ms ease, background 160ms ease;
  align-content: start;
  align-items: start;
}
.group-dropzone.is-over {
  border-color: rgba(15, 23, 42, 0.2);
  background: rgba(15, 23, 42, 0.04);
}
.saved-note {
  border-radius: 14px;
  border: 2px solid rgb(238, 238, 240);
  background: #ffffff;
  padding: 12px;
  display: grid;
  gap: 8px;
}
.saved-note-toggle summary {
  cursor: pointer;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}
.saved-note-toggle .qa-content {
  border-radius: 12px;
  border: 2px solid rgb(238, 238, 240);
  padding: 12px;
  background: #ffffff;
}
.saved-note.is-dragging {
  opacity: 0.5;
}
.saved-note-title {
  font-weight: 600;
  font-size: 14px;
}
.saved-note-body {
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
}
.saved-note-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}
.saved-note-bar {
  margin-top: 0;
}
.saved-note-actions {
  display: flex;
  gap: 8px;
}
.saved-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  align-items: center;
}
.group-form {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.group-form input {
  border-radius: 999px;
  border: 2px solid rgb(238, 238, 240);
  padding: 6px 12px;
  font-size: 13px;
  background: #ffffff;
}
.saved-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.saved-table th,
.saved-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid #eef2f7;
  vertical-align: top;
}
.users-table .user-name { font-weight: 600; }
.users-table .user-email { color: var(--muted); font-size: 12px; }
.perm-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.perm-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 2px solid rgb(238, 238, 240);
  background: #ffffff;
  color: var(--text);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
}
.perm-chip input {
  accent-color: var(--accent);
}
.perm-form .chip {
  margin-top: 8px;
}
.settings-block { margin-top: 12px; }
.settings-title {
  font-weight: 600;
  margin-bottom: 4px;
}
.settings-help {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
}
.settings-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}
.settings-warning {
  color: #fbbf24;
  font-size: 12px;
  margin-bottom: 8px;
}
.settings-reset {
  margin-top: 10px;
}
.master-prompt.is-hidden {
  display: none;
}
.settings-slider {
  display: flex;
  align-items: center;
  gap: 12px;
}
.settings-slider input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}
.settings-value {
  min-width: 40px;
  text-align: center;
  padding: 4px 8px;
  border-radius: 999px;
  border: 2px solid rgb(238, 238, 240);
  font-size: 12px;
}
.settings-textarea {
  width: 100%;
  border-radius: 12px;
  border: 2px solid rgb(238, 238, 240);
  padding: 12px;
  font-size: 14px;
  font-family: inherit;
}
.learn-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: grid;
  gap: 8px;
}
.learn-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid rgb(238, 238, 240);
  background: #ffffff;
}
.learn-add {
  display: flex;
  gap: 10px;
  align-items: center;
}
.learn-add input {
  flex: 1;
  border-radius: 999px;
  border: 2px solid rgb(238, 238, 240);
  padding: 10px 14px;
  background: #ffffff;
}
.qa-card {
  border-radius: 18px;
  padding: 16px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.08);
  margin-bottom: 12px;
}
.qa-block { margin-bottom: 12px; }
.qa-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}
.qa-content {
  border-radius: 12px;
  border: 2px solid rgb(238, 238, 240);
  padding: 12px;
  background: #ffffff;
  white-space: pre-wrap;
}
.thinking {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.thinking-dots {
  display: inline-flex;
  gap: 4px;
}
.thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0.4;
  animation: pulse 1s infinite ease-in-out;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
.qa-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.rating-split {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 999px;
  border: 2px solid rgb(238, 238, 240);
  background: #ffffff;
}
.rating-label {
  font-size: 12px;
  color: var(--muted);
  margin-right: 4px;
}
.feedback-box {
  border-radius: 12px;
  border: 2px solid rgb(238, 238, 240);
  padding: 12px;
  background: #ffffff;
  margin-bottom: 10px;
}
.feedback-box.is-hidden { display: none; }
.feedback-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.tag-chip.selected {
  color: #ffffff;
  background: var(--accent);
  border-color: transparent;
}
.login-wrap {
  max-width: none;
  padding: 0;
  background: #1f2431;
}
.login-card {
  width: 100%;
  border-radius: 20px;
  padding: 28px;
  background: #2a3143;
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 50px rgba(10, 14, 20, 0.35);
}
.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 520px);
  min-height: 100vh;
  gap: 24px;
  align-items: stretch;
}
.login-panel {
  padding: 48px 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}
.login-visual {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  background: url("/assets/img/loginpage.jpeg") center/cover no-repeat;
  min-height: 100vh;
  filter: saturate(0.9) contrast(1.05);
}
.login-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(20, 25, 36, 0.75), rgba(20, 25, 36, 0.2));
  display: flex;
  align-items: flex-start;
  padding: 24px;
}
.login-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: #ffffff;
}
.login-brand img {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #ffffff;
  padding: 6px;
}
.login-title { font-size: 20px; font-weight: 700; }
.login-subtitle { font-size: 13px; opacity: 0.85; }
.login-heading {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 10px;
}
.login-tabs {
  display: flex;
  gap: 20px;
  font-weight: 600;
  margin-bottom: 16px;
}
.login-tabs span {
  color: rgba(226, 232, 240, 0.6);
}
.login-tabs .active {
  color: #ffffff;
  border-bottom: 2px solid #38bdf8;
  padding-bottom: 6px;
}
.login-caption {
  color: rgba(226, 232, 240, 0.7);
  font-size: 13px;
  margin-bottom: 16px;
}
.login-form {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}
.login-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: rgba(226, 232, 240, 0.7);
}
.login-form input {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 12px;
  font-size: 14px;
  background: rgba(15, 23, 42, 0.6);
  color: #e2e8f0;
}
.login-form .send-btn {
  width: 100%;
  justify-content: center;
  background: transparent;
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 25px;
  padding: 12px 16px;
  height: 48px;
}
.login-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: rgba(226, 232, 240, 0.7);
}
.login-check {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.login-link {
  color: #7dd3fc;
}
.login-divider {
  text-align: center;
  color: rgba(226, 232, 240, 0.5);
  font-size: 12px;
  margin: 16px 0;
  position: relative;
}
.login-divider span {
  background: #2a3143;
  padding: 0 10px;
}
.login-alt {
  width: 100%;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 10px 16px;
  background: rgba(15, 23, 42, 0.4);
  color: #e2e8f0;
  cursor: pointer;
}
.login-footer {
  text-align: center;
  color: rgba(226, 232, 240, 0.6);
  font-size: 12px;
  margin-top: 18px;
}
.ref-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: grid;
  gap: 8px;
}
.ref-item {
  border-radius: 10px;
  border: 2px solid rgb(238, 238, 240);
  padding: 8px 10px;
  background: #ffffff;
}
.ref-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.ref-source {
  font-weight: 600;
  color: var(--text);
}
.ref-location {
  white-space: nowrap;
}
.ref-snippet {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
  white-space: pre-wrap;
}
.training-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}
.training-card {
  border-radius: 16px;
  border: 2px solid rgb(238, 238, 240);
  background: #ffffff;
  padding: 14px;
  display: grid;
  gap: 10px;
}
.training-header {
  display: grid;
  gap: 6px;
}
.training-title {
  font-weight: 600;
  font-size: 14px;
}
.training-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}
.training-body {
  white-space: pre-wrap;
}
.training-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.training-feedback {
  border-radius: 12px;
  border: 2px dashed rgb(238, 238, 240);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text);
  background: #ffffff;
}
.training-actions {
  display: flex;
  gap: 8px;
}
.accordion {
  border-radius: 16px;
  border: 2px solid rgb(238, 238, 240);
  background: #ffffff;
  margin-bottom: 12px;
  overflow: hidden;
}
.accordion-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
}
.accordion-summary::-webkit-details-marker { display: none; }
.accordion-title {
  font-weight: 600;
}
.accordion-meta {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.accordion[open] .accordion-summary {
  border-bottom: 2px solid rgb(238, 238, 240);
}
.rank-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.rank-form select {
  border-radius: 999px;
  border: 2px solid rgb(238, 238, 240);
  padding: 6px 10px;
  background: #ffffff;
  font-size: 13px;
}
.saved-table th { color: var(--muted); font-weight: 600; }
.saved-empty { color: var(--muted); font-size: 13px; }
@keyframes pulse {
  0%, 100% { transform: scale(0.7); opacity: 0.4; }
  50% { transform: scale(1); opacity: 1; }
}
@keyframes floatIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 860px) {
  .login-shell {
    grid-template-columns: 1fr;
  }
  .login-visual {
    min-height: 220px;
  }
  .login-panel {
    padding: 24px 18px 40px;
  }
}
