* {
  box-sizing: border-box;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial,
    sans-serif;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

body,
body * {
  font-weight: 400 !important;
}

:root {
  /* Theme tokens (light = day) */
  --bg: #ffffff;
  --panel: #ffffff;
  --panelAlt: #f0f0f0;
  --text: #0f172a;
  --muted: rgba(15, 23, 42, 0.55);
  --line: #d7dbe3;
  --side: #e9e9e9;
  --accent: #26bbab;
  --danger: #b91c1c;
  --warn: #b45309;
  --chipBg: #ffffff;
  --itemBg: #ffffff;
  --itemBgBlocked: #fff5f5;
  --msgMeBg: #ede9fe;
  --msgYouBg: #f1f5f9;
  --daysepBg: #ffffff;
  --daysepText: rgba(15, 23, 42, 0.55);
  --bookbarBg: rgba(38, 187, 171, 0.1);
  --bookbarText: rgba(15, 23, 42, 0.75);
  --inputBg: #ffffff;
  --inputBorder: rgba(15, 23, 42, 0.2);
  --link: rgba(15, 23, 42, 0.45);
  --linkHover: rgba(15, 23, 42, 0.65);

  --chipH: 28px;
  --barH: 3.25rem;
  --barPad: 0.5rem;
  --rowH: calc(var(--barH) + (2 * var(--barPad)));
}

/* Dark theme (night) */
body.theme-dark {
  --bg: #111418;
  --panel: #171b20;
  --panelAlt: #101317;
  --text: #e6edf3;
  --muted: rgba(230, 237, 243, 0.55);
  --line: rgba(230, 237, 243, 0.14);
  --side: #14181d;
  --chipBg: #14181d;
  --itemBg: #171b20;
  --itemBgBlocked: rgba(185, 28, 28, 0.12);
  --msgMeBg: rgba(38, 187, 171, 0.18);
  --msgYouBg: rgba(255, 255, 255, 0.06);
  --daysepBg: rgba(255, 255, 255, 0.04);
  --daysepText: rgba(230, 237, 243, 0.55);
  --bookbarBg: rgba(38, 187, 171, 0.12);
  --bookbarText: rgba(230, 237, 243, 0.75);
  --inputBg: #0f1215;
  --inputBorder: rgba(230, 237, 243, 0.18);
  --link: rgba(230, 237, 243, 0.45);
  --linkHover: rgba(230, 237, 243, 0.7);
  --warn: #fbbf24;
}

/* Dark scrollbars */
body.theme-dark,
body.theme-dark * {
  scrollbar-color: rgba(230, 237, 243, 0.35) rgba(255, 255, 255, 0.06);
  scrollbar-width: thin;
}

body.theme-dark::-webkit-scrollbar,
body.theme-dark *::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

body.theme-dark::-webkit-scrollbar-track,
body.theme-dark *::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
}

body.theme-dark::-webkit-scrollbar-thumb,
body.theme-dark *::-webkit-scrollbar-thumb {
  background: rgba(230, 237, 243, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.06);
}

body.theme-dark::-webkit-scrollbar-thumb:hover,
body.theme-dark *::-webkit-scrollbar-thumb:hover {
  background: rgba(230, 237, 243, 0.5);
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 22.5rem 1fr;
  grid-template-rows: var(--rowH) 1fr var(--rowH);
  height: 100vh;
}

@media (max-width: 61.25rem) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: var(--rowH) 17.5rem 1fr var(--rowH);
  }
}

/* Header (left) */
.top-left {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

@media (max-width: 61.25rem) {
  .top-left {
    grid-column: 1;
    border-right: none;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand img {
  width: 56px;
  height: auto;
  display: block;
}

.name {
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spacer {
  flex: 1;
}

.top-left-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0;
}

.chip {
  border: 1px solid var(--line);
  background: var(--chipBg);
  color: var(--text);
  font-size: 12px;
  line-height: 1;
  height: var(--chipH);
  padding: 0 10px;
  border-radius: 0;
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chip.online {
  border-color: rgba(38, 187, 171, 0.55);
  color: #0f766e;
}

.chip.offline {
  border-color: rgba(185, 28, 28, 0.35);
  color: #b91c1c;
}

.chip.logout {
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
}

.chip-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M6%209l6%206%206-6%27%20fill%3D%27none%27%20stroke%3D%27%239CA3AF%27%20stroke-width%3D%272.25%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%2F%3E%3C%2Fsvg%3E");
  background-position: calc(100% - 12px) 50%;
  background-size: 14px 14px;
  background-repeat: no-repeat;
}

.chip.icon {
  width: var(--chipH);
  padding: 0;
}

.btn.tab.icon {
  width: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M4%204h16v4H4zM4%2010h10v4H4zM4%2016h16v4H4z%27%20fill%3D%27%239CA3AF%27%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 16px 16px;
}
.btn.tab.crm-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border-color: rgba(239, 132, 63, 0.9);
  color: #ef843f;
  box-shadow: 0 0 0 1px rgba(239, 132, 63, 0.25) inset;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M12%203l7%204v5c0%205-3.5%209-7%209s-7-4-7-9V7l7-4z%27%20fill%3D%27none%27%20stroke%3D%27%23ef843f%27%20stroke-width%3D%272%27%20stroke-linejoin%3D%27round%27/%3E%3Cpath%20d%3D%27M9%2012h6%27%20stroke%3D%27%23ef843f%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 8px 50%;
  background-size: 16px 16px;
  padding-left: 30px;
}

body.view-crm .top-actions,
body.view-crm .side,
body.view-crm .main,
body.view-crm .composer {
  display: none !important;
}

body.crm-page {
  background: var(--bg);
}
.crm-page {
  --crm-nav-width: 280px;
}
.crm-standalone {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
body.crm-page .crm-wrap {
  display: block;
  border-top: 1px solid var(--line);
}
body.crm-page .crm-body {
  min-height: 0;
  flex: 1;
}
body.crm-page .crm-top,
body.crm-page .crm-foot {
  border-bottom: 1px solid var(--line);
}

.crm-wrap {
  grid-column: 1 / -1;
  grid-row: 2 / 4;
  display: none;
  background: var(--panel);
  border-top: 1px solid var(--line);
}

body.view-crm .crm-wrap {
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.crm-top,
.crm-foot {
  padding: 1rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--panel);
}
.crm-foot {
  border-top: 1px solid var(--line);
  border-bottom: none;
}
.crm-title {
  font-size: 18px;
  font-weight: 700 !important;
}
.crm-subtitle {
  font-size: 12px;
}
.crm-body {
  display: grid;
  grid-template-columns: var(--crm-nav-width) 6px 1fr;
  min-height: 0;
}
.crm-nav {
  border-right: 1px solid var(--line);
  background: var(--panelAlt);
  padding: 1rem 0.75rem;
  overflow: auto;
}
.crm-nav-resizer {
  cursor: col-resize;
  background: var(--line);
  width: 6px;
}
.crm-nav-group {
  margin-bottom: 0.85rem;
}
.crm-nav-group.collapsed .crm-nav-item,
.crm-nav-group.collapsed .crm-nav-tree {
  display: none;
}
.crm-nav-title {
  cursor: pointer;
  user-select: none;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.crm-nav-title::after {
  content: '▾';
  float: right;
  font-size: 10px;
  opacity: 0.7;
}
.crm-nav-group.collapsed .crm-nav-title::after {
  content: '▸';
}
.crm-nav-tree {
  margin: 0.25rem 0 0.35rem;
  padding: 0.25rem 0 0.25rem 0.6rem;
  border-left: 1px dashed var(--line);
}
.crm-nav-tree .crm-nav-item {
  margin-left: 0.25rem;
  background: rgba(255,255,255,0.02);
}
.crm-nav-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0.25rem 0.5rem 0.4rem;
}
.crm-nav-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--chipBg);
  color: var(--text);
  padding: 0.45rem 0.65rem;
  margin: 0.2rem 0;
  font-size: 12px;
  cursor: pointer;
}
.crm-nav-item.active {
  border-color: rgba(38, 187, 171, 0.75);
  background: rgba(38, 187, 171, 0.12);
}
.crm-main {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}
.crm-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.crm-breadcrumb {
  font-size: 13px;
  font-weight: 700 !important;
}
.crm-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.crm-content {
  padding: 1rem;
  overflow: auto;
}
.crm-embed {
  width: 100%;
  height: calc(100vh - 240px);
  min-height: 560px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.crm-embed iframe {
  width: 100%;
  height: 100%;
  border: 0;
}
.crm-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}
.crm-card {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 1rem;
}
.crm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.crm-table th,
.crm-table td {
  border: 1px solid var(--line);
  padding: 0.5rem;
  text-align: left;
  vertical-align: top;
}
.crm-table th {
  background: var(--panelAlt);
}
.file-manager {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 0.75rem;
}
.file-manager-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.file-manager-breadcrumb {
  font-size: 12px;
  color: var(--muted);
}
.file-manager-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.file-list {
  border: 1px solid var(--line);
  background: var(--panelAlt);
  border-radius: 6px;
  padding: 0.5rem;
  display: grid;
  gap: 0.25rem;
  max-height: 420px;
  overflow: auto;
}
.file-row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
}
.file-row:hover {
  background: rgba(255,255,255,0.04);
}
.file-row .file-name {
  font-size: 12px;
}
.file-row .file-meta {
  font-size: 11px;
  color: var(--muted);
}
.file-icon {
  width: 14px;
  height: 14px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--chipBg);
}
.file-icon.dir {
  border-color: rgba(38, 187, 171, 0.6);
  background: rgba(38, 187, 171, 0.12);
}
.file-editor {
  display: grid;
  gap: 0.75rem;
}
.file-editor textarea {
  min-height: 360px;
}
.code-editor {
  position: relative;
  min-height: 360px;
  border: 1px solid var(--line);
  background: #0f1113;
  border-radius: 6px;
  overflow: hidden;
}
.code-highlight {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0.75rem;
  overflow: auto;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.4;
  color: #d9e4e8;
  pointer-events: none;
}
.code-input {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 360px;
  border: none;
  outline: none;
  background: transparent;
  color: transparent;
  caret-color: #d9e4e8;
  padding: 0.75rem;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.4;
}
.code-view {
  border: 1px solid var(--line);
  background: #0f1113;
  color: #d9e4e8;
  padding: 0.75rem;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.4;
}
.code-view .tok-hbs,
.code-highlight .tok-hbs {
  color: #7dd3fc;
}
.code-view .tok-tag,
.code-highlight .tok-tag {
  color: #fca5a5;
}
.code-view .tok-comment,
.code-highlight .tok-comment {
  color: #9ca3af;
  font-style: italic;
}
.crm-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.crm-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 11px;
  color: var(--muted);
}
.crm-form input,
.crm-form select,
.crm-form textarea {
  border: 1px solid var(--line);
  background: var(--inputBg);
  color: var(--text);
  padding: 0.4rem 0.5rem;
  font-size: 12px;
}
.crm-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.crm-badge {
  display: inline-flex;
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--line);
  font-size: 11px;
}
.crm-chat {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 0.75rem;
  height: 320px;
  overflow: auto;
}
.crm-chat-entry {
  margin-bottom: 0.5rem;
}
.crm-foot-actions {
  display: flex;
  gap: 0.5rem;
}

.chip.icon::before {
  content: "";
  width: 14px;
  height: 14px;
  display: block;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M21%2012.8A8.5%208.5%200%200%201%2011.2%203a7%207%200%201%200%209.8%209.8z%27%2F%3E%3C%2Fsvg%3E")
    no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M21%2012.8A8.5%208.5%200%200%201%2011.2%203a7%207%200%201%200%209.8%209.8z%27%2F%3E%3C%2Fsvg%3E")
    no-repeat center / contain;
}

.chip.icon.markfilter::before {
  -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M7%202h2v2h6V2h2v2h3v18H4V4h3V2zm13%206H6v12h14V8z%27%2F%3E%3C%2Fsvg%3E")
    no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M7%202h2v2h6V2h2v2h3v18H4V4h3V2zm13%206H6v12h14V8z%27%2F%3E%3C%2Fsvg%3E")
    no-repeat center / contain;
}

/* Keep the "marked-only" icon stable in dark theme (don't inherit theme-toggle icon mask). */
body.theme-dark .chip.icon.markfilter::before {
  -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M7%202h2v2h6V2h2v2h3v18H4V4h3V2zm13%206H6v12h14V8z%27%2F%3E%3C%2Fsvg%3E")
    no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M7%202h2v2h6V2h2v2h3v18H4V4h3V2zm13%206H6v12h14V8z%27%2F%3E%3C%2Fsvg%3E")
    no-repeat center / contain;
}

.chip.icon.markfilter.active {
  border-color: rgba(245, 158, 11, 0.55);
  color: var(--warn);
}

body.theme-dark .chip.icon::before {
  -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M12%2018a6%206%200%201%200%200-12%206%206%200%200%200%200%2012zm0-16h1v3h-1V2zm0%2017h1v3h-1v-3zM2%2011h3v1H2v-1zm17%200h3v1h-3v-1zM4.2%204.2l2.1%202.1-.7.7-2.1-2.1.7-.7zm14.4%2014.4l2.1%202.1-.7.7-2.1-2.1.7-.7zM19.8%204.2l.7.7-2.1%202.1-.7-.7%202.1-2.1zM5.6%2018.4l.7.7-2.1%202.1-.7-.7%202.1-2.1z%27%2F%3E%3C%2Fsvg%3E")
    no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M12%2018a6%206%200%201%200%200-12%206%206%200%200%200%200%2012zm0-16h1v3h-1V2zm0%2017h1v3h-1v-3zM2%2011h3v1H2v-1zm17%200h3v1h-3v-1zM4.2%204.2l2.1%202.1-.7.7-2.1-2.1.7-.7zm14.4%2014.4l2.1%202.1-.7.7-2.1-2.1.7-.7zM19.8%204.2l.7.7-2.1%202.1-.7-.7%202.1-2.1zM5.6%2018.4l.7.7-2.1%202.1-.7-.7%202.1-2.1z%27%2F%3E%3C%2Fsvg%3E")
    no-repeat center / contain;
}

/* Header (actions) */
.top-actions {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

@media (max-width: 61.25rem) {
  .top-actions {
    grid-column: 1;
    grid-row: 2;
  }
}

.actions-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--line);
  background: var(--chipBg);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  border-radius: 0;
}

.btn.primary {
  border-color: rgba(38, 187, 171, 0.55);
  color: #0f766e;
}

.btn.danger {
  border-color: rgba(185, 28, 28, 0.45);
  color: #b91c1c;
}

.btn.orange {
  border-color: rgba(245, 158, 11, 0.55);
  color: var(--warn);
}

.btn.tab.active {
  outline: 2px solid rgba(38, 187, 171, 0.3);
  outline-offset: -2px;
}

.btn.tab.blink {
  animation: chatpulse 1s ease-in-out infinite;
}

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

select {
  border: 1px solid var(--line);
  background: var(--chipBg);
  color: var(--text);
  padding: 0.75rem;
  border-radius: 0;
}

/* Keep selects in the top actions bar aligned with buttons */
.top-actions select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  line-height: 1;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M6%209l6%206%206-6%27%20fill%3D%27none%27%20stroke%3D%27%239CA3AF%27%20stroke-width%3D%272.25%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%2F%3E%3C%2Fsvg%3E");
  background-position: calc(100% - 12px) 50%;
  background-size: 14px 14px;
  background-repeat: no-repeat;
}

select[disabled] {
  opacity: 1;
  cursor: default;
}

.chip-select-static {
  background-image: none !important;
  padding-right: 10px !important;
}

/* Sidebar */
.side {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--side);
  padding: 0;
  gap: 0;
}

@media (max-width: 61.25rem) {
  .side {
    grid-column: 1;
    grid-row: 2;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
}

.side-footer {
  grid-column: 1;
  grid-row: 3;
  height: var(--rowH);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border-right: 1px solid var(--line);
  border-top: 1px solid var(--line);
  background: var(--side);
  padding: 1rem;
}

@media (max-width: 61.25rem) {
  .side-footer {
    grid-column: 1;
    grid-row: 4;
    border-right: none;
    border-top: 1px solid var(--line);
  }
}

.view-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: auto;
  min-height: 0;
  flex: 1;
  padding: 0.75rem;
}

.item {
  border: 1px solid var(--line);
  background: var(--itemBg);
  padding: 0.75rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  position: relative;
}

.item.with-go {
  padding-right: 3.25rem; /* space for the arrow activator */
}

.item .go {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  background: rgba(38, 187, 171, 0.22);
  user-select: none;
}

.item .go::before {
  content: "";
  width: 16px;
  height: 16px;
  display: block;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M9%206l6%206-6%206%27%20fill%3D%27none%27%20stroke%3D%27%23000%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%2F%3E%3C%2Fsvg%3E")
    no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M9%206l6%206-6%206%27%20fill%3D%27none%27%20stroke%3D%27%23000%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%2F%3E%3C%2Fsvg%3E")
    no-repeat center / contain;
}

.item:hover .go {
  background: rgba(38, 187, 171, 0.28);
}

.item.locked .go {
  background: rgba(185, 28, 28, 0.18);
}

.item.marked .go {
  background: rgba(245, 158, 11, 0.16);
}

.item.unread .go,
.item.remind .go {
  background: rgba(38, 187, 171, 0.32);
}

.item.active {
  outline: 2px solid rgba(38, 187, 171, 0.3);
  outline-offset: -2px;
}

.item.unread {
  outline: 2px solid rgba(38, 187, 171, 0.55);
  outline-offset: -2px;
  background: rgba(38, 187, 171, 0.18);
  animation: chatpulse 1s ease-in-out infinite;
}

.item.unread.active,
.item.unread.blocked {
  animation: none;
}

.item.remind {
  outline: 2px solid rgba(38, 187, 171, 0.85);
  outline-offset: -2px;
  background: rgba(38, 187, 171, 0.22);
  animation: chatpulse 1s ease-in-out infinite;
}

.item.marked {
  outline: 2px solid rgba(245, 158, 11, 0.55);
  outline-offset: -2px;
  background: rgba(245, 158, 11, 0.12);
  animation: none;
}

.item.marked.active {
  animation: none;
}

.item.locked {
  outline: 2px solid rgba(185, 28, 28, 0.55);
  outline-offset: -2px;
  background: rgba(185, 28, 28, 0.12);
  animation: none;
}

.item.locked.active,
.item.locked.unread,
.item.locked.remind {
  animation: none;
}

.item.blocked {
  border-color: rgba(185, 28, 28, 0.35);
  background: var(--itemBgBlocked);
}

.item .t {
  font-size: 13px;
}

.item .m {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main column */
.main {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  overflow: hidden;
  position: relative;
}

/* Views without composer: main occupies the bottom row too */
body.view-mail .main,
body.view-bookings .main,
body.view-archive .main {
  grid-row: 2 / span 2;
}

@media (max-width: 61.25rem) {
  .main {
    grid-column: 1;
    grid-row: 3;
  }
}

@media (max-width: 61.25rem) {
  body.view-mail .main,
  body.view-bookings .main,
  body.view-archive .main {
    grid-row: 3;
  }
}

.bookbar {
  border-bottom: 1px solid var(--line);
  background: var(--bookbarBg);
  padding: 0.75rem 1.5rem;
  white-space: pre-wrap;
}

.bookbar-title {
  font-size: 1rem;
}

.bookbar-info {
  color: var(--bookbarText);
  font-size: 13px;
}

.msgs {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 1.5rem;
}

.msgs-inner {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 1rem;
}

body.view-mail .msgs-inner {
  justify-content: flex-start;
}

/* Completely hide composer in mail/bookings/archive, without affecting left bottom tabs */
body.view-mail .composer,
body.view-bookings .composer,
body.view-archive .composer {
  display: none;
}

.mail-head {
  align-self: stretch;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 1rem;
}

.mail-subject {
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}

.mail-body {
  align-self: stretch;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 1rem;
}

.mail-pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 0.875rem/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  color: var(--text);
}

.daysep {
  align-self: center;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  background: var(--daysepBg);
  color: var(--daysepText);
  font-size: 0.75rem;
}

.msgwrap {
  display: flex;
}

.msgwrap.me {
  justify-content: flex-end;
}

.msgwrap.you {
  justify-content: flex-start;
}

.bubble {
  max-width: min(35rem, 78%);
  padding: 0.75rem 1rem;
  border-radius: 0;
  display: inline-block;
}

.bubble.me {
  background: var(--msgMeBg);
  color: var(--text);
  margin-left: auto;
}

.bubble.you {
  background: var(--msgYouBg);
  color: var(--text);
  margin-right: auto;
}

.bubble.booking {
  background: rgba(38, 187, 171, 0.1);
  border: 1px solid rgba(38, 187, 171, 0.55);
}

.btext {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.bmeta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.replyquote {
  border-left: 3px solid var(--line);
  padding-left: 10px;
  margin: 6px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bwho {
  font-weight: 400;
}

.btime {
  white-space: nowrap;
}

.bookingTitle {
  font-size: 1rem;
}

.bookingInfo {
  white-space: pre-wrap;
  color: var(--bookbarText);
  font-size: 13px;
}

.replylink {
  display: inline-block;
  margin-top: 6px;
  color: var(--link);
  text-decoration: underline;
  font-size: 12px;
}

.replylink:hover {
  color: var(--linkHover);
}

#typingline {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(1rem + 86px);
  padding: 0;
  margin: 0;
  min-height: 0;
  font-size: 14px;
  pointer-events: none;
  background: transparent;
  border: 0;
}

/* Composer */
.composer {
  grid-column: 2;
  grid-row: 3;
  border-top: 1px solid var(--line);
  background: var(--panelAlt);
  padding: var(--barPad);
}

@media (max-width: 61.25rem) {
  .composer {
    grid-column: 1;
    grid-row: 4;
  }
}

.composer-inner {
  max-width: 61.25rem;
  margin: 0 auto;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.composer-input {
  flex: 1;
  height: var(--barH);
  border-radius: 9999px;
  border: 1px solid var(--inputBorder);
  background: var(--inputBg);
  padding: 0 1rem;
  font: 0.875rem/1.4 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
}

.composer-input::placeholder {
  color: rgba(15, 23, 42, 0.55);
}

body.theme-dark .composer-input {
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
}

body.theme-dark .composer-input::placeholder {
  color: rgba(230, 237, 243, 0.55);
}

/* Chrome autofill */
body.theme-dark .composer-input:-webkit-autofill,
body.theme-dark .composer-input:-webkit-autofill:hover,
body.theme-dark .composer-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text) !important;
  box-shadow: 0 0 0 1000px var(--inputBg) inset;
  transition: background-color 999999s ease-in-out 0s;
}

.composer-input:focus {
  outline: 2px solid rgba(38, 187, 171, 0.35);
  outline-offset: 0;
}

.sendbtn {
  width: var(--barH);
  height: var(--barH);
  border-radius: 9999px;
  border: 1px solid rgba(38, 187, 171, 0.55);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.sendbtn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.sendbtn-icon {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M2%2021l21-9L2%203v7l15%202-15%202v7z%27%2F%3E%3C%2Fsvg%3E")
    no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M2%2021l21-9L2%203v7l15%202-15%202v7z%27%2F%3E%3C%2Fsvg%3E")
    no-repeat center / contain;
}

@keyframes chatpulse {
  0%,
  100% {
    background: rgba(38, 187, 171, 0.12);
    outline-color: rgba(38, 187, 171, 0.3);
  }
  50% {
    background: rgba(38, 187, 171, 0.38);
    outline-color: rgba(38, 187, 171, 0.85);
  }
}

/* Reply box */
.replybox {
  border: 1px solid rgba(15, 23, 42, 0.18);
  background: #fff;
  padding: 0.75rem;
  margin: 0 auto 0.75rem auto;
  max-width: 61.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.replybox-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.replybox-preview {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}

.modal-dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(35rem, 92vw);
  background: #fff;
  border: 1px solid var(--line);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

body.theme-dark .modal-backdrop {
  background: rgba(0, 0, 0, 0.65);
}

body.theme-dark .modal-dialog {
  background: var(--panel);
  color: var(--text);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.modal-head-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#bookDrag {
  cursor: grab;
  user-select: none;
}

#bookDrag.dragging {
  cursor: grabbing;
}

.modal-title {
  font-weight: 600;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.modal-field-wide {
  grid-column: 1 / -1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.modal-dialog input,
.modal-dialog select {
  border: 1px solid var(--line);
  padding: 0.75rem;
}

body.theme-dark .modal-dialog input,
body.theme-dark .modal-dialog select {
  background: var(--inputBg);
  color: var(--text);
}

body.theme-dark .modal-dialog input::placeholder,
body.theme-dark .modal-textarea::placeholder {
  color: rgba(230, 237, 243, 0.55);
}

.modal-textarea {
  border: 1px solid var(--line);
  padding: 0.75rem;
  min-height: 5.5rem;
  resize: vertical;
  font: 0.875rem/1.4 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
}

body.theme-dark .modal-textarea {
  background: var(--inputBg);
  color: var(--text);
}
