:root {
  --page: #f5f6f3;
  --surface: #ffffff;
  --surface-soft: #f8f9f7;
  --text: #17201c;
  --muted: #68736e;
  --subtle: #919a96;
  --line: #dfe4e0;
  --line-strong: #ccd4cf;
  --accent: #365f52;
  --accent-hover: #294b40;
  --accent-soft: #e6eeea;
  --success: #2d7a55;
  --danger: #b84444;
  --warning: #b17a24;
  --shadow: 0 18px 50px rgba(39, 56, 49, .08);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background: var(--page);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px clamp(18px, 4vw, 54px);
  border-bottom: 1px solid rgba(204, 212, 207, .8);
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 13px;
  color: white;
  background: var(--accent);
  box-shadow: 0 8px 20px rgba(54, 95, 82, .18);
}
.brand-mark span { width: 3px; border-radius: 4px; background: currentColor; }
.brand-mark span:nth-child(1) { height: 10px; }
.brand-mark span:nth-child(2) { height: 20px; }
.brand-mark span:nth-child(3) { height: 15px; }
.brand-mark span:nth-child(4) { height: 7px; }
.brand-copy strong, .brand-copy small { display: block; }
.brand-copy strong { font-size: 16px; letter-spacing: -.01em; }
.brand-copy small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.connection-card {
  min-width: 170px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}
.connection-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 4px rgba(177, 122, 36, .11);
}
.connection-dot.ready { background: var(--success); box-shadow: 0 0 0 4px rgba(45, 122, 85, .11); }
.connection-dot.error { background: var(--danger); box-shadow: 0 0 0 4px rgba(184, 68, 68, .11); }
.connection-card strong, .connection-card small { display: block; white-space: nowrap; }
.connection-card strong { font-size: 12px; }
.connection-card small { margin-top: 1px; color: var(--muted); font-size: 10px; }

.profile-button,
.header-actions button,
.primary-button,
.secondary-button,
.danger-button,
.add-profile-button,
.close-button {
  border: 0;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}
.profile-button {
  min-width: 196px;
  height: 52px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  text-align: left;
}
.profile-button:hover { border-color: var(--line-strong); background: var(--surface-soft); }
.avatar {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  font-weight: 800;
  letter-spacing: .02em;
}
.user-avatar { width: 34px; height: 34px; background: #4f6f64; font-size: 11px; }
.profile-button-copy { min-width: 0; }
.profile-button-copy strong, .profile-button-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-button-copy strong { font-size: 12px; }
.profile-button-copy small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.profile-chevron { color: var(--subtle); font-size: 22px; line-height: 1; }

.workspace {
  width: min(1040px, calc(100% - 36px));
  margin: 0 auto;
  padding: clamp(30px, 5vw, 52px) 0 72px;
}
.intro { max-width: 720px; }
.eyebrow {
  display: inline-block;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
}
.intro h1 {
  margin: 12px 0 12px;
  font-size: clamp(38px, 6vw, 64px);
  line-height: .98;
  letter-spacing: -.055em;
  font-weight: 750;
}
.intro p {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(15px, 2vw, 18px);
  line-height: 1.6;
}

.upload-card {
  margin-top: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.drop-zone {
  min-height: 122px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 28px;
  transition: background .16s ease, box-shadow .16s ease;
}
.drop-zone.dragging { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.upload-symbol {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 27px;
  font-weight: 400;
}
.composer-copy { min-width: 0; flex: 1; }
.composer-copy strong, .composer-copy span { display: block; }
.composer-copy strong { font-size: 17px; letter-spacing: -.01em; }
.composer-copy span { margin-top: 5px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.upload-button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  color: white;
  background: var(--accent);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: background .16s ease, transform .16s ease;
}
.upload-button:hover { background: var(--accent-hover); transform: translateY(-1px); }
#audioInput { display: none; }
.spinner {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border: 3px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .85s linear infinite;
}
.progress-track { height: 3px; overflow: hidden; background: var(--accent-soft); }
.progress-bar { width: 34%; height: 100%; background: var(--accent); animation: loading 1.2s ease-in-out infinite; }
.context-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}
.context-row label { color: var(--muted); font-size: 12px; font-weight: 750; }
.context-row input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface);
}
.context-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(54, 95, 82, .11); }

.transcript-section {
  margin-top: 44px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 12px 40px rgba(39, 56, 49, .05);
}
.section-header {
  min-height: 94px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.section-title { flex: 0 0 auto; }
.section-header h2 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
.section-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.transcript-tools {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}
.search-field {
  width: min(360px, 100%);
  min-height: 40px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  background: var(--surface-soft);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.search-field:focus-within {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(54, 95, 82, .1);
}
.search-icon { font-size: 19px; line-height: 1; transform: rotate(-12deg); }
.search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 9px 0;
  color: var(--text);
  background: transparent;
  font-size: 13px;
}
.search-field input::-webkit-search-cancel-button { display: none; }
.search-field button {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.search-field button:hover { color: var(--text); background: var(--line); }
.header-actions { display: flex; gap: 7px; flex: 0 0 auto; }
.header-actions button {
  min-width: 50px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: var(--surface);
  font-size: 11px;
  font-weight: 800;
}
.header-actions button:hover:not(:disabled) { border-color: var(--line-strong); background: var(--surface-soft); }
.header-actions button:disabled { opacity: .35; cursor: default; }

.messages { overflow-x: hidden; padding: 8px 0; }
.channel-welcome {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 22px;
  text-align: center;
}
.empty-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  color: var(--accent);
  background: var(--accent-soft);
  font-family: Georgia, serif;
  font-weight: 700;
}
.channel-welcome h3 { margin: 14px 0 5px; font-size: 16px; }
.channel-welcome p { margin: 0; color: var(--muted); font-size: 13px; }
.message {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 13px;
  margin: 0 20px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}
.message:last-child { border-bottom: 0; }
.message .avatar { width: 44px; height: 44px; font-size: 12px; }
.message-user-avatar { color: white; }
.system-avatar { color: var(--accent); background: var(--accent-soft); }
.error-avatar { color: white; background: var(--danger); }
.message-body { min-width: 0; }
.message-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; min-height: 22px; }
.message-head strong { font-size: 14px; }
.message-head time { color: var(--subtle); font-size: 11px; }
.bot-tag { display: none; }
.message p {
  max-width: 100%;
  margin: 7px 0 0;
  color: #34413b;
  font-size: 15px;
  line-height: 1.68;
  overflow-wrap: anywhere;
}
.transcript-line {
  display: block;
  max-width: 100%;
  margin-top: 10px !important;
  color: #26332d !important;
  font-size: clamp(18px, 2vw, 21px) !important;
  line-height: 1.72 !important;
  letter-spacing: -.012em;
  white-space: normal;
  overflow: visible;
  word-break: normal;
  overflow-wrap: anywhere;
}
.transcript-line mark {
  border-radius: 4px;
  padding: 0 .08em;
  color: inherit;
  background: #f5df88;
  box-shadow: 0 0 0 1px rgba(153, 118, 14, .08);
}
.search-empty-state {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 22px;
  text-align: center;
}
.search-empty-state h3 { margin: 14px 0 5px; font-size: 16px; }
.search-empty-state p { margin: 0; color: var(--muted); font-size: 13px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes loading { 0% { transform: translateX(-110%); } 100% { transform: translateX(300%); } }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 120;
  padding: 11px 15px;
  border-radius: 11px;
  color: white;
  background: #17201c;
  box-shadow: 0 12px 35px rgba(23, 32, 28, .2);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: .2s ease;
  font-size: 13px;
}
.toast.show { opacity: 1; transform: translateY(0); }

body.modal-open { overflow: hidden; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(21, 29, 25, .48);
  backdrop-filter: blur(5px);
}
.settings-modal {
  width: min(800px, 100%);
  max-height: min(650px, calc(100vh - 48px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 30px 90px rgba(21, 29, 25, .24);
}
.settings-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 26px 20px;
  border-bottom: 1px solid var(--line);
}
.settings-header h2 { margin: 7px 0 0; font-size: 25px; letter-spacing: -.03em; }
.settings-header p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.close-button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 25px;
  line-height: 1;
}
.close-button:hover { color: var(--text); background: var(--accent-soft); }
.settings-content { min-height: 420px; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.profile-list-panel { min-height: 0; padding: 20px 12px; border-right: 1px solid var(--line); background: var(--surface-soft); }
.settings-label { padding: 0 9px 9px; color: var(--subtle); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.profile-list { max-height: 340px; overflow-y: auto; }
.profile-list-item {
  width: 100%;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 9px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.profile-list-item:hover { background: var(--surface); }
.profile-list-item.selected { border-color: var(--line); background: var(--surface); box-shadow: 0 5px 16px rgba(39, 56, 49, .05); }
.mini-profile-avatar { width: 36px; height: 36px; font-size: 11px; }
.profile-list-copy { min-width: 0; }
.profile-list-copy strong, .profile-list-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-list-copy strong { font-size: 13px; }
.profile-list-copy small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.active-check { color: var(--success); font-weight: 800; }
.add-profile-button {
  width: calc(100% - 8px);
  margin: 14px 4px 0;
  padding: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
}
.add-profile-button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.profile-editor { min-width: 0; padding: 28px; overflow-y: auto; }
.profile-preview { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.profile-preview-avatar { width: 56px; height: 56px; font-size: 16px; }
.profile-preview strong, .profile-preview small { display: block; }
.profile-preview strong { font-size: 18px; }
.profile-preview small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.profile-editor > label { display: block; margin: 16px 0 7px; color: var(--muted); font-size: 11px; font-weight: 800; }
.profile-editor > input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  padding: 11px 12px;
  color: var(--text);
  background: var(--surface);
}
.profile-editor > input[type="text"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(54, 95, 82, .11); }
.color-field { display: flex; align-items: center; gap: 11px; }
.color-field input[type="color"] { width: 54px; height: 40px; border: 0; padding: 0; background: transparent; cursor: pointer; }
.color-field span { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.profile-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 32px; }
.profile-actions button { border-radius: 10px; padding: 10px 13px; font-size: 12px; font-weight: 800; }
.profile-actions button:disabled { opacity: .45; cursor: default; }
.primary-button { color: white; background: var(--accent); }
.primary-button:hover { background: var(--accent-hover); }
.secondary-button { color: var(--text); background: var(--surface-soft); border: 1px solid var(--line); }
.secondary-button:hover:not(:disabled) { background: var(--accent-soft); }
.danger-button { margin-right: auto; color: var(--danger); background: transparent; }
.danger-button:hover:not(:disabled) { background: rgba(184, 68, 68, .08); }

@media (max-width: 820px) {
  .connection-card { display: none; }
  .topbar { padding-inline: 18px; }
  .workspace { width: min(100% - 28px, 1040px); }
}

@media (max-width: 650px) {
  .brand-copy small, .profile-button-copy small, .profile-chevron { display: none; }
  .brand-copy strong { font-size: 14px; }
  .profile-button { min-width: 0; width: 46px; grid-template-columns: 1fr; padding: 5px; }
  .profile-button-copy { display: none; }
  .user-avatar { width: 34px; height: 34px; }
  .workspace { padding-top: 42px; }
  .drop-zone { flex-wrap: wrap; padding: 22px; }
  .composer-copy { flex-basis: calc(100% - 70px); }
  .upload-button { width: 100%; }
  .context-row { grid-template-columns: 1fr; gap: 8px; padding: 16px 20px; }
  .section-header { align-items: stretch; flex-direction: column; }
  .transcript-tools { width: 100%; align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .header-actions { width: 100%; }
  .header-actions button { flex: 1; }
  .message { margin-inline: 16px; grid-template-columns: 38px minmax(0, 1fr); }
  .message .avatar { width: 38px; height: 38px; }
  .modal-backdrop { padding: 10px; }
  .settings-modal { max-height: calc(100vh - 20px); }
  .settings-content { grid-template-columns: 1fr; overflow-y: auto; }
  .profile-list-panel { max-height: 220px; border-right: 0; border-bottom: 1px solid var(--line); }
  .profile-list { max-height: 125px; }
  .profile-actions { flex-wrap: wrap; }
  .danger-button { margin-right: 0; }
}

/* Channel workspace */
.channel-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.channel-panel-top {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 17px 20px;
}
.active-channel-copy { min-width: 0; }
.active-channel-copy h1 {
  margin: 5px 0 0;
  font-size: clamp(20px, 3vw, 27px);
  line-height: 1.08;
  letter-spacing: -.035em;
}
.compact-upload {
  min-width: 310px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
.compact-upload.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(54, 95, 82, .1);
}
.compact-upload.busy .small-upload-button {
  opacity: .65;
  pointer-events: none;
}
.small-upload-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 12px;
  border-radius: 9px;
  color: white;
  background: var(--accent);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s ease, transform .16s ease;
}
.small-upload-button:hover { background: var(--accent-hover); transform: translateY(-1px); }
.small-upload-button span:first-child { font-size: 15px; font-weight: 500; }
.compact-upload .spinner {
  width: 18px;
  height: 18px;
  border-width: 2px;
}
.upload-status {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.channel-tabs {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding: 0 14px 13px;
  scrollbar-width: thin;
}
.channel-tab {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  transition: color .16s ease, background .16s ease, border-color .16s ease;
}
.channel-tab:hover { color: var(--text); background: var(--surface-soft); }
.channel-tab.active {
  color: var(--accent);
  border-color: #d8e4de;
  background: var(--accent-soft);
}
.compact-context {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 13px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}
.compact-context label { color: var(--muted); font-size: 11px; font-weight: 750; }
.compact-context input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  padding: 8px 10px;
  color: var(--text);
  background: var(--surface);
  font-size: 12px;
}
.compact-context input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(54, 95, 82, .1); }
.channel-panel .progress-track { border-top: 1px solid rgba(54, 95, 82, .08); }
.transcript-section { margin-top: 22px; }
.header-actions button:first-child { min-width: 82px; }

@media (max-width: 720px) {
  .channel-panel-top { align-items: flex-start; flex-direction: column; }
  .compact-upload { width: 100%; min-width: 0; justify-content: flex-start; }
  .upload-status { flex: 1; }
  .compact-context { grid-template-columns: 1fr; gap: 7px; }
}

@media (max-width: 480px) {
  .channel-panel-top { padding: 15px; }
  .channel-tabs { padding-inline: 10px; }
  .compact-context { padding: 12px 15px; }
  .compact-upload { flex-wrap: wrap; }
  .upload-status { flex-basis: calc(100% - 115px); }
}

/* Notebook theme */
:root {
  --page: #e9e4d7;
  --surface: #fffdf3;
  --surface-soft: #f8f3e5;
  --text: #28261f;
  --muted: #716c5f;
  --subtle: #9a9383;
  --line: #d8d1bf;
  --line-strong: #bdb4a0;
  --accent: #315f87;
  --accent-hover: #244b6d;
  --accent-soft: #e7eff6;
  --paper-line: rgba(92, 147, 190, .22);
  --paper-margin: rgba(203, 83, 83, .42);
  --shadow: 0 22px 60px rgba(62, 53, 35, .14);
}

body {
  background:
    radial-gradient(circle at 15% 0%, rgba(255,255,255,.7), transparent 30%),
    linear-gradient(135deg, #ece7db 0%, #ddd6c7 100%);
  font-family: "Segoe UI", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

.topbar {
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(300px, 1fr);
  align-items: center;
  gap: 18px;
  padding: 10px clamp(16px, 3vw, 42px);
  border-bottom: 1px solid #cfc6b3;
  background: rgba(250, 246, 235, .96);
  box-shadow: 0 4px 18px rgba(73, 63, 43, .08);
}

.brand-mark {
  width: 38px;
  height: 46px;
  gap: 0;
  align-items: stretch;
  justify-content: stretch;
  border: 1px solid #c7bda9;
  border-radius: 5px 10px 10px 5px;
  color: transparent;
  background:
    linear-gradient(90deg, #d7685f 0 4px, transparent 4px),
    repeating-linear-gradient(to bottom, #fffdf3 0 9px, #b9d3e6 10px 11px);
  box-shadow: 4px 5px 0 rgba(88, 77, 55, .1);
  position: relative;
}
.brand-mark::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 4px;
  bottom: 4px;
  width: 7px;
  background: repeating-linear-gradient(to bottom, #58564e 0 3px, transparent 3px 7px);
  border-radius: 4px;
}
.brand-mark span { display: none; }
.brand-copy strong { font-family: Georgia, "Times New Roman", serif; font-size: 17px; }
.brand-copy small { color: #7a7365; }

.topbar-upload {
  position: relative;
  min-width: 260px;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 5px 5px;
  border: 1px solid #cfc5b0;
  border-radius: 9px;
  background: #fffdf6;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.topbar-upload.dragging {
  border-color: var(--accent);
  background: #f1f7fb;
  box-shadow: 0 0 0 3px rgba(49, 95, 135, .12);
}
.topbar-upload.busy .topbar-upload-button { opacity: .62; pointer-events: none; }
.topbar-upload-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border-radius: 7px;
  color: white;
  background: var(--accent);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  transition: background .16s ease, transform .16s ease;
}
.topbar-upload-button:hover { background: var(--accent-hover); transform: translateY(-1px); }
.paperclip { font-size: 16px; font-weight: 500; line-height: 1; }
.topbar-upload-status {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-upload .spinner { width: 18px; height: 18px; border-width: 2px; }
.topbar-progress {
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 1px;
  height: 2px;
  border-radius: 2px;
}

.topbar-actions { justify-content: flex-end; }
.connection-card, .profile-button {
  border-color: #d1c7b3;
  background: rgba(255,253,246,.82);
}

.workspace {
  width: min(1120px, calc(100% - 36px));
  padding: clamp(24px, 4vw, 42px) 0 70px;
}

.channel-panel {
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.channel-panel-top {
  min-height: 74px;
  padding: 8px 12px 16px;
  border-bottom: 0;
}
.active-channel-copy h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 500;
  letter-spacing: -.035em;
}
.eyebrow { color: #8f4c47; letter-spacing: .12em; }
.notebook-date {
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-style: italic;
}

.channel-tabs {
  gap: 7px;
  overflow: visible;
  padding: 0 12px;
  border-bottom: 0;
}
.channel-tab {
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid #cfc4ad;
  border-bottom-color: #a99e88;
  border-radius: 9px 9px 3px 3px;
  color: #655f53;
  background: #e8dfc8;
  box-shadow: 0 2px 0 rgba(72, 62, 43, .08);
}
.channel-tab:nth-child(2) { background: #dfe8d7; }
.channel-tab:nth-child(3) { background: #e3e6ee; }
.channel-tab:nth-child(4) { background: #eaded5; }
.channel-tab:hover { color: var(--text); background: #f4edda; }
.channel-tab.active {
  z-index: 2;
  color: #302d27;
  border-color: #bfb49f;
  border-bottom-color: #fffdf3;
  background: #fffdf3;
  box-shadow: 0 -2px 0 rgba(255,255,255,.7), 0 4px 10px rgba(80,67,43,.08);
}

.compact-context {
  margin: 0 12px;
  padding: 12px 18px;
  border: 1px solid #d2c8b4;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: rgba(255,253,243,.84);
}
.compact-context input {
  border-color: #d3cab7;
  border-radius: 5px;
  background: rgba(255,255,255,.55);
}

.transcript-section {
  position: relative;
  margin-top: 0;
  overflow: hidden;
  border: 1px solid #c9bea8;
  border-radius: 4px 12px 12px 4px;
  background:
    linear-gradient(90deg, transparent 0 72px, var(--paper-margin) 72px 74px, transparent 74px),
    repeating-linear-gradient(to bottom, transparent 0 37px, var(--paper-line) 37px 38px),
    #fffdf3;
  box-shadow: var(--shadow), -7px 0 0 #d8cfbd, -11px 0 0 #a69b85;
}
.transcript-section::before {
  content: "";
  position: absolute;
  z-index: 4;
  left: -6px;
  top: 24px;
  bottom: 24px;
  width: 12px;
  background: repeating-linear-gradient(to bottom, #5e5b53 0 5px, transparent 5px 16px);
  border-radius: 7px;
  pointer-events: none;
}

.section-header {
  min-height: 92px;
  padding: 17px 22px 17px 92px;
  border-bottom: 1px solid rgba(168, 156, 133, .55);
  background: rgba(255,253,243,.82);
  backdrop-filter: blur(4px);
}
.section-header h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 500;
}
.section-header p { color: #7e7769; }
.search-field {
  border-color: #d0c6b2;
  border-radius: 6px;
  background: rgba(255,255,255,.55);
}
.header-actions button {
  border-color: #cfc5b2;
  border-radius: 5px;
  background: rgba(255,253,246,.82);
}

.messages { padding: 0 0 20px; }
.message {
  min-height: 114px;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 14px;
  margin: 0;
  padding: 19px 28px 18px 88px;
  border-bottom: 1px dashed rgba(137, 126, 103, .28);
}
.message:last-child { border-bottom: 0; }
.message .avatar {
  width: 36px;
  height: 36px;
  margin-top: 1px;
  border: 2px solid rgba(255,253,243,.9);
  box-shadow: 0 0 0 1px rgba(101, 89, 68, .16);
  font-size: 10px;
}
.message-head strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  font-weight: 600;
}
.message-head time { color: #8d8576; font-style: italic; }
.message p { color: #343129; }
.transcript-line {
  margin-top: 8px !important;
  color: #29271f !important;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(20px, 2vw, 23px) !important;
  line-height: 1.67 !important;
  letter-spacing: .003em;
}
.transcript-line mark { background: #f5de79; }

.channel-welcome, .search-empty-state {
  min-height: 320px;
  padding-left: 92px;
}
.empty-icon {
  border: 1px solid #d4c9b4;
  border-radius: 6px;
  background: rgba(255,255,255,.55);
  font-family: Georgia, "Times New Roman", serif;
}
.channel-welcome h3, .search-empty-state h3 { font-family: Georgia, "Times New Roman", serif; font-size: 19px; font-weight: 500; }

.settings-modal {
  border-color: #c8bda8;
  background: #fffdf3;
}
.settings-header, .profile-list-panel { background: #f5efdf; }
.profile-editor input, .profile-editor select { border-radius: 5px; }

@media (max-width: 1000px) {
  .topbar { grid-template-columns: minmax(180px, 1fr) minmax(230px, 1fr) auto; }
  .connection-card { display: none; }
}

@media (max-width: 760px) {
  .topbar {
    position: sticky;
    grid-template-columns: 1fr auto;
    gap: 9px;
    padding: 9px 14px;
  }
  .topbar-upload {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-width: 0;
  }
  .topbar-actions { grid-column: 2; grid-row: 1; }
  .workspace { width: min(100% - 24px, 1120px); padding-top: 24px; }
  .channel-panel-top { align-items: flex-end; flex-direction: row; padding-inline: 4px; }
  .channel-tabs { padding-inline: 0; }
  .channel-tab { padding-inline: 13px; font-size: 11px; }
  .compact-context { margin-inline: 0; }
  .section-header { padding-left: 64px; }
  .message { padding-left: 62px; padding-right: 18px; }
  .transcript-section {
    background:
      linear-gradient(90deg, transparent 0 49px, var(--paper-margin) 49px 51px, transparent 51px),
      repeating-linear-gradient(to bottom, transparent 0 37px, var(--paper-line) 37px 38px),
      #fffdf3;
  }
  .channel-welcome, .search-empty-state { padding-left: 62px; }
}

@media (max-width: 520px) {
  .brand-copy small, .topbar-upload-status { display: none; }
  .brand-copy strong { font-size: 14px; }
  .brand-mark { width: 32px; height: 39px; }
  .topbar-upload { justify-content: space-between; }
  .topbar-upload-button { flex: 1; justify-content: center; }
  .channel-panel-top { align-items: flex-start; flex-direction: column; gap: 6px; }
  .notebook-date { font-size: 11px; }
  .channel-tabs { gap: 4px; }
  .channel-tab { min-height: 38px; padding-inline: 9px; font-size: 10px; }
  .compact-context { grid-template-columns: 1fr; gap: 7px; padding: 11px 13px; }
  .section-header { padding-left: 58px; }
  .message {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 9px;
    padding-left: 56px;
    padding-right: 12px;
  }
  .message .avatar { width: 30px; height: 30px; font-size: 9px; }
  .transcript-line { font-size: 19px !important; line-height: 1.72 !important; }
}


/* Full-screen notebook layout */
html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
}

.app-shell {
  width: 100%;
  height: 100vh;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  flex: 0 0 auto;
}

.workspace {
  width: 100%;
  max-width: none;
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
}

.channel-panel {
  flex: 0 0 auto;
  padding: 12px 22px 0;
  border-bottom: 1px solid #c9bea8;
  background: #e9e1cf;
}

.channel-panel-top {
  min-height: 66px;
  padding: 4px 8px 12px;
}

.channel-tabs {
  padding-inline: 8px;
}

.transcript-section {
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.transcript-section::before {
  left: 0;
}

.section-header {
  flex: 0 0 auto;
}

.transcript-tools {
  margin-left: auto;
}

.messages {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.search-empty-state {
  min-height: 0;
  flex: 1 1 auto;
}

@media (max-width: 760px) {
  .workspace {
    width: 100%;
    padding: 0;
  }

  .channel-panel {
    padding: 10px 12px 0;
  }
}

@media (max-width: 520px) {
  .channel-panel {
    padding-inline: 8px;
  }

  .section-header {
    gap: 12px;
  }
}


/* Transcription Tree refinements */
.brand-copy { display: flex; align-items: center; }
.brand-copy strong { font-size: 19px; }
.active-channel-copy h1 { margin-top: 0; }


/* Channel clearing and retention controls */
.clear-channel-button {
  min-height: 40px;
  flex: 0 0 auto;
  border: 1px solid rgba(184, 68, 68, .28);
  border-radius: 11px;
  padding: 0 14px;
  color: #9e3d3d;
  background: rgba(255, 250, 247, .88);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}
.clear-channel-button:hover:not(:disabled) {
  border-color: rgba(184, 68, 68, .52);
  background: rgba(184, 68, 68, .08);
  transform: translateY(-1px);
}
.clear-channel-button:focus-visible {
  outline: 3px solid rgba(184, 68, 68, .16);
  outline-offset: 2px;
}
.clear-channel-button:disabled {
  opacity: .45;
  cursor: not-allowed;
}
@media (max-width: 760px) {
  .clear-channel-button { width: 100%; }
}

/* Per-user transcript language preference */
.profile-editor > select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: none;
  padding: 11px 38px 11px 12px;
  color: var(--text);
  background-color: var(--surface);
  cursor: pointer;
}
.profile-editor > select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(54, 95, 82, .11);
}
.language-help {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.transcript-line.translation-pending {
  color: #8d8576;
  font-style: italic;
}

/* The transcript toolbar stands alone; category title is shown in the channel header. */
.section-header { justify-content: flex-end; min-height: 68px; }


/* Day filter */
.day-field {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  padding: 0 10px 0 12px;
  border: 1px solid #c9bea8;
  border-radius: 8px;
  color: #60594c;
  background: rgba(255, 253, 246, .92);
}
.day-field-label {
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.day-field input[type="date"] {
  min-width: 136px;
  border: 0;
  outline: 0;
  padding: 5px 2px;
  color: var(--text);
  background: transparent;
  font-size: 12px;
  cursor: pointer;
}
.day-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(54, 95, 82, .10);
}
@media (max-width: 760px) {
  .day-field { width: 100%; justify-content: space-between; }
  .day-field input[type="date"] { flex: 1 1 auto; min-width: 0; text-align: right; }
}

/* Login and administrator accounts */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 22px;
  overflow-y: auto;
  background:
    radial-gradient(circle at 20% 0%, rgba(255,255,255,.72), transparent 34%),
    linear-gradient(135deg, #ece7db 0%, #d8d0bf 100%);
}
.login-card {
  width: min(420px, 100%);
  padding: 34px;
  border: 1px solid #c9bea8;
  border-radius: 16px;
  background: #fffdf3;
  box-shadow: 0 28px 80px rgba(62, 53, 35, .18);
}
.login-brand-mark {
  width: 50px;
  height: 58px;
  margin: 0 auto 18px;
  border: 1px solid #c7bda9;
  border-radius: 6px 12px 12px 6px;
  background:
    linear-gradient(90deg, #d7685f 0 5px, transparent 5px),
    repeating-linear-gradient(to bottom, #fffdf3 0 11px, #b9d3e6 12px 13px);
  box-shadow: 5px 6px 0 rgba(88, 77, 55, .1);
  position: relative;
}
.login-brand-mark::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 5px;
  bottom: 5px;
  width: 8px;
  border-radius: 4px;
  background: repeating-linear-gradient(to bottom, #58564e 0 3px, transparent 3px 8px);
}
.login-brand-mark span { display: none; }
.login-card h1 {
  margin: 0;
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -.035em;
}
.login-card > p {
  margin: 8px 0 26px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}
.login-card label {
  display: block;
  margin: 15px 0 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}
.login-card input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  padding: 0 13px;
  color: var(--text);
  background: #fffef9;
}
.login-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(49, 95, 135, .12);
}
.login-button {
  width: 100%;
  min-height: 46px;
  margin-top: 22px;
  border: 0;
  border-radius: 8px;
  color: white;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}
.login-button:hover:not(:disabled) { background: var(--accent-hover); }
.login-button:disabled { opacity: .6; cursor: wait; }
.login-error,
.form-error {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(184, 68, 68, .28);
  border-radius: 7px;
  color: #963b3b;
  background: rgba(184, 68, 68, .07);
  font-size: 12px;
  line-height: 1.4;
}

.profile-button {
  grid-template-columns: 34px minmax(0, 1fr) auto auto;
}
.profile-button:disabled,
.profile-button.non-admin {
  cursor: default;
  opacity: 1;
}
.profile-button:disabled:hover { border-color: #d1c7b3; background: rgba(255,253,246,.82); }
.admin-chip {
  padding: 3px 6px;
  border-radius: 999px;
  color: #285341;
  background: #dfece5;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.logout-button {
  min-height: 40px;
  border: 1px solid #d1c7b3;
  border-radius: 9px;
  padding: 0 12px;
  color: #5d574d;
  background: rgba(255,253,246,.82);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}
.logout-button:hover { border-color: #a99e88; background: #fffdf6; }

.profile-editor > input[type="password"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: none;
  padding: 11px 12px;
  color: var(--text);
  background: var(--surface);
}
.profile-editor > input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(54, 95, 82, .11);
}
.field-help {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}
.admin-checkbox {
  display: flex !important;
  align-items: center;
  gap: 9px;
  margin-top: 18px !important;
  color: var(--text) !important;
  cursor: pointer;
}
.admin-checkbox input { width: 17px; height: 17px; accent-color: var(--accent); }
.admin-settings-modal { width: min(920px, calc(100vw - 28px)); }

@media (max-width: 1000px) {
  .topbar-actions { gap: 7px; }
  .profile-button { min-width: 180px; }
}
@media (max-width: 650px) {
  .admin-chip { display: none; }
  .logout-button { min-width: 44px; padding: 0 8px; font-size: 0; }
  .logout-button::before { content: "↪"; font-size: 18px; }
  .profile-button { grid-template-columns: 1fr; }
}
@media (max-width: 460px) {
  .login-card { padding: 26px 22px; }
}

/* Keep every administrator user setting accessible on shorter screens. */
.admin-settings-modal {
  display: flex;
  flex-direction: column;
  height: min(760px, calc(100vh - 48px));
  max-height: calc(100vh - 48px);
}
.admin-settings-modal .settings-header {
  flex: 0 0 auto;
}
.admin-settings-modal .settings-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.admin-settings-modal .profile-list-panel,
.admin-settings-modal .profile-editor {
  min-height: 0;
}
.admin-settings-modal .profile-list-panel {
  overflow-y: auto;
}
.admin-settings-modal .profile-editor {
  position: relative;
  overflow-y: auto;
  padding-bottom: 0;
}
.language-setting-card {
  margin-top: 18px;
  padding: 15px;
  border: 1px solid #d5ccba;
  border-radius: 10px;
  background: rgba(248, 243, 229, .72);
}
.language-setting-card > label {
  display: block;
  margin: 0 0 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
}
.language-setting-card > select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
  padding: 10px 38px 10px 12px;
  color: var(--text);
  background-color: var(--surface);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}
.language-setting-card > select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(54, 95, 82, .11);
}
.admin-settings-modal .profile-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin: 28px -28px 0;
  padding: 16px 28px;
  border-top: 1px solid var(--line);
  background: rgba(255, 253, 243, .97);
  box-shadow: 0 -10px 24px rgba(62, 53, 35, .08);
  backdrop-filter: blur(8px);
}
.admin-settings-modal #saveProfileButton {
  min-width: 130px;
  min-height: 42px;
  font-size: 13px;
}
@media (max-width: 650px) {
  .admin-settings-modal {
    height: calc(100vh - 20px);
    max-height: calc(100vh - 20px);
  }
  .admin-settings-modal .settings-content {
    overflow-y: auto;
  }
  .admin-settings-modal .profile-list-panel {
    flex: 0 0 auto;
    overflow: visible;
  }
  .admin-settings-modal .profile-editor {
    overflow: visible;
  }
  .admin-settings-modal .profile-actions {
    margin-inline: -28px;
  }
}

/* Administrator channel permissions and channel maintenance */
.channel-access-card {
  margin: 18px 0 0;
  padding: 15px;
  border: 1px solid #d5ccba;
  border-radius: 10px;
  background: rgba(248, 243, 229, .72);
}
.channel-access-card legend {
  padding: 0 5px;
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
}
.channel-access-card > p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}
.channel-access-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.channel-access-toggle {
  display: grid !important;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  column-gap: 9px;
  min-height: 43px;
  margin: 0 !important;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text) !important;
  background: var(--surface);
  cursor: pointer;
  font-size: 12px !important;
  font-weight: 750 !important;
}
.channel-access-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.toggle-control {
  position: relative;
  grid-row: 1;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #d8d3c7;
  transition: background .16s ease;
}
.toggle-control::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  transition: transform .16s ease;
}
.channel-access-toggle input:checked + .toggle-control { background: var(--accent); }
.channel-access-toggle input:checked + .toggle-control::after { transform: translateX(14px); }
.channel-access-toggle input:focus-visible + .toggle-control { box-shadow: 0 0 0 3px rgba(54, 95, 82, .16); }
.toggle-label {
  grid-column: 2;
  min-width: 0;
  line-height: 1.25;
}

.channel-maintenance-panel {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.channel-maintenance-panel > p {
  margin: 7px 0 12px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}
.admin-channel-clear-list {
  display: grid;
  gap: 7px;
}
.admin-channel-clear-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}
.admin-channel-clear-row > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.admin-channel-clear-row strong {
  overflow: hidden;
  color: var(--text);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-channel-clear-row small {
  color: var(--muted);
  font-size: 10px;
}
.admin-clear-channel-button {
  min-height: 31px;
  padding: 0 10px;
  border: 1px solid #e2bdb5;
  border-radius: 8px;
  color: #9e3e30;
  background: #fff5f2;
  cursor: pointer;
  font-size: 10px;
  font-weight: 850;
}
.admin-clear-channel-button:hover:not(:disabled) { background: #fde9e4; }
.admin-clear-channel-button:disabled { opacity: .42; cursor: not-allowed; }

@media (max-width: 650px) {
  .channel-access-grid { grid-template-columns: 1fr; }
}


/* Administrator metrics */
.metrics-button,
.metrics-refresh-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.metrics-button:hover,
.metrics-refresh-button:hover { background: var(--surface-soft); border-color: var(--line-strong); }
.metrics-modal {
  width: min(1180px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.metrics-header { flex: 0 0 auto; }
.metrics-content {
  min-height: 0;
  overflow-y: auto;
  padding: 22px;
}
.metrics-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.metrics-filter-group { display: flex; flex-wrap: wrap; gap: 12px; }
.metrics-toolbar label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 750; }
.metrics-toolbar select,
.metrics-toolbar input {
  min-width: 190px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0 12px;
  color: var(--text);
  background: var(--surface);
}
.metrics-toolbar input { min-width: 250px; }
.metrics-toolbar input::placeholder { color: var(--muted); }
.metrics-status {
  padding: 26px;
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
}
.metrics-status.error { color: var(--danger); border-color: rgba(184, 68, 68, .4); background: rgba(184, 68, 68, .04); }
.metrics-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.metric-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface-soft);
}
.metric-card span,
.metric-card small { display: block; color: var(--muted); }
.metric-card span { font-size: 11px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; }
.metric-card strong {
  display: block;
  margin-top: 9px;
  overflow: hidden;
  color: var(--text);
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.05;
  letter-spacing: -.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.metric-card small { min-height: 16px; margin-top: 6px; font-size: 11px; }
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.metric-chart-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
}
.daily-chart-card { grid-column: 1 / -1; }
.metric-chart-heading h3 { margin: 0; font-size: 15px; }
.metric-chart-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.metric-chart {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 14px;
  overflow: visible;
}
.metric-chart .chart-grid { stroke: var(--line); stroke-width: 1; }
.metric-chart .chart-axis { stroke: var(--line-strong); stroke-width: 1; }
.metric-chart .chart-label { fill: var(--muted); font-size: 11px; font-family: inherit; }
.metric-chart .chart-value { fill: var(--text); font-size: 11px; font-weight: 750; font-family: inherit; }
.metric-chart .chart-line { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.metric-chart .chart-area { fill: var(--accent-soft); opacity: .72; }
.metric-chart .chart-point { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.metric-chart .chart-bar { fill: var(--accent); }
.metric-chart .chart-bar-secondary { fill: var(--accent-hover); }
.metric-chart .chart-empty { fill: var(--muted); font-size: 15px; font-family: inherit; }

.metrics-time-table-wrap { margin-top: 16px; overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; }
.metrics-time-table { width: 100%; border-collapse: collapse; min-width: 620px; font-size: 12px; }
.metrics-time-table th, .metrics-time-table td { padding: 11px 13px; border-bottom: 1px solid var(--line); text-align: left; }
.metrics-time-table th { color: var(--muted); background: var(--surface-soft); font-size: 10px; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.metrics-time-table tbody tr:last-child td { border-bottom: 0; }
.metrics-time-table td { color: var(--text); }
.metric-chart .chart-time-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.metric-chart .chart-time-point { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; }

@media (max-width: 980px) {
  .metrics-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .metrics-button { grid-column: auto; }
  .metrics-content { padding: 16px; }
  .metrics-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics-grid { grid-template-columns: 1fr; }
  .daily-chart-card { grid-column: auto; }
}
@media (max-width: 520px) {
  .metrics-modal { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .metrics-toolbar { align-items: stretch; flex-direction: column; }
  .metrics-filter-group, .metrics-toolbar label, .metrics-toolbar select, .metrics-toolbar input, .metrics-refresh-button { width: 100%; }
  .metrics-summary { grid-template-columns: 1fr 1fr; }
  .metric-card { padding: 13px; }
}

/* Multi-property login and private owner console */
.multi-login-card {
  width: min(440px, calc(100vw - 32px));
}

.login-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  margin: 18px 0 20px;
  border: 1px solid #d9ddd8;
  border-radius: 12px;
  background: #f4f6f3;
}

.login-mode-tab {
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  background: transparent;
  color: #667069;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.login-mode-tab.active {
  background: #ffffff;
  color: #21473d;
  box-shadow: 0 1px 4px rgba(32, 56, 48, 0.12);
}

.brand-copy small {
  display: block;
  margin-top: 2px;
  color: #758078;
  font-size: 0.75rem;
  font-weight: 600;
}

.owner-shell {
  min-height: 100vh;
  background: #f4f6f2;
  color: #20312b;
}

.owner-topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 28px;
  border-bottom: 1px solid #dce2dc;
  background: rgba(255, 255, 255, 0.96);
  position: sticky;
  top: 0;
  z-index: 20;
}

.owner-topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.owner-security-badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: #e7f1ec;
  color: #285d4d;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.owner-workspace {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 34px 34px 60px;
}

.owner-dashboard-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.owner-dashboard-header h1 {
  margin: 4px 0 6px;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  letter-spacing: -0.035em;
}

.owner-dashboard-header p,
.owner-editor-heading p,
.owner-admin-section p {
  margin: 0;
  color: #69756e;
}

.owner-add-property {
  white-space: nowrap;
}

.owner-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.owner-summary-grid article {
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
  border: 1px solid #dce2dc;
  border-radius: 16px;
  background: #ffffff;
}

.owner-summary-grid span {
  color: #68736c;
  font-size: 0.84rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.045em;
}

.owner-summary-grid strong {
  font-size: 2rem;
  line-height: 1;
  color: #21473d;
}

.owner-management-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  min-height: 650px;
  overflow: hidden;
  border: 1px solid #d9dfd9;
  border-radius: 18px;
  background: #ffffff;
}

.owner-property-list-panel {
  padding: 18px;
  border-right: 1px solid #dfe4df;
  background: #f8faf7;
}

.owner-list-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.owner-list-heading span {
  min-width: 30px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e6eee9;
  color: #315f51;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 800;
}

.owner-property-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 0 12px;
  border: 1px solid #d7ddd7;
  border-radius: 11px;
  background: #ffffff;
}

.owner-property-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: none;
  padding: 11px 0;
  background: transparent;
  font: inherit;
}

.owner-property-list {
  display: grid;
  gap: 8px;
}

.owner-property-list-item {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.owner-property-list-item:hover {
  background: #eef3ef;
}

.owner-property-list-item.selected {
  border-color: #9ab8ad;
  background: #e5efea;
}

.owner-property-list-code {
  min-width: 64px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #203f36;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.035em;
}

.owner-property-list-copy {
  min-width: 0;
}

.owner-property-list-copy strong,
.owner-property-list-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.owner-property-list-copy small {
  margin-top: 3px;
  color: #69756e;
  font-size: 0.75rem;
}

.owner-property-message-count {
  min-width: 28px;
  color: #3d6256;
  text-align: right;
  font-size: 0.82rem;
  font-weight: 800;
}

.owner-property-empty {
  padding: 30px 14px;
  color: #79837d;
  text-align: center;
}

.owner-property-editor {
  padding: 30px;
  overflow: auto;
}

.owner-editor-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 22px;
  border-bottom: 1px solid #e1e5e1;
}

.owner-editor-heading h2 {
  margin: 4px 0 6px;
  font-size: 1.65rem;
}

.owner-property-code-chip {
  padding: 8px 11px;
  border-radius: 9px;
  background: #233f37;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.owner-form-grid {
  display: grid;
  gap: 18px;
  margin-top: 22px;
}

.owner-form-grid.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.owner-form-grid.three-columns {
  grid-template-columns: minmax(160px, 0.8fr) minmax(140px, 0.7fr) minmax(240px, 1.25fr);
}

.owner-property-editor label,
.owner-language-fieldset > span {
  display: block;
  color: #394a43;
  font-size: 0.84rem;
  font-weight: 800;
}

.owner-property-editor input,
.owner-property-editor select {
  width: 100%;
  margin-top: 7px;
  padding: 11px 12px;
  border: 1px solid #cfd7d1;
  border-radius: 10px;
  background: #ffffff;
  color: #20312b;
  font: inherit;
}

.owner-property-editor input:focus,
.owner-property-editor select:focus {
  border-color: #5f8d7d;
  outline: 3px solid rgba(64, 115, 96, 0.13);
}

.owner-property-editor label small {
  display: block;
  margin-top: 6px;
  color: #7a847e;
  font-size: 0.75rem;
  font-weight: 500;
}

.owner-language-fieldset {
  padding: 13px 14px;
  border: 1px solid #d3dad4;
  border-radius: 11px;
  background: #f8faf8;
}

.owner-language-fieldset label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  margin-right: 18px;
  font-weight: 650;
}

.owner-language-fieldset input {
  width: auto;
  margin: 0;
}

.owner-admin-section {
  margin-top: 26px;
  padding: 20px;
  border: 1px solid #d7ded8;
  border-radius: 14px;
  background: #f7faf8;
}

.owner-admin-section h3 {
  margin: 4px 0 5px;
}

.owner-admin-section > label {
  margin-top: 18px;
}

.owner-property-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.owner-property-stats span {
  padding: 7px 11px;
  border-radius: 999px;
  background: #edf2ee;
  color: #54635b;
  font-size: 0.78rem;
}

.owner-editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid #e0e5e1;
}

@media (max-width: 980px) {
  .owner-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .owner-management-grid {
    grid-template-columns: 1fr;
  }

  .owner-property-list-panel {
    border-right: 0;
    border-bottom: 1px solid #dfe4df;
  }

  .owner-property-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .owner-form-grid.three-columns {
    grid-template-columns: 1fr 1fr;
  }

  .owner-language-fieldset {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .owner-topbar,
  .owner-dashboard-header,
  .owner-topbar-actions {
    align-items: flex-start;
  }

  .owner-topbar,
  .owner-dashboard-header {
    flex-direction: column;
  }

  .owner-workspace {
    padding: 22px 14px 40px;
  }

  .owner-summary-grid,
  .owner-property-list,
  .owner-form-grid.two-columns,
  .owner-form-grid.three-columns {
    grid-template-columns: 1fr;
  }

  .owner-language-fieldset {
    grid-column: auto;
  }

  .owner-property-editor {
    padding: 20px 16px;
  }

  .owner-editor-heading,
  .owner-editor-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .owner-editor-actions button {
    width: 100%;
  }
}

.owner-shell {
  height: 100vh;
  overflow-y: auto;
}

.owner-topbar .brand-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.owner-users-panel {
  margin-top: 22px;
  border: 1px solid #d9dfd9;
  border-radius: 18px;
  background: #ffffff;
  overflow: hidden;
}

.owner-users-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 26px;
  border-bottom: 1px solid #dfe4df;
}

.owner-users-heading h2 {
  margin: 4px 0 5px;
  font-size: 1.45rem;
}

.owner-users-heading p,
.owner-user-editor-heading p,
.owner-user-channel-card p {
  margin: 0;
  color: #69756e;
}

.owner-users-heading-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  white-space: nowrap;
}

.owner-users-heading-actions > span {
  color: #647169;
  font-size: 0.82rem;
}

.owner-users-grid {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  min-height: 560px;
}

.owner-user-list-panel {
  padding: 16px;
  border-right: 1px solid #dfe4df;
  background: #f8faf7;
}

.owner-user-list {
  display: grid;
  gap: 8px;
}

.owner-user-list-item {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 11px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.owner-user-list-item:hover {
  background: #eef3ef;
}

.owner-user-list-item.selected {
  border-color: #9ab8ad;
  background: #e5efea;
}

.owner-user-avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--owner-user-color, #365f52);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 850;
}

.owner-user-list-copy {
  min-width: 0;
}

.owner-user-list-copy strong,
.owner-user-list-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.owner-user-list-copy small {
  margin-top: 3px;
  color: #69756e;
  font-size: 0.72rem;
}

.owner-user-admin-badge {
  padding: 4px 7px;
  border-radius: 999px;
  background: #dfece6;
  color: #285d4d;
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

.owner-user-editor {
  padding: 26px;
}

.owner-user-editor-heading {
  padding-bottom: 18px;
  border-bottom: 1px solid #e1e5e1;
}

.owner-user-editor-heading h3 {
  margin: 4px 0 5px;
  font-size: 1.35rem;
}

.owner-user-editor label,
.owner-user-channel-card legend {
  display: block;
  color: #394a43;
  font-size: 0.84rem;
  font-weight: 800;
}

.owner-user-editor input[type="text"],
.owner-user-editor input[type="password"],
.owner-user-editor select {
  width: 100%;
  margin-top: 7px;
  padding: 11px 12px;
  border: 1px solid #cfd7d1;
  border-radius: 10px;
  background: #ffffff;
  color: #20312b;
  font: inherit;
}

.owner-user-editor input:focus,
.owner-user-editor select:focus {
  border-color: #5f8d7d;
  outline: 3px solid rgba(64, 115, 96, 0.13);
}

.owner-user-editor label small {
  display: block;
  margin-top: 6px;
  color: #7a847e;
  font-size: 0.75rem;
  font-weight: 500;
}

.owner-user-color-field {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 7px;
  padding: 7px 11px;
  border: 1px solid #cfd7d1;
  border-radius: 10px;
  background: #ffffff;
}

.owner-user-color-field input {
  width: 38px;
  height: 30px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.owner-user-color-field strong {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.owner-user-channel-card {
  margin: 22px 0 0;
  padding: 16px;
  border: 1px solid #d5ddd6;
  border-radius: 12px;
  background: #f8faf8;
}

.owner-user-channel-card p {
  margin-top: 4px;
  font-size: 0.78rem;
}

.owner-user-channel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 13px;
}

.owner-user-channel-option {
  display: flex !important;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid #d9e0da;
  border-radius: 10px;
  background: #ffffff;
  font-weight: 650 !important;
}

.owner-user-channel-option input,
.owner-user-admin-toggle input {
  width: auto;
  margin: 0;
}

.owner-user-admin-toggle {
  display: flex !important;
  align-items: center;
  gap: 9px;
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid #d5ddd6;
  border-radius: 11px;
  background: #f8faf8;
}

@media (max-width: 980px) {
  .owner-users-grid {
    grid-template-columns: 1fr;
  }

  .owner-user-list-panel {
    border-right: 0;
    border-bottom: 1px solid #dfe4df;
  }

  .owner-user-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .owner-users-heading,
  .owner-users-heading-actions,
  .owner-user-editor .owner-editor-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .owner-users-heading-actions .primary-button,
  .owner-user-editor .owner-editor-actions button {
    width: 100%;
  }

  .owner-user-list,
  .owner-user-channel-grid {
    grid-template-columns: 1fr;
  }

  .owner-user-editor {
    padding: 20px 16px;
  }
}
