/* =========================================================================
   DigitalEdge XBox – Aurora Console design system
   ========================================================================= */

:root {
  /* Palette */
  --bg-1: #f3f6ff;
  --bg-2: #eef0fb;
  --bg-3: #e7eefc;
  --ink-1: #0d1830;
  --ink-2: #2a3a5e;
  --ink-3: #5b6e90;
  --ink-muted: #8c9ab8;
  --line: #d8e2f5;
  --line-strong: #c1d0ee;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --surface-soft: rgba(247, 250, 255, 0.78);

  --accent-indigo: #6366f1;
  --accent-cyan: #22d3ee;
  --accent-emerald: #10b981;
  --accent-mint: #34d399;
  --accent-violet: #8b5cf6;
  --accent-amber: #f59e0b;
  --accent-coral: #fb7185;
  --accent-danger: #ef4444;

  --gradient-primary: linear-gradient(125deg, #6366f1 0%, #22d3ee 60%, #34d399 100%);
  --gradient-soft: linear-gradient(140deg, rgba(99, 102, 241, 0.10), rgba(34, 211, 238, 0.10));
  --gradient-warm: linear-gradient(135deg, #fb7185, #f59e0b);

  --shadow-sm: 0 4px 12px rgba(20, 40, 90, 0.06);
  --shadow-md: 0 12px 32px rgba(20, 40, 90, 0.10);
  --shadow-lg: 0 24px 60px rgba(20, 40, 90, 0.14);
  --shadow-glow: 0 8px 24px rgba(99, 102, 241, 0.28);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --header-h: 64px;

  font-family: "Inter", "Segoe UI", Tahoma, sans-serif;
  color: var(--ink-1);
  background: var(--bg-1);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink-1);
  background:
    radial-gradient(1100px 600px at 8% -10%, rgba(99, 102, 241, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(34, 211, 238, 0.16), transparent 55%),
    radial-gradient(700px 500px at 50% 110%, rgba(52, 211, 153, 0.14), transparent 55%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 60%, var(--bg-3) 100%);
  background-attachment: fixed;
}

::selection {
  background: rgba(99, 102, 241, 0.25);
  color: var(--ink-1);
}

.hidden {
  display: none !important;
}

/* =========================================================================
   Brand header
   ========================================================================= */

.brand-header {
  position: sticky;
  top: 0;
  z-index: 25;
  padding: 12px 18px;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  background: rgba(244, 247, 255, 0.78);
  border-bottom: 1px solid rgba(193, 208, 238, 0.65);
}

.brand-wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
}

.brand-main {
  font-family: "Orbitron", "Inter", sans-serif;
  font-size: clamp(22px, 3vw, 30px);
  letter-spacing: 0.5px;
  color: var(--ink-1);
  background: linear-gradient(120deg, #1e3a8a, #6366f1 60%, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  font-family: "Orbitron", "Inter", sans-serif;
  font-size: clamp(15px, 2vw, 20px);
  letter-spacing: 0.8px;
  color: var(--accent-emerald);
  text-shadow: 0 0 10px rgba(52, 211, 153, 0.45);
  animation: xboxGlow 2.4s ease-in-out infinite alternate;
}

@keyframes xboxGlow {
  from { text-shadow: 0 0 6px rgba(52, 211, 153, 0.35); color: #10b981; }
  to   { text-shadow: 0 0 18px rgba(52, 211, 153, 0.85); color: #34d399; }
}

/* =========================================================================
   Landing
   ========================================================================= */

.landing {
  min-height: calc(100vh - var(--header-h));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  padding: 28px 20px 40px;
}

.hero-title {
  font-family: "Orbitron", "Inter", sans-serif;
  letter-spacing: 0.6px;
  font-size: clamp(28px, 5vw, 46px);
  line-height: 1.1;
  margin: 0;
  background: linear-gradient(125deg, #0d1830 0%, #4f46e5 55%, #06b6d4 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.landing p {
  max-width: 560px;
  color: var(--ink-3);
  font-size: clamp(14px, 1.6vw, 17px);
  margin: 0;
  line-height: 1.55;
}

/* =========================================================================
   Cards & shells
   ========================================================================= */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 18px;
}

.workspace-shell {
  height: calc(100vh - var(--header-h) - 20px);
}

/* =========================================================================
   Buttons & inputs
   ========================================================================= */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface-strong);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
  line-height: 1.1;
  user-select: none;
  white-space: nowrap;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.button:active {
  transform: translateY(0);
}

.button:focus-visible {
  outline: 2px solid var(--accent-indigo);
  outline-offset: 2px;
}

.button.primary {
  background: var(--gradient-primary);
  border-color: transparent;
  color: #ffffff;
  font-weight: 700;
  box-shadow: var(--shadow-glow);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.10);
}

.button.primary:hover {
  box-shadow: 0 12px 28px rgba(99, 102, 241, 0.36);
}

.button.warn {
  background: linear-gradient(135deg, #fff1f2, #ffe4e6);
  color: #9f1239;
  border-color: #fecdd3;
}

.button.warn:hover {
  background: linear-gradient(135deg, #ffe4e6, #fecdd3);
}

.button.ghost {
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink-2);
}

.button.ghost:hover {
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink-1);
}

.button.big {
  padding: 16px 22px;
  font-size: 16px;
  border-radius: var(--radius-md);
}

.button.icon {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 16px;
  border-radius: var(--radius-sm);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--ink-1);
  background: rgba(255, 255, 255, 0.92);
  font-family: inherit;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-muted);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent-indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
  background: #ffffff;
}

textarea {
  resize: vertical;
  min-height: 60px;
  line-height: 1.45;
}

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

.hint {
  font-size: 12px;
  color: var(--ink-3);
  white-space: pre-line;
}

.error {
  color: var(--accent-danger);
  font-size: 13px;
  margin-top: 6px;
}

/* =========================================================================
   Page shells
   ========================================================================= */

.client-page,
.admin-page {
  padding: 12px;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 10px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.chat-header > div {
  flex: 1 1 0;
  min-width: 0;
}

.chat-header h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0.2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-header #client-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#active-chat-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
}

#active-chat-title {
  font-weight: 700;
  color: var(--ink-1);
  font-size: 15px;
  letter-spacing: 0.2px;
}

.chat-header.muted #active-chat-title {
  color: var(--ink-muted);
  font-weight: 600;
}

/* =========================================================================
   Messages
   ========================================================================= */

.messages {
  background: linear-gradient(180deg, rgba(247, 250, 255, 0.45), rgba(241, 245, 255, 0.6));
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  height: 100%;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.messages::-webkit-scrollbar {
  width: 8px;
}

.messages::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
}

.msg {
  max-width: 62%;
  padding: 10px 12px;
  border-radius: 14px;
  white-space: pre-line;
  word-wrap: break-word;
  font-size: 13px;
  line-height: 1.45;
  width: fit-content;
  display: inline-block;
  box-shadow: var(--shadow-sm);
  animation: msgPop 0.18s ease-out both;
}

@keyframes msgPop {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg.client {
  margin-left: auto;
  background: linear-gradient(135deg, #6366f1 0%, #22d3ee 100%);
  color: #ffffff;
  border: 1px solid transparent;
  border-bottom-right-radius: 6px;
}

.msg.client .meta {
  color: rgba(255, 255, 255, 0.85);
}

.msg.client a {
  color: #ffffff;
  text-decoration: underline;
}

.msg.admin {
  background: #ffffff;
  color: var(--ink-1);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}

.msg.system {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px dashed #f59e0b;
  color: #78350f;
}

.msg.priority {
  border: 1px solid #fb923c;
  box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.20);
}

.msg .meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--ink-muted);
  letter-spacing: 0.2px;
}

.msg-image {
  max-width: min(320px, 100%);
  max-height: 320px;
  border-radius: 10px;
  margin-top: 6px;
  object-fit: contain;
  display: block;
  cursor: zoom-in;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* =========================================================================
   Composer
   ========================================================================= */

.send-form {
  display: grid;
  gap: 8px;
  position: sticky;
  bottom: 0;
  padding-top: 8px;
  background: linear-gradient(180deg, rgba(244, 247, 255, 0), rgba(244, 247, 255, 0.96) 40%);
}

.send-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.composer-actions {
  border: 1px solid var(--line);
  background: var(--surface-strong);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  box-shadow: var(--shadow-sm);
}

.file-input-hidden {
  display: none;
}

.photo-button {
  font-weight: 600;
  min-width: 84px;
  text-align: center;
}

.send-button {
  min-width: 120px;
  font-weight: 700;
  margin-left: auto;
}

.selected-file-name {
  font-size: 11px;
  color: var(--ink-3);
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================================================
   Mobile nav (in workspaces)
   ========================================================================= */

.mobile-nav {
  display: none;
}

.mobile-only {
  display: none;
}

/* =========================================================================
   Admin & client layouts
   ========================================================================= */

.admin-layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) 320px;
  gap: 12px;
  align-items: stretch;
  height: 100%;
}

.client-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 270px;
  gap: 12px;
  align-items: stretch;
  height: 100%;
}

.admin-sidebar,
.admin-main,
.admin-tools,
.client-sidebar,
.client-main,
.client-tools {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 14px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.admin-main,
.client-main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  gap: 8px;
}

.admin-sidebar,
.admin-tools,
.client-sidebar,
.client-tools {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* =========================================================================
   Sidebar (chat list)
   ========================================================================= */

.toolbar {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.toolbar input {
  margin-bottom: 0;
}

.status-box {
  background: linear-gradient(140deg, rgba(99, 102, 241, 0.08), rgba(34, 211, 238, 0.08));
  border: 1px solid rgba(99, 102, 241, 0.18);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 13px;
  margin: 12px 0;
  white-space: pre-line;
  color: var(--ink-2);
  line-height: 1.45;
}

.chat-list {
  height: 100%;
  overflow: auto;
  margin-top: 8px;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.chat-list::-webkit-scrollbar {
  width: 6px;
}

.chat-list::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
}

.chat-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  background: var(--surface-strong);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.chat-item:hover {
  border-color: var(--accent-indigo);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.chat-item strong {
  font-family: "Orbitron", "Inter", sans-serif;
  letter-spacing: 0.4px;
  color: var(--ink-1);
  font-size: 13px;
}

.chat-preview {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  line-height: 1.4;
  min-height: 2.7em;
  margin-top: 4px;
}

.draft-preview {
  margin-top: 6px;
  margin-bottom: 4px;
  font-size: 11px;
  color: #78350f;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid #f59e0b;
  border-radius: 6px;
  padding: 4px 8px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.chat-item.active {
  border-color: var(--accent-indigo);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.10), rgba(34, 211, 238, 0.08));
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.20), var(--shadow-sm);
}

.chat-item.pending-urgent {
  border-color: #fb923c;
  box-shadow: inset 0 0 0 1px rgba(251, 146, 60, 0.40);
}

.tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: var(--radius-pill);
  padding: 3px 8px;
  margin-left: 6px;
  vertical-align: middle;
}

.tag.warn {
  background: linear-gradient(135deg, #fed7aa, #fdba74);
  color: #7c2d12;
}

.banner {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid #f59e0b;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 13px;
  color: #78350f;
}

.draft {
  margin-top: 6px;
  min-height: 64px;
  background: linear-gradient(180deg, #fffdf6, #fef3c7);
  border-color: #fde68a;
}

.draft:focus {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

/* =========================================================================
   Tools panel header
   ========================================================================= */

.tools-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 8px;
}

.tools-header h3 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.2px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-1);
}

.tools-header h3::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 18px;
  border-radius: 3px;
  background: var(--gradient-primary);
}

.tools-content {
  display: grid;
  gap: 14px;
  overflow: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.tools-content::-webkit-scrollbar {
  width: 6px;
}

.tools-content::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
}

.admin-layout.tools-collapsed {
  grid-template-columns: 290px minmax(0, 1fr) 64px;
}

.admin-layout.tools-collapsed .admin-tools,
.client-layout.tools-collapsed .client-tools {
  padding: 12px 8px;
}

.admin-layout.tools-collapsed .tools-header,
.client-layout.tools-collapsed .tools-header {
  justify-content: center;
}

.admin-layout.tools-collapsed .tools-header h3,
.client-layout.tools-collapsed .tools-header h3 {
  display: none;
}

.admin-layout.tools-collapsed .tools-header .button,
.client-layout.tools-collapsed .tools-header .button {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.client-layout.tools-collapsed {
  grid-template-columns: 250px minmax(0, 1fr) 64px;
}

/* =========================================================================
   QUICK ANSWERS — modern card design
   ========================================================================= */

.qa-section {
  display: grid;
  gap: 12px;
}

.qa-search {
  position: relative;
}

.qa-search input {
  margin-bottom: 0;
  padding-left: 36px;
}

.qa-search::before {
  content: "🔎";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  pointer-events: none;
  opacity: 0.7;
}

.qa-create-toggle {
  display: flex;
  width: 100%;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border-style: dashed;
  background: rgba(99, 102, 241, 0.06);
  color: var(--accent-indigo);
  border-color: rgba(99, 102, 241, 0.35);
}

.qa-create-toggle:hover {
  background: rgba(99, 102, 241, 0.10);
}

.script-create-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: linear-gradient(140deg, rgba(99, 102, 241, 0.06), rgba(34, 211, 238, 0.05));
  border: 1px solid rgba(99, 102, 241, 0.18);
  border-radius: var(--radius-md);
}

.icon-field {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: start;
  gap: 8px;
}

.icon-field input,
.icon-field textarea {
  margin-bottom: 0;
}

.field-icon {
  width: 32px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  font-size: 16px;
  color: var(--accent-indigo);
}

.script-create-form textarea {
  min-height: 78px;
}

.script-create-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.scripts-list {
  display: grid;
  gap: 10px;
  max-height: none;
  overflow: visible;
  margin-bottom: 0;
}

.script-row {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 12px 10px;
  background: var(--surface-strong);
  transition: border-color 0.15s ease, box-shadow 0.18s ease, transform 0.15s ease;
  display: grid;
  gap: 8px;
}

.script-row:hover {
  border-color: var(--accent-indigo);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.script-row.editing {
  border-color: var(--accent-amber);
  background: linear-gradient(140deg, #fffaf0, #fff7ed);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}

.script-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}

.script-topic {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-1);
  background: var(--gradient-soft);
  border: 1px solid rgba(99, 102, 241, 0.20);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.script-topic::before {
  content: "📌";
  font-size: 12px;
}

.script-order {
  display: inline-flex;
  gap: 4px;
}

.script-order .button {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 14px;
  border-radius: 8px;
}

.script-body-wrap {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
  white-space: pre-line;
  background: rgba(247, 250, 255, 0.6);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
}

.script-body-wrap.collapsed {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.script-body-wrap:hover {
  border-color: var(--accent-indigo);
}

.script-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.script-actions .send-btn {
  flex: 1;
  min-width: 130px;
  padding: 9px 12px;
  font-size: 13px;
}

.script-actions .icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 15px;
  border-radius: var(--radius-sm);
}

.script-actions .icon-btn.danger {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fff1f2;
}

.script-actions .icon-btn.danger:hover {
  background: #fee2e2;
}

.script-actions .button[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.script-edit-form {
  display: grid;
  gap: 8px;
}

.script-edit-form input,
.script-edit-form textarea {
  margin-bottom: 0;
}

.script-edit-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.scripts-empty {
  text-align: center;
  color: var(--ink-muted);
  padding: 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  font-size: 13px;
}

/* =========================================================================
   Inline forms & exports
   ========================================================================= */

.inline-form {
  display: flex;
  gap: 8px;
}

.inline-form input {
  margin-bottom: 0;
}

.tools-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

.tools-section h3 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tools-section h3::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 14px;
  border-radius: 2px;
  background: var(--gradient-primary);
}

.xls-result {
  max-height: 28vh;
  overflow: auto;
  font-size: 12px;
  white-space: pre-line;
  padding: 8px;
  background: rgba(247, 250, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
}

/* =========================================================================
   Login & register cards
   ========================================================================= */

.login-card,
#register-card {
  max-width: 460px;
  margin: 40px auto;
  padding: 28px;
}

.login-card h2,
#register-card h3 {
  margin: 0 0 18px;
  background: linear-gradient(120deg, #1e3a8a, #6366f1, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-card form,
#register-card form {
  display: grid;
  gap: 8px;
}

/* =========================================================================
   Lightbox
   ========================================================================= */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 16, 32, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.lightbox-content {
  position: relative;
  z-index: 1;
  width: min(94vw, 1000px);
  height: min(88vh, 800px);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
  box-shadow: var(--shadow-lg);
}

.lightbox-content img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 0.12s ease;
}

.lightbox-controls {
  display: flex;
  justify-content: center;
  gap: 8px;
}

/* =========================================================================
   Responsive
   ========================================================================= */

@media (max-width: 1100px) {
  .admin-layout,
  .client-layout,
  .admin-layout.tools-collapsed,
  .client-layout.tools-collapsed {
    grid-template-columns: 1fr;
    height: auto;
  }

  .workspace-shell {
    height: auto;
  }
}

@media (max-width: 780px) {
  :root {
    --header-h: 56px;
  }

  html,
  body {
    overscroll-behavior: contain;
  }

  body {
    overflow: hidden;
  }

  .brand-header {
    padding: 10px 14px;
  }

  .client-page,
  .admin-page {
    padding: 0;
    height: calc(100dvh - var(--header-h));
    min-height: 0;
    overflow: hidden;
  }

  .workspace-shell {
    height: 100%;
    border-radius: 0;
  }

  .admin-layout,
  .client-layout,
  .admin-layout.tools-collapsed,
  .client-layout.tools-collapsed {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 0;
    height: 100%;
    min-height: 0;
  }

  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 10px 12px;
    background: rgba(244, 247, 255, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 6;
  }

  .mobile-nav .button {
    padding: 12px 8px;
    font-size: 13px;
    border-radius: var(--radius-sm);
    min-height: 44px;
  }

  .mobile-only {
    display: inline-flex;
  }

  .admin-sidebar,
  .admin-main,
  .admin-tools,
  .client-sidebar,
  .client-main,
  .client-tools {
    border-radius: 0;
    box-shadow: none;
    border: 0;
    padding: 12px;
    min-height: 0;
    background: transparent;
    backdrop-filter: none;
  }

  .admin-layout .admin-sidebar,
  .admin-layout .admin-main,
  .admin-layout .admin-tools,
  .client-layout .client-sidebar,
  .client-layout .client-main,
  .client-layout .client-tools {
    display: none;
  }

  .admin-layout[data-mobile-view="chats"] .admin-sidebar,
  .admin-layout[data-mobile-view="chat"] .admin-main,
  .admin-layout[data-mobile-view="tools"] .admin-tools,
  .client-layout[data-mobile-view="dialogs"] .client-sidebar,
  .client-layout[data-mobile-view="chat"] .client-main,
  .client-layout[data-mobile-view="tools"] .client-tools {
    display: grid;
    align-content: stretch;
    min-height: 0;
    height: 100%;
    overflow: hidden;
  }

  .admin-layout[data-mobile-view="dialogs"] .admin-sidebar,
  .admin-layout[data-mobile-view="tools"] .admin-tools,
  .client-layout[data-mobile-view="dialogs"] .client-sidebar,
  .client-layout[data-mobile-view="tools"] .client-tools {
    overflow-y: auto;
  }

  .admin-main,
  .client-main {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .chat-header {
    padding: 6px 4px 8px;
    gap: 8px;
  }

  .chat-header h2 {
    font-size: 15px;
  }

  .chat-header #client-meta,
  .chat-header .muted {
    font-size: 11px;
  }

  .messages {
    min-height: 0;
    height: 100%;
    border-radius: var(--radius-md);
    padding: 12px;
  }

  .msg {
    max-width: 86%;
    font-size: 14px;
    padding: 10px 12px;
  }

  .msg-image {
    max-width: min(240px, 100%);
    max-height: 240px;
  }

  .send-form textarea,
  #admin-message-input,
  #message-input {
    min-height: 76px;
    font-size: 15px;
    padding: 12px;
  }

  .send-actions {
    position: sticky;
    bottom: 0;
    background: rgba(244, 250, 255, 0.98);
    padding-top: 6px;
  }

  .send-actions .button {
    min-width: 100px;
    font-size: 14px;
    padding: 12px 14px;
    min-height: 44px;
  }

  .selected-file-name {
    max-width: 110px;
  }

  .chat-list {
    max-height: calc(100dvh - 240px);
  }

  .scripts-list {
    max-height: none;
  }

  .tools-content {
    gap: 12px;
    overflow: visible;
  }

  .inline-form {
    flex-direction: column;
    gap: 8px;
  }

  .lightbox-content {
    width: 96vw;
    height: 80vh;
    border-radius: var(--radius-md);
    padding: 8px;
  }

  .login-card,
  #register-card {
    margin: 16px auto;
    padding: 20px;
  }

  .script-actions .send-btn {
    flex: 1 0 100%;
  }

  .script-actions .icon-btn {
    flex: 0 0 auto;
  }
}

@media (max-width: 420px) {
  .msg {
    max-width: 92%;
  }

  .send-actions .button {
    min-width: 0;
    flex: 1;
  }

  .send-actions .photo-button {
    flex: 0 0 auto;
    min-width: 70px;
  }
}
