/* Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 16px; color: #1a1a1a; background: #ffffff; }
a { color: inherit; }

/* Layout */
.kb-layout { display: flex; height: 100dvh; overflow: hidden; }

/* Sidebar */
.kb-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #f1f0ee;
  border-right: 1px solid #e5e4e0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 13px;
}
.kb-sidebar__scroll { flex: 1; overflow-y: auto; }
.kb-sidebar__alert {
  display: flex; align-items: center; gap: 7px;
  margin: 0 10px 8px; padding: 8px 10px;
  font-size: 12px; font-weight: 600; text-decoration: none;
  color: #c92a2a; background: #fff5f5;
  border: 1px solid #ffc9c9; border-radius: 6px;
  transition: background 0.1s, border-color 0.1s;
}
.kb-sidebar__alert:hover { background: #ffe3e3; border-color: #ffa8a8; }
.kb-sidebar__alert svg { flex-shrink: 0; }
.kb-sidebar__footer {
  padding: 10px 12px;
  border-top: 1px solid #e5e4e0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.kb-sidebar__user-email {
  color: #9b9a97;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.kb-sidebar__signout-btn {
  background: none; border: none; cursor: pointer; padding: 4px 6px;
  color: #9b9a97; border-radius: 4px; display: flex; align-items: center; flex-shrink: 0;
}
.kb-sidebar__signout-btn:hover { background: #e8e7e3; color: #37352f; }
.kb-sidebar__user {
  display: flex; align-items: center; gap: 8px;
  min-width: 0; flex: 1; text-decoration: none;
  padding: 4px 6px; border-radius: 4px;
}
.kb-sidebar__user:hover { background: #e8e7e3; }
.kb-sidebar__user--active { background: #e8e7e3; }
.kb-sidebar__avatar {
  flex-shrink: 0; font-size: 18px; line-height: 1;
  width: 22px; text-align: center;
}
.kb-sidebar__header {
  padding: 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e5e4e0;
}
.kb-sidebar__logo { font-weight: 700; letter-spacing: -.3px; text-decoration: none; }
.kb-sidebar__header-actions { display: flex; align-items: center; gap: 4px; }
.kb-sidebar__icon-btn {
  background: none; border: none; cursor: pointer; padding: 4px 6px;
  color: #9b9a97; border-radius: 4px; display: flex; align-items: center;
}
.kb-sidebar__icon-btn:hover { background: #e8e7e3; color: #37352f; }
.kb-sidebar__section + .kb-sidebar__section { border-top: 1px solid #e5e4e0; padding-top: 4px; }
.kb-sidebar__section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px 2px;
}
.kb-sidebar__section-title { font-weight: 600; color: #9b9a97; letter-spacing: .5px; text-transform: uppercase; }
.kb-sidebar__section-title--link { text-decoration: none; }
.kb-sidebar__section-title--link:hover { color: #37352f; }
.kb-sidebar__section-actions { display: flex; align-items: center; gap: 4px; }
.kb-sidebar__new-folder-form {
  padding: 8px 12px;
  border-bottom: 1px solid #e5e4e0;
}
.kb-sidebar__new-folder-form form { display: flex; gap: 4px; align-items: center; }
.kb-sidebar__folder-input {
  flex: 1; padding: 4px 8px;
  border: 1px solid #d8d7d4; border-radius: 4px; background: #fff;
}
.kb-sidebar__folder-input:focus { outline: none; border-color: #5e9af0; }
.kb-sidebar__nav { list-style: none; padding: 8px; }
.kb-sidebar__nav li { margin: 0; }
.kb-sidebar__item { list-style: none; }
.kb-sidebar__item--dragging { opacity: 0.4; }

/* Presence status switcher: 4 colored icons for quick switching */
.kb-status {
  display: flex; align-items: center; justify-content: space-around; gap: 4px;
  padding: 4px 0;
  background: #000;
}
.kb-status form { margin: 0; flex: 1; transform: scale(0.75); }
.kb-status__btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center;
  height: 34px; padding: 0;
  background: none; border: none; border-radius: 8px; cursor: pointer;
  color: #b3b1ac; transition: background 0.1s, color 0.1s;
}
.kb-status__btn:hover { background: #e8e7e3; color: #fff; background-color: var(--status-color); }
.kb-status__btn--active { background: #e3e2de; color: #fff; background-color: var(--status-color); }

/* Main-pages toolbar (Notion-style): active item shows icon + label, others icon-only */
.kb-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 10px 8px;
  border-bottom: 1px solid #e5e4e0;
}
.kb-toolbar__item {
  display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 9px;
  border-radius: 8px; text-decoration: none;
  color: #5f5e5b; transition: background 0.1s, color 0.1s;
}
.kb-toolbar__item:hover { background: #e8e7e3; color: #37352f; }
.kb-toolbar__icon { display: flex; align-items: center; flex-shrink: 0; }
.kb-toolbar__item--active { background: #e3e2de; color: #37352f; font-weight: 500; }
.kb-toolbar__label { white-space: nowrap; font-size: 13px; }

/* Folders */
.kb-sidebar__folder { list-style: none; margin-bottom: 2px; }
.kb-sidebar__folder + .kb-sidebar__folder { margin-top: 10px; }
.kb-sidebar__folder-header {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 8px 3px 0; border-radius: 4px;
}
.kb-sidebar__folder-header:hover .kb-sidebar__folder-delete { opacity: 1; }
.kb-sidebar__folder-handle {
  cursor: grab; color: #c2c0bb;
  width: 16px; flex-shrink: 0; text-align: center;
  line-height: 1; user-select: none;
}
.kb-sidebar__folder-handle:active { cursor: grabbing; }
.kb-sidebar__folder-name {
  flex: 1; font-weight: 700; color: #37352f;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kb-sidebar__folder-delete {
  background: none; border: none; cursor: pointer; padding: 2px 3px;
  color: #9b9a97; border-radius: 3px; opacity: 0; transition: opacity 0.1s;
  display: flex; align-items: center;
}
.kb-sidebar__folder-delete:hover { color: #c0392b; background: #fdf0ee; }
.kb-sidebar__folder-name[contenteditable]:focus {
  outline: 2px solid #5e9af0; outline-offset: 2px; border-radius: 3px; cursor: text;
}
.kb-sidebar__folder-pages { list-style: none; padding: 0; margin: 0; }
.kb-sidebar__folder--over .kb-sidebar__folder-header {
  background: #dbeafe; outline: 2px solid #93c5fd; outline-offset: -2px;
}

.kb-sidebar__link {
  display: block;
  padding: 5px 20px;
  border-radius: 4px;
  text-decoration: none;
  color: #37352f;
  transition: background 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kb-sidebar__link:hover { background: #e8e7e3; }
.kb-sidebar__link--active { background: #e3e2de; font-weight: 500; }

/* Auth */
.kb-auth {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f7f6f3;
}
.kb-auth__card {
  background: #fff;
  border: 1px solid #e5e4e0;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.kb-auth__logo { font-size: 1.6rem; font-weight: 700; text-align: center; margin-bottom: 4px; }
.kb-auth__btn  { width: 100%; justify-content: center; }
.kb-auth__input {
  padding: 9px 12px; border: 1px solid #d8d7d4; border-radius: 6px;
  width: 100%; font-family: inherit;
}
.kb-auth__input:focus { outline: none; border-color: #5e9af0; }
.kb-auth__error { color: #c0392b; text-align: center; }
.kb-auth__divider {
  text-align: center; color: #9b9a97;
  display: flex; align-items: center; gap: 8px;
}
.kb-auth__divider::before,
.kb-auth__divider::after { content: ""; flex: 1; height: 1px; background: #e5e4e0; }

/* Main content */
.kb-main { flex: 1; overflow-y: auto; padding: 48px 64px; }
.kb-main--empty { display: flex; align-items: center; justify-content: center; }
.kb-empty { color: #9b9a97; }

/* Failed jobs */
.kb-failed-jobs { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.kb-failed-job {
  padding: 12px 14px; border: 1px solid #f1d4d4; border-radius: 8px; background: #fffafa;
}
.kb-failed-job__head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px;
}
.kb-failed-job__name { font-weight: 600; color: #37352f; }
.kb-failed-job__time { font-size: 12px; color: #9b9a97; white-space: nowrap; }
.kb-failed-job__error { font-size: 13px; color: #37352f; word-break: break-word; }
.kb-failed-job__exception { font-weight: 600; color: #c92a2a; }
.kb-failed-job__trace { margin-top: 8px; }
.kb-failed-job__trace summary { font-size: 12px; color: #9b9a97; cursor: pointer; }
.kb-failed-job__trace pre {
  margin: 6px 0 0; padding: 8px 10px; overflow-x: auto;
  font-size: 11px; color: #6b6a66; background: #f7f6f3; border-radius: 6px;
}
.kb-failed-job__actions { display: flex; gap: 8px; margin-top: 10px; }

/* Page */
.kb-page { max-width: 720px; margin: 0 auto; }
/* Page options menu (fixed top-right) */
.kb-page-menu {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 2px;
}
.kb-page-menu__lock-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  color: #9b9a97;
  padding: 5px 8px;
  border-radius: 6px;
  letter-spacing: .3px;
  transition: background 0.1s, color 0.1s;
}
.kb-page-menu__lock-btn:hover { background: #e8e7e3; color: #37352f; }
.kb-page-menu__lock-btn--active { color: tomato; }
.kb-page-menu__lock-btn--active:hover { background: tomato; color: white; }
.kb-page-menu__trigger {
  background: none;
  border: none;
  cursor: pointer;
  color: #9b9a97;
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 2px;
  line-height: 1;
  transition: background 0.1s, color 0.1s;
}
.kb-page-menu__trigger:hover { background: #e8e7e3; color: #37352f; }
.kb-page-menu__dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: #fff;
  border: 1px solid #e5e4e0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  padding: 4px;
  min-width: 160px;
}
.kb-page-menu__option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  padding: 8px 12px;
  border-radius: 6px;
  color: #37352f;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  transition: background 0.1s;
  text-decoration: none;
}
.kb-page-menu__option svg { flex-shrink: 0; opacity: .7; }
.kb-page-menu__option:hover { background: #f1f0ee; }
.kb-page-menu__option--danger { color: #c0392b; }
.kb-page-menu__option--danger:hover { background: #fdf0ee; }

.kb-page__header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 32px; gap: 16px; }
.kb-page__title {
  font-size: 3.2rem;
  font-weight: 700;
  letter-spacing: -.5px;
  color: #1a1a1a;
  cursor: text;
  line-height: 1.2;
  word-break: break-word;
  outline: none;
}
.kb-page__title:empty::before { content: "Untitled"; color: #c8c7c4; }
.kb-page__actions { display: flex; gap: 8px; flex-shrink: 0; padding-top: 10px; }

/* Buttons */
.kb-btn {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: 6px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  text-decoration: none;
  background: #2d2d2d;
  color: #fff;
  transition: background 0.15s;
  white-space: nowrap;
  font-size: 16px;
}
.kb-btn:hover { background: #111; }
.kb-btn--ghost { background: transparent; color: #37352f; border: 1px solid #d8d7d4; }
.kb-btn--ghost:hover { background: #f1f0ee; }
.kb-btn--sm { padding: 4px 10px; font-size: 11px; }
.kb-btn--danger { background: transparent; color: #c0392b; border: 1px solid #e8c0bc; }
.kb-btn--danger:hover { background: #fdf0ee; }

/* Empty page prompt */
.kb-empty-page { position: relative; margin-top: 8px; }
.kb-empty-page__btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #9b9a97;
  padding: 6px 2px;
  border-radius: 6px;
  transition: color 0.1s;
}
.kb-empty-page__btn:hover { color: #37352f; }
.kb-empty-page__picker {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #fff;
  border: 1px solid #e5e4e0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  padding: 4px;
  min-width: 160px;
  z-index: 100;
}

/* Blocks list */
.kb-blocks { display: flex; flex-direction: column; }

/* Individual block */
.kb-block {
  position: relative;
  display: flex;
  align-items: baseline;
  border-radius: 6px;
  padding: 2px 0;
  transition: background 0.1s;
}
.kb-block--image_gallery { align-items: flex-start; }
.kb-block--dragging { opacity: 0.4; }
.kb-block--dragging .kb-block__side-actions { opacity: 0 !important; }
.kb-page--locked .kb-block__side-actions { opacity: 0 !important; pointer-events: none; }
.kb-block { margin-bottom: 10px; }

.kb-drop-marker {
  height: 0;
  overflow: visible;
  pointer-events: none;
  position: relative;
  margin: 0;
}
.kb-drop-marker::before {
  content: '';
  display: block;
  position: absolute;
  inset-inline: 0;
  top: -5px;
  height: 3px;
  background: #3b82f6;
  border-radius: 2px;
}

/* Side actions — sit in the left margin, outside the page content area */
.kb-block__side-actions {
  flex-shrink: 0;
  width: 4rem;
  margin-left: -4rem;
  position: relative;
  display: flex;
  align-items: center;
  padding-right: 4px;
  opacity: 0;
  transition: opacity 0.1s;
  white-space: nowrap;
}
.kb-block:hover .kb-block__side-actions,
.kb-block__side-actions:has(.kb-block__actions-menu:not([hidden])),
.kb-block__side-actions:has(.kb-block__type-picker:not([hidden])) { opacity: 1; }

.kb-block__handle {
/*  letter-spacing: -3px;*/
}
.kb-block__handle,
.kb-block__add-btn {
  line-height: 1;
  color: #c8c7c4;
  background: none;
  border: none;
  cursor: pointer;
  user-select: none;
  padding: 4px 5px;
  border-radius: 4px;
  transition: background 0.1s, color 0.1s;
}
.kb-block__handle:hover,
.kb-block__add-btn:hover { background: #e8e7e3; color: #37352f; }

.kb-block__type-picker {
  position: absolute;
  left: 0;
  top: 0;
  background: #fff;
  border: 1px solid #e5e4e0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  padding: 4px;
  min-width: 140px;
  z-index: 100;
}

.kb-block__actions-menu {
  position: absolute;
  left: 0;
  top: 0;
  background: #fff;
  border: 1px solid #e5e4e0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  padding: 4px;
  min-width: 140px;
  z-index: 100;
}
.kb-display-submenu { position: relative; }
.kb-submenu-arrow { margin-left: auto; color: #b0b0a8; }

.kb-block__submenu {
  position: absolute;
  left: 100%;
  top: 0;
  background: #fff;
  border: 1px solid #e5e4e0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  padding: 4px;
  min-width: 150px;
  z-index: 101;
}

.kb-check-icon {
  display: inline-block;
  width: 18px;
  flex-shrink: 0;
}

.kb-block__action-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  padding: 7px 12px;
  border-radius: 6px;
  color: #37352f;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  text-decoration: none;
  transition: background 0.1s;
}
.kb-block__action-option svg { flex-shrink: 0; opacity: .7; }
.kb-block__action-option:hover { background: #f1f0ee; }
.kb-block__action-option--danger { color: #c0392b; }
.kb-block__action-option--danger:hover { background: #fdf0ee; }
.kb-block__type-picker-divider { height: 1px; background: #e9e8e3; margin: 4px 8px; }

.kb-heading { outline: none; word-break: break-word; margin: 0; font-weight: 700; color: #1a1a1a; cursor: text; }
.kb-heading:empty::before { color: #c8c7c4; font-weight: 400; }
.kb-heading--heading1 { font-size: 2rem; letter-spacing: -.5px; line-height: 1.2; }
.kb-heading--heading1:empty::before { content: "Heading 1"; }
.kb-heading--heading2 { font-size: 1.6rem; letter-spacing: -.3px; line-height: 1.25; }
.kb-heading--heading2:empty::before { content: "Heading 2"; }
.kb-heading--heading3 { font-size: 1.3rem; letter-spacing: -.2px; line-height: 1.3; }
.kb-heading--heading3:empty::before { content: "Heading 3"; }
.kb-heading--heading4 { font-size: 1.1rem; line-height: 1.35; }
.kb-heading--heading4:empty::before { content: "Heading 4"; }

.kb-hr { border: none; border-top: 2px solid #e9e8e3; margin: 8px 0; }

.kb-block__frame { display: block; flex: 1; min-width: 0; }
.kb-block__content { min-width: 0; }

.kb-block__placeholder { color: #b3b1ab; font-style: italic; }
.kb-block__text-view { line-height: 1.6; }

/* Trix: disable file attachment */
.trix-button-group--file-tools { display: none !important; }

/* Block form */
.kb-block__form { display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
.kb-block__trix { min-height: 15em; }
.kb-block__form-actions { display: flex; gap: 8px; }

/* Image gallery */
.kb-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
}
.kb-gallery--edit { margin-bottom: 12px; }

.kb-gallery__item { display: flex; flex-direction: column; }

.kb-gallery--half-width {
  gap: 12px;
  padding: 4px 0;
}
.kb-gallery--half-width .kb-gallery__item { width: calc(50% - 6px); }
.kb-gallery--half-width .kb-gallery__thumb {
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.kb-gallery--full-width {
  flex-direction: column;
  gap: 12px;
  padding: 4px 0;
}
.kb-gallery--full-width .kb-gallery__item { width: 100%; }
.kb-gallery--full-width .kb-gallery__thumb {
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.kb-gallery__thumb-link { display: block; }
.kb-gallery__caption {
  color: #6b6b63;
  padding: 4px 2px 0;
  line-height: 1.4;
  display: none;
}

.kb-gallery__caption-input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 4px 6px;
  font-family: inherit;
  border: 1px solid #e1e1d8;
  border-radius: 4px;
  outline: none;
  background: #fff;
}
.kb-gallery__caption-input:focus { border-color: #3b82f6; }
.kb-gallery__thumb {
  display: block;
  height: 140px;
  width: auto;
  border-radius: 4px;
  transition: opacity 0.15s;
}

/* Gallery edit items */
.kb-gallery__edit-item { position: relative; display: inline-block; cursor: grab; }
.kb-gallery__edit-item:active { cursor: grabbing; }
.kb-gallery__edit-item--dragging { opacity: 0.4; }

.kb-gallery__drop-marker {
  display: inline-block;
  width: 3px;
  height: 100px;
  background: #3b82f6;
  border-radius: 2px;
  vertical-align: top;
  pointer-events: none;
  align-self: stretch;
}
.kb-gallery__edit-item .kb-gallery__thumb { height: 100px; width: auto; }
.kb-gallery__remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  text-decoration: none;
}
.kb-gallery__remove:hover { background: rgba(192,57,43,0.9); }


/* Spinner */
@keyframes kb-spin { to { transform: rotate(360deg); } }
.kb-spinner {
  width: 16px; height: 16px;
  border: 2px solid #d8d7d4;
  border-top-color: #37352f;
  border-radius: 50%;
  animation: kb-spin 0.55s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
.kb-upload-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 1px solid #e0dedd;
  border-radius: 8px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #37352f;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  z-index: 9999;
}

/* Dropzone */
.kb-dropzone {
  border: 2px dashed #d8d7d4;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 8px;
}
.kb-dropzone:hover, .kb-dropzone--over {
  border-color: #5e9af0;
  background: #f0f6ff;
}
.kb-dropzone__label { color: #9b9a97; pointer-events: none; }
.kb-dropzone__input { display: none; }
.kb-dropzone__preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  justify-content: center;
}
.kb-dropzone__preview-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
}


/* Page form */
.kb-page-form { max-width: 560px; margin: 0 auto; }
.kb-page-form__context { color: #9b9a97; margin-bottom: 4px; }
.kb-page-form__context a { text-decoration: none; }
.kb-page-form__context a:hover { text-decoration: underline; }
.kb-page-form__title { font-size: 1.8rem; font-weight: 700; margin-bottom: 24px; }
.kb-field { margin-bottom: 16px; }
.kb-field__label { display: block; font-weight: 500; color: #37352f; margin-bottom: 5px; }
.kb-field__hint { color: #9b9a97; margin-bottom: 6px; }
.kb-select {
  padding: 7px 10px; border: 1px solid #d8d7d4; border-radius: 6px;
  font-family: inherit; background: #fff; color: #37352f;
  cursor: pointer;
}
.kb-select:focus { outline: none; border-color: #5e9af0; }
.kb-page-title-input {
  width: 100%;
  font-size: 1.8rem;
  font-weight: 700;
  border: none;
  outline: none;
  background: transparent;
  color: #1a1a1a;
  letter-spacing: -.3px;
}
.kb-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d8d7d4;
  border-radius: 6px;
  outline: none;
}
.kb-input:focus { border-color: #5e9af0; }
.kb-errors { background: #fdf0ee; border: 1px solid #e8c0bc; border-radius: 6px; padding: 12px 16px; margin-bottom: 16px; color: #c0392b; }

/* New customer combined form */
.kb-new-customer__section { margin: 24px 0 20px; }
.kb-new-customer__section-title {
  font-weight: 600; color: #37352f;
  margin-bottom: 14px; display: flex; align-items: center; gap: 8px;
}
.kb-new-customer__optional { font-weight: 400; color: #9b9a97; }
.kb-new-customer__phones { display: flex; gap: 8px; margin-bottom: 16px; }
.kb-new-customer__phones .kb-input { flex: 1; min-width: 0; }

/* Customer subdomains */
.kb-customer__note { color: #5f5e5b; line-height: 1.6; margin: 8px 0 24px; }
.kb-customer__note-editor { min-height: 8em; background: #fff; border-radius: 6px; }
.kb-customer__calls { margin-top: 32px; }
.kb-customer__section-title {
  font-weight: 600; color: #37352f; margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px solid #e5e4e0;
}
.kb-customer__subdomains { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 24px; }
.kb-customer__subdomain-link {
  display: inline-flex; align-items: center; gap: 5px;
  color: #37352f; text-decoration: none;
  padding: 4px 10px; border-radius: 6px; border: 1px solid #e5e4e0;
  background: #fafaf9; transition: background 0.1s, border-color 0.1s;
}
.kb-customer__subdomain-link:hover { background: #e8e7e3; border-color: #d8d7d4; }
.kb-customer__subdomain-link svg { color: #9b9a97; flex-shrink: 0; }
.kb-customer__subdomain-edit { margin: 8px 0 24px; }
.kb-customer__subdomain-input {
  width: 100%; max-width: 400px; padding: 5px 0;
  border: none; border-bottom: 1px solid transparent;
  color: #9b9a97; background: transparent; font-family: inherit;
  outline: none; transition: border-color 0.1s, color 0.1s;
}
.kb-customer__subdomain-input:focus { border-bottom-color: #d8d7d4; color: #37352f; }
.kb-customer__subdomain-input::placeholder { color: #c2c0bb; }

/* Customer list */
.kb-customer-filter { position: relative; margin-bottom: 16px; }
.kb-customer-filter__icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: #9b9a97; pointer-events: none;
}
.kb-customer-filter__input { padding-left: 36px; }

.kb-customer-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.kb-customer-list__item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0; border-bottom: 1px solid #f1f0ee;
}
.kb-customer-list__fav {
  background: none; border: none; cursor: pointer; padding: 2px;
  color: #d8d7d4; flex-shrink: 0; display: flex; align-items: center;
  transition: color 0.1s;
}
.kb-customer-list__fav:hover        { color: #f0b429; }
.kb-customer-list__fav--active      { color: #f0b429; }
.kb-customer-list__fav--active svg  { fill: #f0b429; }
.kb-customer-list__name { flex: 1; color: #37352f; text-decoration: none; }
.kb-customer-list__name:hover { text-decoration: underline; }
.kb-customer-list__count { color: #9b9a97; }

/* Flash */
.kb-flash-region {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 500; display: flex; flex-direction: column; gap: 8px;
  width: max-content; max-width: 90vw;
}
.kb-flash {
  padding: 10px 16px; border-radius: 8px; cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  font-size: 14px; border: 1px solid transparent;
  transition: opacity 0.25s, transform 0.25s;
}
.kb-flash--leaving { opacity: 0; transform: translateY(-8px); }
.kb-flash--notice { background: #edf7ed; border-color: #cce8cc; color: #1e6b25; }
.kb-flash--error  { background: #fdf0ee; border-color: #e8c0bc; color: #c0392b; }

/* Profile */
.kb-profile__avatar-row {
  display: flex; align-items: center; gap: 16px; margin-bottom: 16px;
}
.kb-avatar-input {
  width: 4ch; text-align: center; font-size: 22px;
}

/* Dashboard */
.kb-dashboard__section { margin-top: 28px; }
.kb-dashboard__heading {
  font-size: 1.4rem; font-weight: 600; color: #37352f;
  margin: 0 0 8px; margin-bottom: 16px;
}

/* On the phone now */
.kb-live-calls { display: flex; flex-direction: column; gap: 8px; }
.kb-live-calls__empty { margin: 0; }
.kb-live-call {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; border: 1px solid #e5e4e0; border-radius: 10px;
  background: #fff;
}
.kb-live-call--talking { border-color: #b7e3cd; background: #f3fbf7; }
.kb-live-call--ringing { border-color: #f3d9b8; background: #fffaf2; }

.kb-live-call__pulse {
  flex: none; width: 9px; height: 9px; border-radius: 50%;
  background: #22a06b;
}
.kb-live-call--ringing .kb-live-call__pulse { background: #e67e22; }
.kb-live-call__pulse {
  animation: kb-live-pulse 1.4s ease-in-out infinite;
}
@keyframes kb-live-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34, 160, 107, .45); }
  50%      { box-shadow: 0 0 0 5px rgba(34, 160, 107, 0); }
}
.kb-live-call--ringing .kb-live-call__pulse {
  animation-name: kb-live-pulse-ring;
}
@keyframes kb-live-pulse-ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(230, 126, 34, .45); }
  50%      { box-shadow: 0 0 0 5px rgba(230, 126, 34, 0); }
}

.kb-live-call__people {
  display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0;
}
.kb-live-call__staff {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 600; color: #37352f; white-space: nowrap;
}
.kb-live-call__arrow { color: #9b9a97; flex: none; }
.kb-live-call__party { display: flex; flex-direction: column; min-width: 0; }
.kb-live-call__party-name { font-weight: 500; color: #37352f; }
.kb-live-call__party-company { font-size: 12px; color: #9b9a97; }
.kb-live-call__subdomains { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.kb-live-call__subdomain-link {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: #37352f; text-decoration: none;
  padding: 1px 7px; border-radius: 5px; border: 1px solid #e5e4e0;
  background: #fafaf9; transition: background 0.1s, border-color 0.1s;
}
.kb-live-call__subdomain-link:hover { background: #e8e7e3; border-color: #d8d7d4; }
.kb-live-call__subdomain-link svg { color: #9b9a97; flex-shrink: 0; }

.kb-live-call__meta {
  display: flex; align-items: center; gap: 12px; flex: none; margin-left: auto;
}
.kb-live-call__status {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  color: #22a06b;
}
.kb-live-call--ringing .kb-live-call__status { color: #e67e22; }
.kb-live-call__timer {
  font-variant-numeric: tabular-nums; font-weight: 600; color: #37352f;
  min-width: 48px; text-align: right;
}

/* Calls */
.kb-page__title--static {
  font-size: 2.2rem; font-weight: 700; letter-spacing: -.5px; color: #1a1a1a; line-height: 1.2;
}
.kb-calls {
  width: 100%; border-collapse: collapse;
}
.kb-calls thead th {
  text-align: left; font-weight: 600; color: #9b9a97;
  text-transform: uppercase; letter-spacing: .5px;
  padding: 0 12px 8px; border-bottom: 1px solid #e5e4e0;
}
.kb-calls thead th:first-child { padding-left: 0; }
.kb-calls__date-row td {
  padding: 16px 0 4px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px; border-bottom: none;
}
/*.kb-calls__date-row:first-child td { padding-top: 4px; }*/
.kb-call td { padding: 10px 12px; border-bottom: 1px solid #f1f0ee; }
.kb-call--has-comments td { border-bottom: none; }
.kb-call td:first-child { padding-left: 0; }
.kb-call--ongoing td { background: #fffef5; }
.kb-call__direction { width: 30px; }
.kb-call__time { color: #9b9a97; white-space: nowrap; width: 60px; }
.kb-call__dir-icon { display: flex; align-items: center; }
.kb-call__dir-icon--ongoing  { color: #e67e22; }
.kb-call__dir-icon--answered { color: #22a06b; }
.kb-call__dir-icon--missed   { color: #c0392b; }
.kb-call__dir-icon--solved   { color: #c2c0bb; }
.kb-call--solved .kb-call__dir-icon { display: none; }
.kb-call--important .kb-call__dir-icon { display: none }
.kb-call--important .kb-call__contact { color: #c0392b; }
.kb-call__number { color: #37352f; font-size: 13px; color: #9b9a97; display: inline; }
.kb-call__peer { color: #37352f; font-size: 13px; color: #9b9a97; display: inline; }
.kb-call__contact { min-width: 140px; }
.kb-call__contact-name  { font-weight: 500; }
.kb-call__contact-company { color: #9b9a97; }
.kb-call__contact-job-title { color: #9b9a97; }
.kb-call__legacy-contact { font-style: italic; }
.kb-call__unknown { font-style: italic; }
.kb-call__import-btn {
  display: inline-flex; align-items: center;
  color: #9b9a97; text-decoration: none;
  padding: 2px 4px; border-radius: 4px; transition: background 0.1s, color 0.1s;
  margin-top: 2px; margin-left: 4px;
  vertical-align: top;
}
.kb-call__import-btn:hover { background: #e8e7e3; color: #37352f; }
.kb-call__duration { color: #37352f; white-space: nowrap; }
.kb-call__resolution { width: 36px; position: relative; padding-left: 6px; padding-right: 0 !important; text-align: right }
.kb-call__resolution-btn {
  background: none; border: none; cursor: pointer;
  display: flex; align-items: center; border-radius: 4px;
  transition: color 0.1s, background 0.1s;
}
.kb-call__resolution-btn:hover { background: #e8e7e3; }
.kb-call__resolution-btn--unsolved  { color: #c2c0bb; }
.kb-call__resolution-btn--call_back { color: #e67e22; }
.kb-call__resolution-btn--important { color: #c0392b; }
.kb-call__resolution-btn--solved    { color: #22a06b; }
.kb-call__resolution-menu {
  position: absolute; top: calc(100% + 2px); right: 0; z-index: 100;
  background: #fff; border: 1px solid #e5e4e0; border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1); padding: 4px; min-width: 150px;
}
.kb-call__resolution-option {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: none; border: none; cursor: pointer; text-align: left;
  padding: 7px 10px; border-radius: 6px; color: #37352f;
  transition: background 0.1s; white-space: nowrap;
}
.kb-call__resolution-option:hover { background: #f1f0ee; }
.kb-call__resolution-option--active { font-weight: 600; }
.kb-call__resolution-option--unsolved  svg { color: #c2c0bb; }
.kb-call__resolution-option--call_back svg { color: #e67e22; }
.kb-call__resolution-option--important svg { color: #c0392b; }
.kb-call__resolution-option--solved    svg { color: #22a06b; }
.kb-calls__pagination { display: flex; gap: 8px; margin-top: 24px; align-items: center; }
.kb-call__comments-cell { width: 36px; }
.kb-call__comments-btn {
  background: none; border: none; cursor: pointer; padding: 2px 4px;
  color: #9b9a97; display: flex; align-items: center; gap: 4px; border-radius: 4px;
  transition: color 0.1s, background 0.1s;
}
.kb-call__comments-btn:hover { color: #37352f; background: #e8e7e3; }
.kb-call__comments-btn--open { color: #37352f; }
.kb-call__comments-count { font-weight: 600; }
.kb-call__comments-row td { padding: 0; padding-right: 7px; border-bottom: 1px solid #f1f0ee; }
.kb-call__comments-panel { padding: 10px 16px 14px; background: #fff; }
.kb-call-comment { display: block; width: 100%; margin-bottom: 6px; }
.kb-call-comment__wrapper { display: flex; align-items: flex-end; gap: 12px; width: 100%; }
.kb-call-comment--own   .kb-call-comment__wrapper { justify-content: flex-end; }
.kb-call-comment--other .kb-call-comment__wrapper { justify-content: flex-start; }
.kb-call-comment--own   .kb-call-comment__avatar { order: 2; }
.kb-call-comment__avatar {
  flex-shrink: 0; font-size: 18px; line-height: 1;
  user-select: none; margin-bottom: -2px;
}
.kb-call-comment__bubble {
  position: relative; display: inline-block; text-align: left;
  padding: 8px 12px; line-height: 1.4;
  word-break: break-word;
  cursor: text; user-select: text; max-width: 70%;
  font-size: 12px;
}
.kb-call-comment--own   .kb-call-comment__bubble { background: #007aff; color: #fff; border-radius: 18px; }
.kb-call__comments-panel--solved .kb-call-comment--own .kb-call-comment__bubble { background: #22a06b; }
.kb-call__comments-panel--important .kb-call-comment--own .kb-call-comment__bubble { background: #e8736a; }
.kb-call__comments-panel--call_back .kb-call-comment--own .kb-call-comment__bubble { background: #f0a85d; }
.kb-call-comment--other .kb-call-comment__bubble { background: #e5e5ea; color: #1a1a1a; border-radius: 18px; }

/* Triangle tail (clip-path) — `background: inherit` keeps it matching the bubble
   colour incl. variants. Position freely with the left/right + bottom offsets. */
.kb-call-comment__bubble::after {
  content: ""; position: absolute; bottom: 6px;
  width: 12px; height: 13px; background: inherit;
}
.kb-call-comment--own   .kb-call-comment__bubble::after { right: -4px; clip-path: polygon(0 0, 0 100%, 100% 100%); }
.kb-call-comment--other .kb-call-comment__bubble::after { left: -4px;  clip-path: polygon(100% 0, 100% 100%, 0 100%); }
.kb-call-comment__md > *:first-child { margin-top: 0; }
.kb-call-comment__md > *:last-child { margin-bottom: 0; }
.kb-call-comment__md p { margin: 0 0 6px; }
.kb-call-comment__md ul, .kb-call-comment__md ol { margin: 4px 0; padding-left: 20px; }
.kb-call-comment__md a { text-decoration: underline; }
.kb-call-comment__md code {
  font-family: ui-monospace, monospace; font-size: 0.92em;
  background: rgba(127,127,127,0.18); padding: 1px 4px; border-radius: 4px;
}
.kb-call-comment__md pre {
  background: rgba(127,127,127,0.18); padding: 8px 10px; border-radius: 6px;
  overflow-x: auto; margin: 6px 0;
}
.kb-call-comment__md pre code { background: none; padding: 0; }
.kb-call-comment--own .kb-call-comment__md a { color: #fff; }
.kb-call-comment__meta { margin-top: 3px; color: #9b9a97; display: none; }
.kb-call-comment__author { font-weight: 500; color: #9b9a97; }
/* Comment bubble context-menu dropdown (right-click / long-press) */
.kb-bubble-menu {
  position: absolute; z-index: 50;
  background: #fff; border: 1px solid #e5e4e0; border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 4px; min-width: 132px;
}
.kb-bubble-menu form { display: block; margin: 0; }
.kb-bubble-menu__item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 10px; border-radius: 6px;
  background: none; border: none; cursor: pointer;
  font: inherit; font-size: 13px; color: #37352f;
  text-align: left; text-decoration: none;
}
.kb-bubble-menu__item:hover { background: #f1f0ee; }
.kb-bubble-menu__item--danger { color: #c0392b; }
.kb-bubble-menu__item--danger:hover { background: #fdf0ee; }
.kb-call-comment-form { margin-top: 4px; display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.kb-call-comment-form__input {
  width: 100%; padding: 8px 10px;
  border: 1px solid #d8d7d4; border-radius: 6px;
  font-family: inherit; resize: vertical; outline: none;
}
.kb-call-comment-form__input:focus { border-color: #5e9af0; }
.kb-call-comment-form__actions { display: flex; gap: 6px; }

/* Contacts */
.kb-contacts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.kb-contact {
  border: 1px solid #e5e4e0;
  border-radius: 8px;
  padding: 14px 16px;
  background: #fafaf9;
}
.kb-contact__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.kb-contact__identity { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.kb-contact__name { font-weight: 600; color: #1a1a1a; }
.kb-contact__job-title { color: #9b9a97; }
.kb-contact__actions { display: flex; gap: 2px; flex-shrink: 0; }
.kb-contact__action-btn {
  background: none; border: none; cursor: pointer; padding: 3px 5px;
  color: #c2c0bb; border-radius: 4px; display: flex; align-items: center; text-decoration: none;
  transition: background 0.1s, color 0.1s;
}
.kb-contact__action-btn:hover { background: #e8e7e3; color: #37352f; }
.kb-contact__action-btn--danger:hover { background: #fdf0ee; color: #c0392b; }
.kb-contact__details { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; }
.kb-contact__detail {
  display: flex; align-items: center; gap: 5px;
  color: #37352f;
}
.kb-contact__detail svg { color: #9b9a97; flex-shrink: 0; }
.kb-contact__detail a { text-decoration: none; color: inherit; }
.kb-contact__detail a:hover { text-decoration: underline; }
.kb-contact__note { margin-top: 8px; color: #9b9a97; white-space: pre-wrap; }

/* Contact form */
.kb-contact-form { display: flex; flex-direction: column; gap: 8px; }
.kb-contact-form__row { display: flex; gap: 8px; }
.kb-contact-form__input {
  flex: 1; padding: 7px 10px; border: 1px solid #d8d7d4; border-radius: 6px;
  font-family: inherit; background: #fff; min-width: 0;
}
.kb-contact-form__input:focus { outline: none; border-color: #5e9af0; }
.kb-contact-form__textarea {
  flex: 1; padding: 7px 10px; border: 1px solid #d8d7d4; border-radius: 6px;
  font-family: inherit; background: #fff; resize: vertical; width: 100%;
}
.kb-contact-form__textarea:focus { outline: none; border-color: #5e9af0; }
.kb-contact-form__actions { display: flex; gap: 6px; align-items: center; }

/* Add contact */
.kb-contact-add { margin-bottom: 16px; }
.kb-contact-add__trigger {
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer;
  padding: 5px 10px; border-radius: 6px; list-style: none;
  transition: background 0.1s, color 0.1s;
  user-select: none;
  background: #2d2d2d; color: #fff; font-weight: 500;
}
.kb-contact-add__trigger:hover { background: #111; }
.kb-contact-add__form { padding: 12px 0 4px; }
