@font-face {
  font-family: "Source Sans 3";
  src: url("../vendor/fonts/source-sans-3-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Sans 3";
  src: url("../vendor/fonts/source-sans-3-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Sans 3";
  src: url("../vendor/fonts/source-sans-3-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #efece4;
  --paper: #fbfaf6;
  --ink: #1c1915;
  --muted: #5e584f;
  --line: #e3dcd0;
  --sidebar: #243028;
  --sidebar-text: #e7efe8;
  --forest: #1f6b5a;
  --copper: #c4652d;
  --bs-body-font-family: "Source Sans 3", "Avenir Next", "Segoe UI", sans-serif;
  --bs-body-color: var(--ink);
  --bs-primary: var(--forest);
  --bs-primary-rgb: 31, 107, 90;
  --bs-border-radius: 0.6rem;
}

body, button, input, select, textarea, .btn, .form-control, .form-select, .dropdown-menu {
  font-family: "Source Sans 3", "Avenir Next", "Segoe UI", sans-serif;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: white;
  padding: 8px 12px;
  z-index: 2000;
}
.skip:focus { top: 12px; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 1.25rem;
}
.mark {
  width: 28px;
  height: 22px;
  border-radius: 4px 4px 3px 3px;
  background:
    linear-gradient(#c4652d, #c4652d) 0 8px / 100% 3px no-repeat,
    #f4efe4;
  box-shadow: inset 0 0 0 1.5px rgba(28, 25, 21, 0.2);
  position: relative;
}
.mark:before {
  content: "";
  position: absolute;
  left: 2px;
  top: -4px;
  width: 12px;
  height: 6px;
  background: #f4efe4;
  border-radius: 3px 3px 0 0;
}

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px;
  flex: none;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 22px 16px 16px;
}
.sidebar .brand { margin-bottom: 16px; }
.sidebar-search { display: flex; gap: 6px; margin-bottom: 16px; }
.sidebar-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--sidebar-text);
  padding: 8px 12px;
}
.sidebar-search input::placeholder { color: #b7c4bc; }
.sidebar-search button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: var(--forest);
  color: #fff;
  flex: none;
}
.workspace.is-library #searchForm,
.workspace.is-library .ai-status,
.workspace.is-chat-off #searchForm,
.workspace.is-chat-off .ai-status { display: none; }
.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--sidebar-text);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 4px;
}
.nav-btn i { width: 1.1rem; text-align: center; }
.nav-btn.active, .nav-btn:hover { background: rgba(255, 255, 255, 0.1); }
.sidebar-foot { margin-top: auto; padding-top: 16px; }
.sidebar-foot .btn { margin: 8px 8px 0 0; }
#who { font-weight: 700; }
#usage { color: #b7c4bc; font-size: 0.92rem; }

.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 16px 20px 0;
}
#searchForm { display: flex; gap: 8px; flex: 1; }
#searchInput {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 10px 16px;
}
.menu-button { display: none; }
.ai-status { margin: 6px 22px 0; color: var(--muted); font-size: 0.92rem; }
.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 20px;
}
.toolbar-lead { display: flex; gap: 12px; align-items: center; min-width: 0; flex-wrap: wrap; }
.library-filter .form-select { width: auto; }
.tag-filter { position: relative; width: 200px; max-width: 100%; }
.tag-filter-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(28, 25, 21, 0.08);
}
.tag-filter-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink);
  border-radius: 6px;
  padding: 6px 8px;
}
.tag-filter-menu button:hover,
.tag-filter-menu button.is-active { background: rgba(31, 107, 90, 0.1); }
.tag-filter-menu .tag-option-empty { color: var(--muted); padding: 6px 8px; }
.icon-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-button:hover, .icon-button:focus-visible { background: rgba(28, 25, 21, 0.06); color: var(--ink); }
.dropdown-item i { width: 1.1rem; margin-right: 8px; }
.btn i, .sidebar-foot .btn i { margin-right: 6px; }
.settings-block { margin-bottom: 28px; max-width: 520px; }
#crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.crumb {
  border: 0;
  background: transparent;
  color: var(--forest);
  padding: 0;
}
.crumb.current { color: var(--ink); font-weight: 700; }
#content { padding: 0 20px 28px; outline: none; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}
.entry {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  text-align: left;
  width: 100%;
  cursor: pointer;
}
.entry:hover, .entry.drop-target { border-color: #b9cfc8; }
.entry:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }
.entry-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.entry-identity { display: flex; gap: 10px; align-items: flex-start; min-width: 0; flex: 1; }
.entry-copy { min-width: 0; }
.file-name { font-weight: 700; overflow-wrap: anywhere; }
.type-icon { width: 34px; height: 34px; flex: none; display: block; color: #6e675e; }
.type-icon svg { width: 34px; height: 34px; display: block; }
.type-folder { color: #c4922a; }
.type-image { color: #3d7ea6; }
.type-video { color: #6b4c9a; }
.type-audio { color: #1f6b5a; }
.type-pdf { color: #a33b3b; }
.type-sheet { color: #2f7d4f; }
.type-slides { color: #c4652d; }
.type-doc { color: #3d5a80; }
.type-archive { color: #8a6232; }
.type-code { color: #3f6b5a; }
.name-with-icon { display: inline-flex; align-items: center; gap: 8px; }
.name-with-icon .type-icon,
.name-with-icon .type-icon svg { width: 26px; height: 26px; }
.detail-title { display: flex; align-items: flex-start; gap: 10px; }
.meta, .lede, .empty p { color: var(--muted); }
.trash-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.trash-bar .lede { margin: 0; }
.match-reason { margin-top: 8px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f3efe6;
  border-radius: 999px;
  padding: 2px 8px;
  margin: 6px 6px 0 0;
  font-size: 0.85rem;
}
.pill-remove {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  line-height: 1;
}
.pill-remove:hover { color: #8d2a2a; }
.vis-private { color: var(--muted); }
.vis-shared { color: #8a4b12; }
.vis-public { color: var(--forest); }
.list .entry { display: grid; grid-template-columns: 1fr auto; align-items: center; }
.empty { padding: 32px 8px; max-width: 460px; }
.empty h2 { font-size: 1.4rem; }
.table-wrap { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 12px 12px 4px; overflow: auto; }
div.dt-container .dt-search input,
div.dt-container .dt-length select { font-family: "Source Sans 3", "Avenir Next", "Segoe UI", sans-serif; }
.detail {
  width: 480px;
  flex: none;
  background: var(--paper);
  border-left: 1px solid var(--line);
  padding: 18px;
  overflow: auto;
}
.detail.is-hidden { display: none; }
.file-preview {
  margin-top: 8px;
  background: #f3efe6;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}
.file-preview img,
.file-preview video,
.file-preview audio { width: 100%; }
.file-preview iframe {
  width: 100%;
  height: 70vh;
  border: 0;
  background: white;
  border-radius: 6px;
}
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.tag-editor { display: flex; gap: 8px; }
.form-error { color: #8d2a2a; margin-top: 8px; }
.upload-list, .share-list {
  max-width: 100%;
  padding-left: 18px;
  overflow-wrap: anywhere;
}
.upload-list li, .share-list li { overflow-wrap: anywhere; }
.modal-content { min-width: 0; overflow-wrap: anywhere; }
.share-results button { display: block; width: 100%; text-align: left; }
mark { background: #f3d7b0; color: inherit; padding: 0 2px; border-radius: 3px; }
.backdrop { position: fixed; inset: 0; background: rgba(28, 25, 21, 0.45); z-index: 1030; }

.workspace.is-chat {
  background: #fbfaf6;
  min-height: 100vh;
}
.workspace.is-chat .topbar,
.workspace.is-chat .toolbar,
.workspace.is-chat .ai-status { display: none; }
.workspace.is-chat #content { display: flex; flex-direction: column; min-height: 0; flex: 1; padding-bottom: 12px; }
.workspace.is-chat #view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.workspace.is-chat .chat-composer { display: flex; }
.workspace.is-chat.is-empty { justify-content: center; }
.workspace.is-chat.is-empty #content {
  flex: 0 0 auto;
  padding-bottom: 0;
}
.workspace.is-chat.is-empty .chat-hero {
  margin: 0 0 28px;
  padding: 0 16px;
}
.workspace.is-chat.is-empty .chat-composer {
  width: min(640px, calc(100% - 48px));
  margin: 0 auto 14px;
  border-radius: 999px;
  padding: 6px 8px 6px 18px;
  box-shadow: 0 10px 32px rgba(28, 25, 21, 0.07);
}
.chat-examples { display: none; }
.workspace.is-chat.is-empty .chat-examples {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: min(640px, calc(100% - 48px));
  margin: 0 auto 10vh;
}
.chat-example {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.3;
  cursor: pointer;
}
.chat-example:hover { border-color: #b9cfc8; color: var(--forest); }
.chat-example:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }
.workspace.is-chat:not(.is-empty) .chat-composer {
  width: min(760px, calc(100% - 40px));
  margin: 0 auto 18px;
  border-radius: 28px;
}
.chat-hero { text-align: center; }
.chat-hero h2 { font-size: 1.85rem; font-weight: 500; margin: 0; letter-spacing: -0.02em; }
.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow: auto;
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 28px 8px 12px;
}
.chat-bubble { max-width: 720px; }
.chat-bubble.is-user {
  align-self: flex-end;
  background: #f3efe6;
  color: var(--ink);
  border-radius: 18px;
  padding: 10px 14px;
}
.chat-bubble.is-user p,
.chat-bubble.is-assistant > p { margin: 0 0 10px; }
.chat-bubble.is-user p:last-child,
.chat-bubble.is-assistant > p:last-child { margin-bottom: 0; }
.chat-bubble.is-assistant { align-self: stretch; }
.chat-pending {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
}
.chat-dots { display: inline-flex; gap: 4px; align-items: flex-end; height: 12px; }
.chat-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--forest);
  animation: chat-dot 1s infinite ease-in-out;
}
.chat-dots span:nth-child(2) { animation-delay: 0.15s; }
.chat-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-dot {
  0%, 70%, 100% { transform: translateY(0); opacity: 0.3; }
  35% { transform: translateY(-5px); opacity: 1; }
}
.chat-composer {
  display: none;
  gap: 8px;
  align-items: flex-end;
  margin: 0 20px 16px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
}
.chat-composer textarea {
  flex: 1;
  border: 0;
  resize: none;
  min-height: 44px;
  max-height: 160px;
  padding: 8px 4px;
  background: transparent;
  outline: none;
}
.chat-send {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: #c5bfb4;
  color: #fff;
  display: grid;
  place-items: center;
  flex: none;
}
.chat-composer textarea:not(:placeholder-shown) + .chat-send {
  background: var(--forest);
}
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card .brand { margin-bottom: 18px; }
.login-card, .error-page {
  width: min(420px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
}
.error-page { margin: 10vh auto; }
code { font-family: "Source Sans 3", sans-serif; font-weight: 700; }
.auth-qr { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; width: fit-content; }
.auth-qr svg { width: 220px; height: auto; display: block; }

.btn-primary {
  --bs-btn-bg: var(--forest);
  --bs-btn-border-color: var(--forest);
  --bs-btn-hover-bg: #184e43;
  --bs-btn-hover-border-color: #184e43;
  --bs-btn-active-bg: #143f36;
  --bs-btn-active-border-color: #143f36;
}
.btn-outline-light { --bs-btn-color: #f4efe4; --bs-btn-border-color: rgba(244, 239, 228, 0.4); }

@media (min-width: 992px) {
  .workspace.is-library .topbar,
  .workspace.is-chat-off .topbar { display: none; }
}
@media (max-width: 991px) {
  .menu-button { display: inline-flex; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    transform: translateX(-105%);
    transition: transform 0.18s ease;
  }
  .sidebar.is-open { transform: none; }
  .detail {
    position: fixed;
    inset: 0;
    width: auto;
    z-index: 1050;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
  .chat-dots span { animation: none; opacity: 0.7; }
}
