:root {
  font-family:
    Segoe UI,
    Roboto,
    system-ui,
    sans-serif;
  color-scheme: light;
  --accent: #6f46c7;
  --accent-soft: #eee8fa;
  --bg: #faf8f8;
  --surface: #fff;
  --ink: #181416;
  --muted: #68616b;
  --line: #e9e3eb;
  --own: #eee8fa;
  --conversation: #f4f1f5;
  font-size: 16px;
}
html[data-palette="rose"] {
  --accent: #9f234d;
  --accent-soft: #f8e5ec;
  --own: #f8e5ec;
}
html[data-palette="green"] {
  --accent: #23864b;
  --accent-soft: #e1f3e8;
  --own: #e1f3e8;
}
html[data-palette="blue"] {
  --accent: #147da9;
  --accent-soft: #e0f1f8;
  --own: #e0f1f8;
}
html[data-mode="dark"] {
  color-scheme: dark;
  --bg: #141216;
  --surface: #201d22;
  --ink: #f4eff2;
  --muted: #b7afbb;
  --line: #39323e;
  --conversation: #19161c;
  --accent-soft: #392b53;
  --own: #392b53;
  --accent: #c2a7ff;
}
html[data-mode="dark"][data-palette="rose"] {
  --accent: #f69db9;
  --accent-soft: #4c2635;
  --own: #4c2635;
}
html[data-mode="dark"][data-palette="green"] {
  --accent: #83d9a4;
  --accent-soft: #213d2d;
  --own: #213d2d;
}
html[data-mode="dark"][data-palette="blue"] {
  --accent: #8fd7f5;
  --accent-soft: #203c49;
  --own: #203c49;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}
button,
input,
select {
  font: inherit;
}
button {
  min-height: 44px;
  padding: 8px 14px;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}
button:hover {
  background: var(--accent-soft);
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
input,
select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
}
label {
  display: block;
  font-size: 14px;
  font-weight: 600;
}
label input,
label select {
  margin-top: 7px;
}
p {
  line-height: 1.6;
  color: var(--muted);
}
[hidden] {
  display: none !important;
}
.app {
  height: 100dvh;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  max-width: 1600px;
  margin: auto;
  border-inline: 1px solid var(--line);
}
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.brand {
  padding: 30px 24px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand h1 {
  font-size: 27px;
  letter-spacing: -1.2px;
  margin: 0;
  font-weight: 750;
  color: #6335ae;
  background: linear-gradient(115deg, #48227e 5%, #764bc0 52%, #eee7fa 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: 0.35px #6335ae;
}
.brand h1 span {
  font-weight: 600;
}
html[data-mode="dark"] .brand h1 {
  background-image: linear-gradient(115deg, #ffffff 5%, #dcccf7 52%, #a57ce1 100%);
  -webkit-text-stroke-color: #c9aff0;
}
.brand p {
  font-size: 13px;
  margin: 5px 0 0;
}
.icon-button {
  border: 0;
  background: transparent;
  width: 46px;
  font-size: 27px;
  padding: 4px;
  flex-shrink: 0;
}
.list-tools {
  padding: 0 20px 16px;
}
.search-field input {
  margin: 0;
}
.tabs {
  display: flex;
  gap: 7px;
  margin-top: 14px;
}
.tabs button {
  border: 0;
  border-radius: 22px;
  font-size: 13px;
  padding: 8px 17px;
  color: var(--muted);
}
.tabs .active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}
.chat-list {
  overflow-y: auto;
  flex: 1;
}
.chat-row {
  width: 100%;
  border: 0;
  border-radius: 0;
  display: flex;
  gap: 13px;
  text-align: left;
  padding: 16px 22px;
  position: relative;
  background: transparent;
}
.chat-row:after {
  content: "";
  height: 1px;
  background: var(--line);
  position: absolute;
  bottom: 0;
  left: 81px;
  right: 22px;
}
.chat-row.selected {
  background: var(--accent-soft);
}
.avatar {
  width: 46px;
  height: 46px;
  border-radius: 17px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 650;
  flex-shrink: 0;
}
.chat-info {
  min-width: 0;
  flex: 1;
}
.chat-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.chat-name {
  font-size: 15px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-time {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chat-preview {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 7px;
  line-height: 1.4;
}
.archive-status {
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  align-items: center;
}
.status-dot {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
}
.viewer {
  min-width: 0;
  min-height: 0;
  background: var(--conversation);
}
.welcome {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 35px;
}
.archive-mark {
  font-size: 72px;
  font-weight: 200;
  color: var(--accent);
  margin-bottom: 22px;
}
.welcome h2 {
  font-size: 27px;
  letter-spacing: -0.7px;
  margin: 0;
}
.welcome p {
  max-width: 380px;
  margin: 14px 0 25px;
}
.welcome small {
  color: var(--muted);
  margin-top: 18px;
  font-size: 12px;
}
.primary {
  background: var(--accent);
  color: var(--surface);
  border-color: transparent;
  font-weight: 650;
}
.primary:hover {
  background: var(--accent);
  filter: brightness(0.9);
}
html[data-mode="dark"] .primary {
  color: #181416;
}
#chat-view {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 17px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.chat-heading {
  flex: 1;
  min-width: 0;
}
.chat-heading h2 {
  font-size: 17px;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-heading p {
  font-size: 12px;
  margin: 4px 0 0;
}
.mobile-back {
  display: none;
}
.timeline-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.timeline-tools button {
  font-size: 12px;
  background: transparent;
  border: 0;
  color: var(--accent);
  padding: 4px 8px;
}
.timeline-tools span {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.message-scroll {
  overflow-y: auto;
  flex: 1;
  padding: 24px clamp(18px, 4vw, 64px);
  overscroll-behavior: contain;
  scroll-behavior: auto;
}
.message {
  width: fit-content;
  max-width: min(78%, 650px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px 16px 16px 16px;
  padding: 10px 13px;
  margin: 6px 0;
}
.message.own {
  margin-left: auto;
  background: var(--own);
  border-color: transparent;
  border-radius: 16px 4px 16px 16px;
}
.message-author {
  font-size: 12px;
  font-weight: 650;
  color: var(--accent);
  margin-bottom: 5px;
}
.message-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
  font-size: 16px;
}
.message-time {
  text-align: right;
  margin-top: 5px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.message.system {
  margin: 15px auto;
  background: transparent;
  border: 0;
  max-width: 90%;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.message.system .message-text {
  font-size: 12px;
}
.message.target {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.day-label {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: 24px 0 18px;
  font-weight: 600;
}
.load-button {
  display: block;
  margin: 0 auto 20px;
  font-size: 12px;
  color: var(--accent);
  background: var(--surface);
}
.panel {
  padding: 25px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  width: min(520px, calc(100% - 24px));
  max-height: 88dvh;
  box-shadow: 0 15px 70px #0003;
}
.panel::backdrop {
  background: #17101e70;
}
.panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 18px;
}
.panel h2 {
  font-size: 21px;
  letter-spacing: -0.4px;
  margin: 0;
}
.panel h3 {
  font-size: 15px;
  margin: 0 0 13px;
}
.panel form {
  display: grid;
  gap: 16px;
}
.panel section + section {
  border-top: 1px solid var(--line);
  padding-top: 22px;
  margin-top: 22px;
}
.panel p {
  font-size: 13px;
}
.check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 400;
}
.check input {
  width: 20px;
  min-height: 20px;
  margin: 0;
  accent-color: var(--accent);
}
.date-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.results {
  margin-top: 15px;
}
.result {
  width: 100%;
  text-align: left;
  display: block;
  margin-bottom: 8px;
  padding: 13px;
}
.result strong {
  display: block;
  font-size: 12px;
  color: var(--accent);
}
.result p {
  margin: 7px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.palettes {
  display: flex;
  gap: 7px;
  margin-bottom: 18px;
}
.palettes button {
  font-size: 12px;
  padding: 8px 10px;
  flex: 1;
  border-bottom: 4px solid var(--swatch);
}
.palettes [data-palette="rose"] {
  --swatch: #9f234d;
}
.palettes [data-palette="green"] {
  --swatch: #23864b;
}
.palettes [data-palette="purple"] {
  --swatch: #6f46c7;
}
.palettes [data-palette="blue"] {
  --swatch: #147da9;
}
.palettes .active {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.brand-actions {
  display: flex;
  gap: 5px;
  align-items: center;
}
.appearance-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 17px;
}
.palette-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}
.appearance-panel {
  max-width: 330px;
}
.appearance-panel .palettes {
  display: grid;
  gap: 9px;
}
.appearance-panel .palettes button {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  border-radius: 14px;
}
.appearance-panel .palettes button::before {
  content: "";
  background: var(--swatch);
  width: 22px;
  height: 22px;
  border-radius: 50%;
}
.appearance-panel .palettes button.active::after {
  content: "✓";
  margin-left: auto;
  color: var(--accent);
  font-weight: 700;
}
.mode-options {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.mode-options button {
  flex: 1;
  border: 0;
  padding: 12px 5px;
  font-size: 12px;
}
.mode-options button.active {
  background: var(--accent);
  color: var(--surface);
}
.aliases {
  max-height: 180px;
  overflow: auto;
  display: grid;
  gap: 10px;
}
.file-label {
  display: block;
  padding: 14px;
  background: var(--accent-soft);
  border-radius: 10px;
  color: var(--accent);
}
.file-label input {
  font-size: 13px;
  background: var(--surface);
}
progress {
  width: 100%;
  margin-top: 15px;
  accent-color: var(--accent);
}
.toast {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  padding: 15px 22px;
  max-width: 90%;
  background: var(--ink);
  color: var(--surface);
  border-radius: 12px;
  z-index: 5;
  font-size: 14px;
}
.empty {
  padding: 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}
.match-tools {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent-soft);
  padding: 5px;
}
.match-tools button {
  border: 0;
  background: transparent;
  font-size: 13px;
}
.match-tools span {
  font-size: 12px;
  color: var(--muted);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
@media (max-width: 899px) {
  .app {
    display: block;
    border: 0;
  }
  .sidebar {
    height: 100%;
  }
  .viewer {
    display: none;
    height: 100%;
  }
  .app.in-chat .sidebar {
    display: none;
  }
  .app.in-chat .viewer {
    display: block;
  }
  .mobile-back {
    display: block;
  }
  .brand {
    padding-top: 22px;
  }
  .chat-header {
    padding: 12px 10px;
    gap: 8px;
  }
  .chat-header .avatar {
    width: 39px;
    height: 39px;
    border-radius: 14px;
  }
  .chat-heading h2 {
    font-size: 15px;
  }
  .timeline-tools {
    padding: 3px 10px;
  }
  .message-scroll {
    padding: 16px;
  }
  .message {
    max-width: 88%;
  }
  .panel {
    padding: 20px;
    border-radius: 18px;
  }
  .welcome {
    display: none;
  }
  .chat-header .icon-button {
    width: 40px;
  }
  .date-fields {
    gap: 8px;
  }
}
@media (prefers-reduced-motion: no-preference) {
  dialog[open] {
    animation: appear 0.14s ease-out;
  }
  @keyframes appear {
    from {
      opacity: 0;
      transform: translateY(8px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}
.calendar-picker {
  margin-bottom: 8px;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin-top: 18px;
}
.calendar-weekday {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 7px 0;
}
.calendar-day {
  padding: 4px;
  min-width: 0;
  background: var(--accent-soft);
  border: 0;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}
.calendar-day:disabled {
  background: transparent;
  color: var(--muted);
  opacity: 0.4;
  font-weight: 400;
}
.calendar-hint {
  margin: 10px 0 0;
  font-size: 12px !important;
}
