:root {
  --ink: #17313a;
  --muted: #667b82;
  --line: #dce7e9;
  --paper: #fbfdfc;
  --panel: #ffffff;
  --mist: #eef6f6;
  --blue: #2e8198;
  --blue-dark: #1e6478;
  --danger: #b64a42;
  --danger-soft: #fff2ef;
  --shadow: 0 24px 60px rgba(40, 74, 81, 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, rgba(152, 207, 213, 0.24), transparent 28rem),
    linear-gradient(135deg, #f8fbfa 0%, #f3f8f8 48%, #eef5f5 100%);
  font-family: "Segoe UI", sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }

.admin-header {
  min-height: 108px;
  padding: 22px clamp(20px, 5vw, 72px);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 28px;
  background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.admin-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-size: 24px;
  font-weight: 750;
}

.admin-brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--blue);
  background: var(--mist);
  font-size: 13px;
  letter-spacing: -2px;
  transform: rotate(90deg);
}

.header-copy h1,
.sidebar-heading h2,
.editor-toolbar h2,
.chat-admin-header h2 {
  margin: 2px 0 0;
  font-family: Georgia, serif;
  font-weight: 500;
}

.header-copy h1 { font-size: clamp(28px, 3vw, 42px); }
.eyebrow {
  margin: 0;
  color: var(--blue);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.site-link {
  padding: 11px 16px;
  color: var(--blue-dark);
  border: 1px solid #bfdbdf;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 650;
}

.admin-shell {
  width: min(1520px, calc(100% - 40px));
  margin: 26px auto 56px;
}

.notice {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #465d65;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  border-radius: 15px;
}

.notice p { margin: 0; }
.notice-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #68a78e;
  box-shadow: 0 0 0 6px rgba(104, 167, 142, 0.12);
}

.admin-tabs {
  margin-top: 26px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.tab-button {
  padding: 14px 18px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  cursor: pointer;
  font-weight: 700;
}

.tab-button.is-active {
  color: var(--blue-dark);
  border-bottom-color: var(--blue);
}

.count-badge {
  min-width: 24px;
  padding: 2px 7px;
  display: inline-block;
  border-radius: 999px;
  background: #dceced;
  font-size: 12px;
}

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.workspace-grid {
  min-height: 720px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 24px 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.page-sidebar {
  padding: 28px 20px;
  background: #f3f8f8;
  border-right: 1px solid var(--line);
}

.sidebar-heading { padding: 0 8px 20px; }
.sidebar-heading h2 { font-size: 25px; }
.page-list { display: grid; gap: 7px; }

.page-button {
  width: 100%;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
}

.page-button:hover { background: rgba(255, 255, 255, 0.75); }
.page-button.is-active {
  color: var(--blue-dark);
  background: #fff;
  border-color: #d7e7e9;
  box-shadow: 0 8px 20px rgba(46, 129, 152, 0.08);
  font-weight: 700;
}

.page-button span:last-child { color: #90a4aa; }
.sidebar-help {
  margin: 30px 8px 0;
  padding-top: 22px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.55;
}
.sidebar-help p { margin: 7px 0 0; }

.editor-area { min-width: 0; }
.editor-toolbar,
.chat-admin-header {
  padding: 22px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}
.editor-toolbar h2 { font-size: 28px; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 9px; }

.button {
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button-primary { color: #fff; background: var(--blue); }
.button-primary:hover { background: var(--blue-dark); }
.button-quiet { background: #f5f8f8; border-color: var(--line); }
.button-danger { color: #fff; background: var(--danger); }
.button-danger-quiet { color: var(--danger); background: var(--danger-soft); border-color: #f0d3ce; }

.selection-note {
  min-height: 42px;
  padding: 11px 26px;
  color: var(--muted);
  background: #fcfdfd;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.preview-frame-wrap {
  height: 640px;
  padding: 18px;
  background:
    linear-gradient(45deg, #eef3f3 25%, transparent 25%) 0 0 / 20px 20px,
    linear-gradient(-45deg, #eef3f3 25%, transparent 25%) 0 10px / 20px 20px,
    #f7f9f9;
}

#pagePreview {
  width: 100%;
  height: 100%;
  display: block;
  background: #fff;
  border: 1px solid #ccdadd;
  border-radius: 12px;
}

.chat-admin-header {
  margin-top: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-top: 0;
}
.chat-admin-header h2 { font-size: 32px; }
.chat-admin-header p:last-child { margin: 7px 0 0; color: var(--muted); }

.message-list {
  min-height: 420px;
  padding: 22px;
  display: grid;
  gap: 12px;
  align-content: start;
  background: #f5f9f9;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 22px 22px;
  box-shadow: var(--shadow);
}

.message-card {
  padding: 16px 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.message-meta { margin-bottom: 7px; color: var(--muted); font-size: 13px; }
.message-meta strong { color: var(--ink); }
.message-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.empty-state { padding: 70px 20px; text-align: center; color: var(--muted); }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: min(420px, calc(100% - 48px));
  padding: 13px 17px;
  color: #fff;
  background: var(--ink);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(23, 49, 58, 0.24);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 180ms ease;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: var(--danger); }

@media (max-width: 1050px) {
  .admin-header { grid-template-columns: auto 1fr; }
  .site-link { display: none; }
  .workspace-grid { grid-template-columns: 220px minmax(0, 1fr); }
  .editor-toolbar { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 760px) {
  .admin-header { min-height: 86px; padding: 16px 18px; gap: 14px; }
  .header-copy h1 { font-size: 25px; }
  .header-copy .eyebrow { display: none; }
  .admin-shell { width: min(100% - 20px, 1520px); margin-top: 14px; }
  .notice { align-items: flex-start; font-size: 13px; }
  .workspace-grid { display: block; }
  .page-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .page-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar-help { display: none; }
  .editor-toolbar, .chat-admin-header { padding: 18px; align-items: flex-start; flex-direction: column; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions .button { flex: 1 1 140px; }
  .preview-frame-wrap { height: 560px; padding: 10px; }
  .message-list { padding: 12px; }
  .message-card { grid-template-columns: 1fr; }
}
