:root {
  --bg: #fbfbfd;
  --bg-deep: #ffffff;
  --panel: rgba(255, 255, 255, 0.65);
  --panel-strong: rgba(255, 255, 255, 0.95);
  --panel-soft: rgba(245, 245, 247, 0.6);
  --line: rgba(0, 0, 0, 0.06);
  --line-strong: rgba(0, 0, 0, 0.12);
  --text: #1d1d1f;
  --text-soft: #86868b;
  --text-faint: #d2d2d7;
  --accent: #0071e3;
  --accent-hover: #0077ED;
  --accent-soft: rgba(0, 113, 227, 0.08);
  --success-bg: rgba(52, 199, 89, 0.12);
  --success-text: #248a3d;
  --text-secondary: #6e6e73;
  
  --shadow-float: 0 20px 40px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.02);
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.01);
  --shadow-btn: 0 4px 14px rgba(0, 113, 227, 0.3);
  --shadow-auth: 0 24px 50px rgba(0, 0, 0, 0.08), 0 2px 10px rgba(0, 0, 0, 0.04);
  
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  
  --font-ui: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  
  --blur: blur(40px) saturate(200%);
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: var(--font-ui);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: -0.015em;
  font-weight: 400;
  display: flex;
  flex-direction: column;
}

body.is-guest {
  background:
    radial-gradient(circle at 10% 18%, rgba(0, 113, 227, 0.05), transparent 32%),
    radial-gradient(circle at 88% 20%, rgba(120, 120, 128, 0.05), transparent 24%),
    #fbfbfd;
  background-attachment: fixed;
}

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

a {
  color: inherit;
  text-decoration: none;
}

h1, h2, h3, h4, p {
  margin: 0;
}

/* Base Headings */
h1, h2, h3, h4 {
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* =========================================
   Layout: Authenticated (Dashboard)
   ========================================= */
.page-shell {
  flex: 1;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 340px;
  gap: 32px;
  padding: 32px;
  max-width: 1800px;
  margin: 0 auto;
  width: 100%;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 32px;
}

.inspector {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar,
.topbar,
.chat-panel,
.inspector-card {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sidebar {
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  background: rgba(255,255,255,0.4);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: none;
  box-shadow: none;
}

.topbar {
  padding: 32px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  background: rgba(255,255,255,0.7);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.chat-panel {
  padding: 32px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(0,0,0,0.03);
  box-shadow: var(--shadow-float);
  background: #ffffff;
}

.inspector-card {
  padding: 28px;
  border: none;
  background: #ffffff;
  box-shadow: var(--shadow-card);
}

.timeline {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-top: 12px;
}

/* =========================================
   Layout: Guest (Landing Page)
   ========================================= */
body.is-guest .page-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 48px;
  align-items: start;
  padding: 56px 32px 40px;
  max-width: 1240px;
  margin: 0 auto;
  min-height: 100vh;
}

body.is-guest .sidebar {
  display: none;
}

body.is-guest .workspace {
  display: block;
  width: 100%;
}

body.is-guest .topbar {
  display: block;
  background: transparent;
  box-shadow: none;
  border: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 0 0 16px;
}

body.is-guest .chat-panel {
  background: transparent;
  box-shadow: none;
  border: none;
  padding: 0;
  width: 100%;
}

body.is-guest .chat-panel > .panel-header {
  display: none;
}

body.is-guest .timeline {
  overflow: visible;
  padding: 0;
  margin: 0;
}

/* The Landing Layout */
body.is-guest .landing-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 32px;
  align-items: start;
  width: 100%;
  padding: 16px 0 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

body.is-guest .landing-copy h3 {
  font-size: 56px;
  line-height: 1.02;
  letter-spacing: -0.04em;
  font-weight: 650;
  color: #111111;
  margin-bottom: 18px;
}

body.is-guest .landing-copy p {
  font-size: 17px;
  line-height: 1.58;
  color: var(--text-soft);
  max-width: 560px;
}

body.is-guest .landing-status {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 8px;
}

body.is-guest .feature-line {
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-top: 14px;
}

body.is-guest .feature-line h4 {
  font-size: 17px;
  font-weight: 600;
  margin: 6px 0 6px;
}

body.is-guest .feature-line p {
  font-size: 14px;
  color: var(--text-soft);
  line-height: 1.5;
}

/* Auth Card specifically for Guest layout */
body.is-guest .inspector {
  display: flex;
  align-self: stretch;
}

body.is-guest .auth-card {
  position: sticky;
  top: 48px;
  align-self: start;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  padding: 26px;
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

body.is-guest #profileCard,
body.is-guest #composerCard {
  display: none !important;
}

/* =========================================
   Typography & Elements
   ========================================= */
.topbar h2 {
  font-size: 36px;
  font-weight: 650;
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin-top: 0;
  max-width: 760px;
}

.topbar-subtitle {
  margin-top: 14px;
  font-size: 16px;
  color: var(--text-soft);
  max-width: 700px;
  line-height: 1.6;
}

.hero-sequence {
  margin-top: 18px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.78;
}

/* Brand Display */
.brand-block {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1d1d1f 0%, #434346 100%);
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

/* Labels */
.eyebrow,
.label {
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 24px;
  margin-bottom: 24px;
}

.panel-header.compact {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 20px;
}

.panel-header h3,
.inspector-card h3 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Timeline & History */
.plain-list {
  margin: 16px 0 0;
  padding-left: 0;
  list-style: none;
}

.plain-list li {
  position: relative;
  padding-left: 24px;
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-size: 15px;
}

.plain-list li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.history-item {
  width: 100%;
  text-align: left;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: #f5f5f7;
  transition: all 0.2s ease;
}

.history-item:hover {
  background: #ffffff;
  border-color: var(--line);
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}

.history-item h4 {
  margin-top: 4px;
  font-size: 16px;
  letter-spacing: -0.01em;
}

/* Forms & Inputs */
.stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 24px;
}

.section-title {
  padding-top: 24px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-top: 1px solid var(--line);
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.grid-three {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

input,
textarea {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: #f5f5f7;
  padding: 14px 16px;
  font-size: 15px;
  transition: all 0.2s ease;
}

input:hover,
textarea:hover {
  background: #ebebeb;
}

input:focus,
textarea:focus {
  background: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

/* Buttons */
.primary-button,
.secondary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px; /* Pill buttons */
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.primary-button {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-btn);
}

.primary-button:hover {
  background: var(--accent-hover);
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 8px 20px rgba(0, 113, 227, 0.4);
}

.primary-button:active {
  transform: scale(0.98);
}

.secondary-button {
  background: rgba(0,0,0,0.05);
  color: var(--text);
  font-weight: 500;
}

.secondary-button:hover {
  background: rgba(0,0,0,0.08);
}

.ghost-button {
  background: transparent;
  color: var(--accent);
}

.ghost-button:hover {
  background: var(--accent-soft);
}

.auth-primary {
  width: 100%;
  min-height: 56px;
  font-size: 17px;
}

.auth-lead {
  margin: 12px 0 18px;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.5;
}

.auth-checklist {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.auth-check {
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(246, 246, 248, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.05);
  line-height: 1.45;
}

.auth-check::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  background: url('data:image/svg+xml;utf8,<svg fill="%230071e3" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>') no-repeat center;
  background-size: contain;
  flex-shrink: 0;
}

/* Badges & Pills */
.pill,
.user-badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success-text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.helper {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
  margin-top: 12px;
}

.drop-zone {
  position: relative;
  transition: all 0.3s ease;
  border-radius: var(--radius-md);
}

.drop-zone.drag-active {
  box-shadow: 0 0 0 4px var(--accent) inset;
  background-color: var(--accent-soft);
  transform: scale(1.02);
}

.drop-zone.drag-active textarea {
  opacity: 0.5;
  pointer-events: none;
}

/* Documents Formatting */
.document-card {
  animation: fadeUp 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  background: #ffffff;
  padding: 32px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--line);
}

.doc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.doc-title {
  margin-top: 8px;
  font-size: 22px;
  font-weight: 600;
}

.document-card pre {
  margin: 24px 0 0;
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 14px;
  font-family: var(--font-mono);
  background: #f5f5f7;
  padding: 24px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0,0,0,0.04);
}

.doc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.hidden {
  display: none !important;
}

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

/* =========================================
   Responsive Breakpoints
   ========================================= */
@media (max-width: 1280px) {
  .page-shell {
    grid-template-columns: 280px minmax(0, 1fr);
  }
  
  .inspector {
    display: none; /* Hide inspector natively, or wrap into tabs ideally, but for now stack */
  }

  body.is-guest .landing-card {
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 40px;
  }

  body.is-guest .landing-copy h3 {
    font-size: 54px;
  }
}

@media (max-width: 960px) {
  .page-shell {
    grid-template-columns: 1fr;
    padding: 20px;
  }

  body.is-guest .landing-card {
    grid-template-columns: 1fr;
  }

  body.is-guest .page-shell {
    grid-template-columns: 1fr;
    gap: 28px;
    padding: 28px 20px;
  }

  body.is-guest .inspector {
    order: 1;
  }

  body.is-guest .workspace {
    order: 2;
  }

  body.is-guest .landing-copy h3 {
    font-size: 40px;
    text-align: left;
  }
  
  body.is-guest .landing-copy p {
    text-align: left;
    margin: 0;
  }
  
  body.is-guest .landing-status {
    text-align: left;
  }

  .topbar {
    flex-direction: column;
  }

  .chat-panel {
    padding: 24px;
  }
}

@media (max-width: 600px) {
  body.is-guest .page-shell {
    padding: 16px;
  }
  
  body.is-guest .auth-card {
    padding: 32px 24px;
  }

  .topbar h2,
  .landing-copy h3 {
    font-size: 32px;
  }

  .grid-two, .grid-three {
    grid-template-columns: 1fr;
  }
}
