/* ChatRepo: calm surfaces, one accent, chats that read like chats. Phone first; light and dark. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e7eaef;
  --border: #e3e6eb;
  --border-strong: #cdd2da;
  --text: #161b24;
  --text-2: #4b5565;
  --accent: #4f5bd5;
  --accent-hover: #4350c4;
  --accent-soft: #eef0fd;
  --accent-text: #3a45b0;
  --on-accent: #ffffff;
  --claude: #c96442;
  --claude-soft: #fbece6;
  --claude-text: #a94e2e;
  --chatgpt: #10a37f;
  --chatgpt-soft: #e2f4ee;
  --chatgpt-text: #0b7a5e;
  --other: #6b7280;
  --other-soft: #eef0f3;
  --other-text: #4b5563;
  --danger: #c8341f;
  --danger-soft: #fdecea;
  --danger-text: #b3261e;
  --on-danger: #ffffff;
  --success-soft: #e6f5ee;
  --success-text: #11704f;
  --code-bg: #1d2230;
  --code-text: #e6e9ef;
  --inline-code-bg: #eceff3;
  --bubble: #e9ecfc;
  --shadow-sm: 0 1px 2px rgb(16 24 40 / 0.05);
  --shadow: 0 2px 6px rgb(16 24 40 / 0.07), 0 1px 2px rgb(16 24 40 / 0.05);
  --shadow-lg: 0 12px 32px rgb(16 24 40 / 0.18);
  --radius: 14px;
  --radius-sm: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161a21;
    --surface-2: #1c212a;
    --surface-3: #252b36;
    --border: #262c37;
    --border-strong: #363d4b;
    --text: #e8ebf1;
    --text-2: #a7b0bf;
    --accent: #8891ff;
    --accent-hover: #9ca3ff;
    --accent-soft: #22264a;
    --accent-text: #c2c7ff;
    --on-accent: #0e1116;
    --claude: #d9774f;
    --claude-soft: #2d1e18;
    --claude-text: #f0a07f;
    --chatgpt: #19a982;
    --chatgpt-soft: #11291f;
    --chatgpt-text: #4fd1a5;
    --other: #8a93a3;
    --other-soft: #232833;
    --other-text: #c3cad6;
    --danger: #ff7a6b;
    --danger-soft: #35191a;
    --danger-text: #ff9b8f;
    --on-danger: #0e1116;
    --success-soft: #12291f;
    --success-text: #5fd3a2;
    --code-bg: #0a0c10;
    --inline-code-bg: #252b36;
    --bubble: #262b52;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow: 0 2px 8px rgb(0 0 0 / 0.45);
    --shadow-lg: 0 12px 32px rgb(0 0 0 / 0.6);
  }
}

/* Base */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

h1 {
  margin: 0;
  font-size: clamp(1.5rem, 1.25rem + 1.1vw, 2rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.icon { flex: none; width: 1.1em; height: 1.1em; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}

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

/* Top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}

.topbar-inner {
  max-width: 60rem;
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.logo { width: 2rem; height: 2rem; flex: none; color: var(--accent); }

.search { position: relative; flex: 1; max-width: 26rem; margin-left: auto; }
.search > .icon {
  position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%);
  color: var(--text-2); pointer-events: none;
}
.search input {
  width: 100%;
  height: 2.6rem;
  padding: 0 2.4rem 0 2.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
.search input::placeholder { color: var(--text-2); }
.search input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.search-key {
  position: absolute; right: 0.7rem; top: 50%; transform: translateY(-50%);
  min-width: 1.4rem; padding: 0 0.35rem; text-align: center;
  font: 600 0.75rem/1.35rem var(--mono); color: var(--text-2);
  border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface);
}
.search input:focus ~ .search-key, .search input:not(:placeholder-shown) ~ .search-key { display: none; }
@media (hover: none) { .search-key { display: none; } }
@media (max-width: 22rem) { .brand span { display: none; } }

.signout { flex: none; }
.btn-quiet { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); padding: 0 0.6rem; }
.btn-quiet:hover { background: var(--surface-2); color: var(--text); }
.chip-dev { flex: none; background: var(--claude-soft); color: var(--claude-text); }
@media (max-width: 30rem) { .signout-label { display: none; } }

/* Page */

.page { max-width: 60rem; margin: 0 auto; padding: 1.5rem 1rem 5rem; }

.page-head { margin-bottom: 1.5rem; }
.page-sub { margin: 0.4rem 0 0; color: var(--text-2); }
.back {
  display: inline-flex; align-items: center; gap: 0.2rem; margin: 0 0 0.6rem -0.3rem;
  min-height: 2.25rem; padding: 0 0.3rem; color: var(--text-2); font-size: 0.92rem;
}
.back:hover { color: var(--text); text-decoration: none; }

.section-title {
  margin: 2.25rem 0 0.8rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-2);
}
.page-head + section .section-title { margin-top: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
}

/* Folders */

.folder-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
}
.folder-card {
  display: flex; flex-direction: column; height: 100%;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.folder-card:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-2px); }
.folder-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.4rem; height: 2.4rem; margin-bottom: 0.75rem;
  border-radius: 11px; background: var(--accent-soft); color: var(--accent);
}
.folder-icon .icon { width: 1.25rem; height: 1.25rem; }
.folder-name { font-weight: 650; line-height: 1.3; }
.folder-meta { margin-top: 0.15rem; font-size: 0.84rem; color: var(--text-2); }
@media (max-width: 30rem) { .folder-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Chat cards */

.chat-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.chat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.chat-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.chat-card-link { display: block; padding: 1rem 1.15rem 0.6rem; color: var(--text); }
.chat-card-link:hover { text-decoration: none; }
.chat-card-title { display: block; font-weight: 650; font-size: 1.06rem; line-height: 1.35; }
.chat-card-link:hover .chat-card-title { color: var(--accent); }
.chat-card-summary {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  margin-top: 0.3rem; color: var(--text-2); font-size: 0.94rem; line-height: 1.5;
}
.chat-card-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem;
  padding: 0 1.15rem 0.95rem; font-size: 0.8rem;
}
.chat-card-time { margin-left: auto; color: var(--text-2); white-space: nowrap; }

/* Chips and source badges */

.chip, .source {
  display: inline-flex; align-items: center; gap: 0.3rem;
  min-height: 1.75rem; max-width: 100%; padding: 0 0.65rem;
  border-radius: 999px; font-size: 0.8rem; font-weight: 550; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip { background: var(--surface-2); color: var(--text-2); }
.chip span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.chip .icon { width: 0.95em; height: 0.95em; }
a.chip:hover { text-decoration: none; background: var(--surface-3); color: var(--text); }
.chip-tag { background: var(--accent-soft); color: var(--accent-text); }
a.chip-tag:hover { background: var(--accent-soft); color: var(--accent-text); filter: brightness(0.97); }
.chip-filter { min-height: 2.25rem; padding: 0 0.5rem 0 0.75rem; border: 1px solid var(--border-strong); background: var(--surface); }
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }

.source::before { content: ""; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: currentColor; flex: none; }
.source-claude { background: var(--claude-soft); color: var(--claude-text); }
.source-chatgpt { background: var(--chatgpt-soft); color: var(--chatgpt-text); }
.source-other { background: var(--other-soft); color: var(--other-text); }

/* Buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 2.75rem; padding: 0 1.05rem;
  border: 1px solid var(--border-strong); border-radius: 11px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 0.95rem; font-weight: 550;
  box-shadow: var(--shadow-sm); cursor: pointer; white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn-danger:hover { background: var(--danger); filter: brightness(1.06); }
.btn-quiet-danger { color: var(--danger-text); background: transparent; border-color: transparent; box-shadow: none; }
.btn-quiet-danger:hover { background: var(--danger-soft); }

/* Banners and the toast */

.banner {
  display: flex; align-items: flex-start; gap: 0.6rem;
  margin: 0 0 1.25rem; padding: 0.8rem 1rem;
  border-radius: var(--radius-sm); font-size: 0.95rem;
}
.banner .icon { margin-top: 0.22rem; }
.banner-success { background: var(--success-soft); color: var(--success-text); }
.banner-error { background: var(--danger-soft); color: var(--danger-text); }
.banner-info { background: var(--surface-2); color: var(--text-2); }

.toast {
  position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom)); z-index: 20;
  max-width: calc(100vw - 2rem); padding: 0.75rem 1.2rem;
  transform: translateX(-50%);
  border-radius: 999px; background: var(--text); color: var(--bg);
  font-size: 0.92rem; font-weight: 550; box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease-out;
}
.toast:empty { display: none; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 0.5rem); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* The empty library */

.welcome { max-width: 34rem; margin: 2rem auto; text-align: center; padding: 2.25rem 1.5rem; }
.welcome-mark .logo { width: 3.5rem; height: 3.5rem; margin-bottom: 1rem; }
.welcome p { margin: 0.75rem 0 0; }
.prompt {
  display: flex; align-items: flex-start; gap: 0.6rem; text-align: left;
  margin: 1.25rem 0 0; padding: 0.9rem 1rem;
  border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-text); font-weight: 500;
}
.prompt .icon { margin-top: 0.22rem; }
.empty { padding: 2rem 0; color: var(--text-2); }
.empty p { margin: 0 0 1rem; }

/* Pager */

.pager {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  margin: 1.5rem 0; color: var(--text-2); font-size: 0.9rem;
}
.pager a {
  display: inline-flex; align-items: center; gap: 0.3rem;
  min-height: 2.75rem; padding: 0 1rem;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm);
}
.pager a:hover { text-decoration: none; border-color: var(--border-strong); }

/* One chat */

.crumbs {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem;
  margin: -0.25rem 0 1rem; font-size: 0.92rem; color: var(--text-2);
}
.crumbs a { display: inline-flex; align-items: center; gap: 0.2rem; min-height: 2.25rem; color: var(--text-2); }
.crumbs a:hover { color: var(--text); text-decoration: none; }

.chat-head {
  padding: 1.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow-sm);
}
.chat-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem;
  margin-top: 0.85rem; color: var(--text-2); font-size: 0.875rem;
}
.meta-item { display: inline-flex; align-items: center; gap: 0.35rem; }
a.meta-item { color: var(--accent); }
.tag-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.8rem; }
.summary-box {
  margin-top: 1.15rem; padding: 0.85rem 1rem;
  background: var(--surface-2); border-radius: var(--radius-sm); border-left: 3px solid var(--accent);
}
.summary-label {
  display: block; margin-bottom: 0.2rem;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-2);
}
.summary-box p { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.25rem; }
.created { margin: 0.9rem 0 0; color: var(--text-2); font-size: 0.82rem; }
@media (max-width: 30rem) { .actions .btn { flex: 1 1 calc(50% - 0.25rem); } }
@media (min-width: 40rem) { .chat-head { padding: 1.75rem 1.9rem; } }

/* The conversation */

.conversation { display: flex; flex-direction: column; gap: 1.6rem; margin-top: 2rem; }

.turn-user { align-self: flex-end; display: flex; flex-direction: column; align-items: flex-end; max-width: min(88%, 40rem); }
.turn-label { margin: 0 0.6rem 0.3rem; font-size: 0.75rem; font-weight: 650; color: var(--text-2); }
.bubble {
  padding: 0.75rem 1.05rem;
  background: var(--bubble);
  border-radius: 20px 20px 6px 20px;
  max-width: 100%;
}

.turn-assistant { min-width: 0; }
.turn-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.45rem; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 1.85rem; height: 1.85rem; border-radius: 50%;
  background: var(--other); color: #fff; font-weight: 700; font-size: 0.82rem;
}
.assistant-claude .avatar { background: var(--claude); }
.assistant-chatgpt .avatar { background: var(--chatgpt); }
.turn-name { font-weight: 650; font-size: 0.92rem; }
.turn-assistant .prose { padding-left: 2.45rem; }
@media (max-width: 30rem) { .turn-assistant .prose { padding-left: 0; } }

.divider { display: flex; align-items: center; gap: 0.75rem; color: var(--text-2); font-size: 0.8rem; font-weight: 600; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border-strong); }
.divider span {
  padding: 0.3rem 0.8rem; text-align: center;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
}

.prose-document {
  padding: 1.35rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px);
}
@media (min-width: 40rem) { .prose-document { padding: 1.75rem 1.9rem; } }

/* Text written in markdown */

.prose { line-height: 1.7; min-width: 0; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose table { margin: 0 0 0.9rem; }
.prose h2, .prose h3, .prose h4, .prose h5, .prose h6 { margin: 1.5rem 0 0.6rem; line-height: 1.3; letter-spacing: -0.01em; }
.prose h2 { font-size: 1.3rem; }
.prose h3 { font-size: 1.12rem; }
.prose h4, .prose h5, .prose h6 { font-size: 1rem; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin: 0.25rem 0; }
.prose li > p { margin: 0.25rem 0; }
.prose a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: currentColor; }
.prose strong { font-weight: 650; }
.prose code {
  padding: 0.12em 0.38em; border-radius: 6px;
  background: var(--inline-code-bg); font-family: var(--mono); font-size: 0.86em;
}
.bubble code { background: color-mix(in srgb, var(--surface) 60%, transparent); }
.prose pre {
  padding: 0.95rem 1.1rem; border-radius: 12px;
  background: var(--code-bg); color: var(--code-text);
  font-size: 0.85rem; line-height: 1.55;
  overflow-x: auto; overflow-wrap: normal;
}
.prose pre code { padding: 0; background: none; color: inherit; font-size: inherit; white-space: pre; }
.prose blockquote { margin-left: 0; padding: 0.1rem 0 0.1rem 1rem; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.prose hr { margin: 1.5rem 0; border: 0; border-top: 1px solid var(--border); }
.prose table {
  display: block; max-width: 100%; overflow-x: auto;
  border-collapse: separate; border-spacing: 0;
  border: 1px solid var(--border); border-radius: 10px; font-size: 0.92rem;
}
.prose th, .prose td { padding: 0.5rem 0.8rem; text-align: left; border-bottom: 1px solid var(--border); }
.prose th + th, .prose td + td { border-left: 1px solid var(--border); }
.prose tr:last-child td { border-bottom: 0; }
.prose th { background: var(--surface-2); font-weight: 650; }
.prose .align-center { text-align: center; }
.prose .align-right { text-align: right; }
.prose a[target="_blank"]:not([href^="mailto:"])::after { content: "↗"; margin-left: 0.15em; font-size: 0.8em; text-decoration: none; display: inline-block; }

/* Forms */

.form-card { max-width: 38rem; }
.form { display: grid; gap: 1.15rem; margin-top: 1.5rem; }
.field { display: grid; gap: 0.35rem; }
.field-label { font-weight: 650; font-size: 0.92rem; }
.field-hint { color: var(--text-2); font-size: 0.83rem; }
.field input {
  width: 100%; height: 2.85rem; padding: 0 0.9rem;
  border: 1px solid var(--border-strong); border-radius: 11px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 1rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.4rem; }
.form-actions-center { justify-content: center; }

/* Confirmation and error pages */

.center-card { max-width: 32rem; margin: 2rem auto; text-align: center; padding: 2.25rem 1.5rem; }
.login-card .banner { text-align: left; }
.center-card h1 { font-size: 1.45rem; }
.center-card p { color: var(--text-2); margin: 0.85rem 0 1.5rem; }
.big-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 3.25rem; height: 3.25rem; margin-bottom: 1rem;
  border-radius: 50%; background: var(--surface-2); color: var(--text-2);
}
.big-icon .icon { width: 1.5rem; height: 1.5rem; }
.big-icon-danger { background: var(--danger-soft); color: var(--danger-text); }

/* Fallback when the browser won't let the page write to the clipboard */

dialog {
  width: min(40rem, calc(100vw - 2rem)); padding: 1.5rem;
  border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgb(10 12 16 / 0.55); }
dialog h2 { margin: 0 0 0.5rem; font-size: 1.15rem; }
dialog p { margin: 0 0 1rem; color: var(--text-2); }
dialog textarea {
  width: 100%; padding: 0.75rem; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface-2); color: var(--text); font: 0.85rem/1.5 var(--mono);
}
dialog form { margin-top: 1rem; text-align: right; }

@media (min-width: 40rem) {
  .topbar-inner { padding: 0.65rem 1.5rem; }
  .page { padding: 2.25rem 1.5rem 6rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
