:root {
  color-scheme: light;
  --page: #f7f8fb;
  --surface: #ffffff;
  --surface-soft: #f1f4f8;
  --ink: #162033;
  --muted: #667085;
  --line: #dbe2ec;
  --dark-blue: #14284a;
  --blue: #2388d1;
  --purple: #8065d8;
  --green: #2fa66a;
  --red: #e55d5d;
  --amber: #f4a126;
  --shadow: 0 18px 44px rgba(20, 40, 74, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

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

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  flex: 0 0 auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-rows: 68px 1fr;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1.1fr) minmax(220px, 1fr);
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);
}

.brand-group,
.project-heading,
.top-actions,
.composer,
.create-actions {
  display: flex;
  align-items: center;
}

.brand-group {
  gap: 10px;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 7px 15px 7px 15px;
  background: linear-gradient(135deg, var(--dark-blue), var(--blue));
  color: #fff;
  font-weight: 800;
}

.brand-group h1,
.create-header h2,
.panel-heading h2,
.start-card h2 {
  margin: 0;
  line-height: 1;
}

.brand-group h1 {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 24px;
}

.brand-group p,
.project-heading span,
.create-header span,
.panel-heading span,
.start-card p,
.empty-state p,
.response-card p,
.editable-card p,
.source-card p {
  color: var(--muted);
}

.brand-group p {
  margin: 3px 0 0;
  font-size: 12px;
}

.project-heading {
  justify-content: center;
  gap: 12px;
  min-width: 0;
}

.project-heading span {
  font-size: 13px;
}

.project-heading strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 17px;
}

.top-actions {
  justify-content: flex-end;
  gap: 8px;
}

.icon-button,
.nav-chip,
.material-button,
.send-button,
.mini-action,
.primary-action,
.secondary-action,
.create-tab,
.response-action {
  border: 0;
  cursor: pointer;
}

.icon-button,
.mini-action {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--dark-blue);
}

.nav-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: transparent;
  color: #586173;
  font-weight: 700;
}

.nav-chip.active {
  background: #edf4ff;
  color: var(--dark-blue);
}

.start-screen {
  display: grid;
  min-height: 0;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 12%, rgba(35, 136, 209, 0.1), transparent 22%),
    radial-gradient(circle at 86% 20%, rgba(128, 101, 216, 0.09), transparent 24%),
    var(--page);
}

.start-card {
  width: min(560px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
}

.eyebrow {
  display: block;
  margin-bottom: 9px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.start-card h2 {
  font-size: 30px;
}

.start-card p {
  margin: 12px 0 22px;
  line-height: 1.6;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(380px, 34%) minmax(560px, 1fr);
  min-height: 0;
}

.chat-panel,
.create-page {
  min-width: 0;
  min-height: 0;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-right: 1px solid var(--line);
  background: #fbfcfe;
}

.panel-heading,
.create-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
}

.panel-heading span,
.create-header span {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.panel-heading h2,
.create-header h2 {
  font-size: 20px;
}

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.chat-message {
  display: flex;
}

.chat-message p {
  max-width: 90%;
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  line-height: 1.48;
}

.chat-message.user {
  justify-content: flex-end;
}

.chat-message.user p {
  background: var(--dark-blue);
  color: #fff;
}

.chat-message.assistant p,
.response-card {
  border: 1px solid var(--line);
  background: #fff;
}

.response-card {
  width: min(94%, 560px);
  padding: 13px;
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(20, 40, 74, 0.06);
}

.response-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.response-card p {
  margin: 0;
  line-height: 1.5;
}

.response-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chat-note {
  width: min(94%, 560px);
  padding: 12px 13px;
  border: 1px solid #cfe0f6;
  border-radius: var(--radius);
  background: #f7fbff;
  color: var(--dark-blue);
  line-height: 1.45;
}

.unit-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.output-unit {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
  padding: 11px;
}

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

.unit-type {
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.unit-type.source {
  color: var(--green);
}

.output-unit h4 {
  margin: 0;
  font-size: 14px;
}

.output-unit p {
  margin-top: 5px;
}

.response-action {
  min-height: 34px;
  padding: 0 10px;
  border-radius: var(--radius);
  background: #edf4ff;
  color: var(--dark-blue);
  font-weight: 800;
}

.response-action.secondary {
  background: #f1f4f8;
  color: #586173;
}

.response-action.saved {
  background: #e8f7ef;
  color: #1d7d4c;
}

.chat-controls {
  display: grid;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.composer {
  gap: 8px;
}

.material-button,
.send-button,
.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: var(--radius);
  font-weight: 800;
}

.material-button {
  width: 42px;
  background: #edf4ff;
  color: var(--dark-blue);
}

.composer input {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: 0;
  padding: 0 12px;
  background: #fff;
}

.send-button,
.primary-action {
  background: var(--dark-blue);
  color: #fff;
}

.send-button {
  width: 42px;
}

.primary-action,
.secondary-action {
  padding: 0 12px;
}

.secondary-action {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--dark-blue);
}

.create-page {
  display: grid;
  grid-template-rows: auto auto 1fr;
  background: var(--page);
}

.create-actions {
  gap: 8px;
}

.create-tabs {
  display: flex;
  align-items: flex-end;
  gap: 0;
  padding: 12px 18px 0;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  overflow-x: auto;
}

.create-tab {
  --tab-color: var(--blue);
  min-height: 42px;
  margin: 0 -1px -1px 0;
  padding: 8px 15px 9px;
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  border-bottom-color: var(--line);
  background: #eef2f6;
  color: #586173;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: inset 0 4px 0 var(--tab-color);
}

.create-tab span {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  margin-left: 5px;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  font-size: 11px;
}

.create-tab.active {
  z-index: 2;
  border-bottom-color: #fff;
  background: #fff;
  color: var(--ink);
}

.create-tab.flash {
  animation: tabFlash 900ms ease;
}

@keyframes tabFlash {
  0%,
  100% {
    background: #fff;
  }
  45% {
    background: #dceeff;
  }
}

.tab-blue {
  --tab-color: var(--blue);
}

.tab-purple {
  --tab-color: var(--purple);
}

.tab-green {
  --tab-color: var(--green);
}

.tab-red {
  --tab-color: var(--red);
}

.tab-amber {
  --tab-color: var(--amber);
}

.create-body {
  min-height: 0;
  overflow: auto;
  padding: 20px;
  background: #fff;
}

.tab-pane {
  display: none;
  gap: 14px;
}

.tab-pane.active {
  display: grid;
}

.content-grid {
  display: grid;
  gap: 12px;
}

.empty-state {
  padding: 24px;
  border: 1px dashed #c8d2df;
  border-radius: var(--radius);
  background: #fbfcfe;
}

.empty-state h3 {
  margin: 0;
  font-size: 18px;
}

.empty-state p {
  margin: 7px 0 0;
}

.editable-card,
.source-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 8px 24px rgba(20, 40, 74, 0.06);
}

.editable-card {
  padding: 16px;
}

.editable-card.large {
  min-height: 240px;
}

.editable-card header {
  margin-bottom: 12px;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
}

.tool-button {
  display: inline-grid;
  min-width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  background: #fff;
  color: var(--dark-blue);
  cursor: pointer;
  font-weight: 800;
}

.tool-button:hover,
.tool-button.active {
  border-color: #bdd9ff;
  background: #edf4ff;
}

.tool-button.wide {
  display: inline-flex;
  width: auto;
  gap: 7px;
  padding: 0 10px;
}

.ai-edit-button {
  border-color: #bdd9ff;
  background: #edf4ff;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--line);
}

.card-kicker {
  display: inline-flex;
  margin-bottom: 7px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.card-kicker.purple {
  color: var(--purple);
}

.card-kicker.green {
  color: var(--green);
}

.card-kicker.red {
  color: var(--red);
}

.editable-card h3,
.source-card h3 {
  margin: 0;
  font-size: 17px;
}

.editable-card p,
.source-card p {
  margin: 7px 0 0;
  line-height: 1.55;
}

.essay-draft {
  display: grid;
  gap: 14px;
  line-height: 1.65;
}

.selection-callout-zone {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px dashed #bdd9ff;
  border-radius: var(--radius);
  background: #f7fbff;
}

.callout-zone-label {
  color: var(--dark-blue);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.selection-callout {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #bdd9ff;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 8px 22px rgba(20, 40, 74, 0.08);
  cursor: grab;
}

.selection-callout.dragging {
  opacity: 0.72;
  cursor: grabbing;
}

.selection-callout header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.selection-callout h4 {
  margin: 0;
  font-size: 14px;
}

.selection-callout p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.callout-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.essay-draft::selection,
.essay-draft *::selection {
  background: rgba(35, 136, 209, 0.22);
}

.essay-draft p {
  margin: 0;
}

.editable-sentence {
  border-left: 4px solid var(--purple);
  padding-left: 12px;
}

.applied-edit {
  animation: editPulse 900ms ease;
}

@keyframes editPulse {
  0%,
  100% {
    background: transparent;
  }
  45% {
    background: #edf4ff;
  }
}

.paper-outline {
  display: grid;
  gap: 13px;
  line-height: 1.52;
}

.paper-outline section {
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}

.paper-outline section:last-child {
  border-bottom: 0;
}

.paper-outline h4 {
  margin: 0 0 6px;
  color: var(--dark-blue);
  font-size: 15px;
}

.paper-outline p,
.paper-outline ul {
  margin: 0;
}

.paper-outline ul {
  padding-left: 20px;
}

.manual-paragraph {
  border-left: 4px solid var(--amber);
  padding-left: 12px;
}

.slide-deck {
  display: grid;
  gap: 14px;
}

.slide-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  box-shadow: 0 8px 24px rgba(20, 40, 74, 0.06);
}

.slide-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.slide-card h4 {
  margin: 0;
  font-size: 14px;
}

.slide-status {
  border-radius: 999px;
  padding: 4px 8px;
  background: #edf4ff;
  color: var(--dark-blue);
  font-size: 11px;
  font-weight: 800;
}

.slide-card img {
  display: block;
  width: 100%;
  height: auto;
}

[contenteditable="true"] {
  border-radius: 5px;
  outline: 0;
}

[contenteditable="true"]:focus {
  box-shadow: 0 0 0 3px rgba(35, 136, 209, 0.16);
  background: #f8fbff;
}

.editable-list {
  display: grid;
  gap: 11px;
}

label {
  display: flex;
  gap: 10px;
  line-height: 1.38;
}

input[type="checkbox"] {
  appearance: none;
  display: grid;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  margin: 0;
  place-items: center;
  border: 1px solid #c7d0dd;
  border-radius: 4px;
  background: #fff;
}

input[type="checkbox"]:checked {
  border-color: var(--blue);
  background: var(--blue);
}

input[type="checkbox"]:checked::after {
  content: "";
  width: 8px;
  height: 4px;
  border: solid #fff;
  border-width: 0 0 2px 2px;
  transform: rotate(-45deg);
}

label.done span {
  color: var(--muted);
  text-decoration: line-through;
}

.source-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
}

.source-dot {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin-top: 2px;
  border-radius: 50%;
}

.source-dot.blue {
  background: var(--blue);
}

.source-dot.green {
  background: var(--green);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 40;
  transform: translate(-50%, 18px);
  opacity: 0;
  max-width: min(460px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--dark-blue);
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 14px;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 68px;
    padding: 12px 16px;
  }

  .project-heading,
  .top-actions {
    justify-content: flex-start;
  }

  .app-shell {
    grid-template-rows: auto 1fr;
  }

  .workspace {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .chat-panel {
    min-height: 560px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .create-page {
    min-height: 640px;
  }
}
