: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: 18px;
}

* {
  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;
}

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;
}

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

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 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);
}

.topbar-start,
.brand-group,
.top-actions,
.composer {
  display: flex;
  align-items: center;
}

.topbar-start {
  justify-content: flex-start;
}

.brand-group {
  gap: 10px;
  justify-content: center;
}

.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,
.drawer-header h2,
.panel-heading h2,
.create-header h2 {
  margin: 0;
  line-height: 1;
}

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

.brand-group p,
.drawer-header p,
.panel-heading span,
.create-header span,
.editable-card p,
.source-card p {
  color: var(--muted);
}

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

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

.icon-button,
.material-button,
.send-button,
.mini-action,
.primary-action,
.secondary-action,
.create-tab {
  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);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  background: rgba(20, 40, 74, 0.18);
}

.drawer-backdrop.show {
  display: block;
}

.project-drawer {
  position: fixed;
  inset: 14px auto 14px 14px;
  z-index: 25;
  display: flex;
  width: min(330px, calc(100vw - 28px));
  flex-direction: column;
  border: 1px solid rgba(20, 40, 74, 0.12);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 28px 70px rgba(20, 40, 74, 0.24);
  transform: translateX(calc(-100% - 28px));
  transition: transform 180ms ease;
}

.project-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.drawer-list {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #586173;
  cursor: pointer;
  font-weight: 700;
  text-align: left;
}

.drawer-item.active,
.drawer-item:hover {
  background: #edf4ff;
  color: var(--dark-blue);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 34%) minmax(540px, 1fr);
  min-height: 0;
  width: 100%;
}

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

.chat-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #f2f6fc;
}

.panel-heading,
.create-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  background: #fff;
}

.panel-heading {
  position: relative;
  margin-right: -16px;
  padding-right: 34px;
  background: #e1ebf9;
  border-bottom: 1px solid rgba(20, 40, 74, 0.08);
}

.create-header {
  padding-inline: 60px;
  background: #fff;
}

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

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

.chat-message {
  display: flex;
}

.chat-message p {
  max-width: 88%;
  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: #dbe7f6;
  color: var(--ink);
}

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

.chat-controls {
  display: grid;
  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;
}

.composer input::placeholder {
  color: rgba(102, 112, 133, 0.48);
}

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

.send-button {
  width: 42px;
}

.create-page {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto 1fr;
  margin-left: -6px;
  border: 1px solid rgba(20, 40, 74, 0.08);
  border-right: 0;
  border-radius: 28px 0 0 28px;
  background: #fff;
  box-shadow: -2px 0 8px rgba(20, 40, 74, 0.04);
  overflow: hidden;
}

.create-page::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -24px;
  width: 36px;
  border-radius: 28px 0 0 28px;
  background: #fff;
  z-index: -1;
}

.create-header-main {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-width: 0;
  flex: 1;
}

.create-header-main::after {
  content: "";
  position: absolute;
  right: -60px;
  bottom: 0;
  left: -60px;
  height: 1px;
  background: var(--line);
}

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

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

.create-tabs {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  padding-top: 2px;
}

.create-tab {
  --tab-color: var(--blue);
  position: relative;
  min-width: 132px;
  min-height: 46px;
  margin: 0;
  padding: 11px 16px 12px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  background: #eef2f7;
  color: #586173;
  text-align: left;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: inset 0 3px 0 transparent;
}

.create-tab.active {
  z-index: 1;
  border-color: color-mix(in srgb, var(--tab-color) 35%, #ffffff);
  background: color-mix(in srgb, var(--tab-color) 22%, #ffffff);
  color: var(--ink);
  box-shadow: inset 0 3px 0 color-mix(in srgb, var(--tab-color) 65%, #ffffff);
}

.create-tab:not(.active):hover {
  background: #f4f7fb;
}

.create-tab-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 0;
  color: var(--dark-blue);
}

.create-tab-add svg {
  width: 16px;
  height: 16px;
}

.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: 14px 60px 18px;
  background: #fff;
}

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

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

.editable-card,
.source-card {
  border: 1px solid rgba(20, 40, 74, 0.08);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 4px 14px rgba(20, 40, 74, 0.04);
}

.editable-card.blue,
.source-card.blue {
  background: #edf4ff;
}

.editable-card.purple {
  background: #f2efff;
}

.editable-card.green,
.source-card.green {
  background: #edf8f1;
}

.editable-card.red {
  background: #fff0f0;
}

.editable-card {
  padding: 16px;
}

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

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

.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;
}

[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: center;
  gap: 12px;
  padding: 14px;
}

.source-dot {
  width: 18px;
  height: 18px;
  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: auto 1fr auto;
    height: auto;
    min-height: 68px;
    padding: 12px 16px;
  }

  .brand-group {
    justify-content: center;
  }

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

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

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

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