:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #f0f3f6;
  --line: #d9dee7;
  --line-strong: #c4ccd8;
  --text: #18202f;
  --text-muted: #687385;
  --blue: #2563eb;
  --blue-soft: #e9efff;
  --teal: #0f766e;
  --teal-soft: #e6f5f2;
  --amber: #b45309;
  --amber-soft: #fff4df;
  --red: #b91c1c;
  --red-soft: #feecec;
  --green: #16794c;
  --green-soft: #e7f6ed;
  --shadow: 0 18px 45px rgba(16, 24, 40, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1180px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: var(--bg);
  padding: 32px;
}

.login-shell.is-hidden,
.app-shell.is-hidden,
.is-hidden {
  display: none;
}

.login-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-card h2 {
  margin: 12px 0 8px;
  font-size: 22px;
}

.login-card p {
  color: var(--text-muted);
  line-height: 1.5;
}

.login-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 16px 0;
}

.text-input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0 10px;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 284px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #fbfcfd;
  padding: 20px;
  overflow: auto;
}

.brand-block {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 22px;
}

.user-card {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px;
  margin-bottom: 14px;
}

.user-card strong {
  font-size: 13px;
}

.user-card span {
  color: var(--text-muted);
  font-size: 12px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--blue);
  font-weight: 800;
}

.brand-block h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.brand-block p,
.panel-header p,
.workspace-header p,
.bridge-step p {
  margin: 4px 0 0;
  color: var(--text-muted);
  line-height: 1.45;
}

.sidebar-section {
  margin-top: 24px;
}

.data-controls {
  display: grid;
  gap: 8px;
}

.data-status {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.35;
  padding: 8px 10px;
}

.oauth-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px;
}

.oauth-card a {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.oauth-code {
  margin-top: 8px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
  padding: 8px;
  text-align: center;
}

.oauth-hint {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.35;
  margin-top: 8px;
}

.section-heading {
  margin-bottom: 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-stack,
.requirement-list {
  display: grid;
  gap: 8px;
}

.status-item,
.requirement-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px;
  text-align: left;
}

.status-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.status-item strong,
.requirement-item strong {
  display: block;
  font-size: 13px;
}

.status-item span,
.requirement-item span {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

.requirement-item.is-active {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.workspace {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.workspace-header {
  display: flex;
  min-height: 92px;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 18px 24px;
}

.workspace-header h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.view {
  display: none;
  padding: 20px 24px 28px;
}

.view.is-active {
  display: block;
}

.layout-two {
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(560px, 1.15fr);
  gap: 18px;
}

.workbench-layout {
  grid-template-columns: minmax(560px, 1fr) minmax(560px, 0.92fr);
  transition: grid-template-columns 160ms ease;
}

.workbench-layout.is-spec-collapsed {
  grid-template-columns: minmax(720px, 1fr) 56px;
}

.layout-review {
  display: grid;
  grid-template-columns: minmax(680px, 1fr) 360px;
  gap: 18px;
}

.layout-library {
  display: grid;
  grid-template-columns: minmax(720px, 1fr) 360px;
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.panel-header h3 {
  margin: 0;
  font-size: 16px;
}

.primary-action,
.secondary-button,
.ghost-button {
  min-height: 36px;
  border-radius: var(--radius);
  padding: 0 13px;
  font-weight: 700;
  white-space: nowrap;
}

.primary-action {
  width: 100%;
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #ffffff;
}

.compact-action {
  width: auto;
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: var(--surface-muted);
  color: var(--text);
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.danger-button {
  border-color: #f1b8b8;
  color: var(--red);
}

.ghost-button.is-active {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}

.full-width {
  width: 100%;
}

.conversation-panel,
.spec-panel {
  min-height: 560px;
}

.spec-panel {
  min-width: 0;
  overflow: hidden;
}

.spec-panel.is-sidebar-collapsed .panel-header {
  align-items: center;
  justify-content: center;
  height: 100%;
  border-bottom: 0;
  padding: 10px;
}

.spec-panel.is-sidebar-collapsed .panel-header > div:first-child,
.spec-panel.is-sidebar-collapsed #copySpecButton,
.spec-panel.is-sidebar-collapsed .spec-body {
  display: none;
}

.spec-panel.is-sidebar-collapsed .header-actions {
  width: 100%;
  justify-content: center;
}

.spec-panel.is-sidebar-collapsed #toggleSpecButton {
  width: 36px;
  min-height: 128px;
  padding: 10px 0;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.conversation {
  display: grid;
  max-height: 300px;
  gap: 10px;
  overflow: auto;
  padding: 16px;
}

.message {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--surface-muted);
}

.message.is-user {
  border-color: #c9d7ff;
  background: var(--blue-soft);
}

.message strong {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
}

.message p {
  margin: 0;
  line-height: 1.5;
  white-space: pre-wrap;
}

.message-attachments,
.pending-attachments,
.reference-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.message-attachments {
  margin-top: 10px;
}

.reference-strip {
  min-height: 66px;
  border-top: 1px solid var(--line);
  background: #fbfcfd;
  padding: 10px 16px;
}

.reference-empty {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  font-size: 12px;
}

.attachment-thumb {
  position: relative;
  width: 72px;
  height: 50px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.attachment-thumb span {
  position: absolute;
  right: 4px;
  bottom: 3px;
  left: 4px;
  overflow: hidden;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
  white-space: nowrap;
}

.remove-attachment {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: rgba(24, 32, 47, 0.75);
  color: #ffffff;
  font-size: 12px;
  line-height: 16px;
  padding: 0;
}

.composer {
  border-top: 1px solid var(--line);
  padding: 16px;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  line-height: 1.5;
  padding: 10px 12px;
}

textarea:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.18);
  outline-offset: 1px;
}

.composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.pending-attachments {
  margin-top: 10px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 16px;
}

.library-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 16px 16px 0;
}

.library-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px 0;
}

.metric {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
  padding: 12px;
}

.metric span {
  display: block;
  font-size: 24px;
  font-weight: 800;
}

.metric small {
  color: var(--text-muted);
  font-weight: 700;
}

.screen-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
}

.spec-body.is-collapsed {
  display: none;
}

.team-list,
.team-form {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.team-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.team-card strong {
  display: block;
  margin-bottom: 4px;
}

.screen-tab {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 8px 10px;
  white-space: nowrap;
}

.screen-tab.is-active {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal);
  font-weight: 800;
}

.screen-detail {
  padding: 16px;
}

.screen-summary {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.badge,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.badge {
  border: 1px solid var(--line);
  background: var(--surface-muted);
  color: var(--text-muted);
}

.badge-green {
  border-color: #b7dec7;
  background: var(--green-soft);
  color: var(--green);
}

.tag {
  border: 1px solid var(--line);
  background: var(--surface-muted);
  color: var(--text-muted);
}

.tag-risk {
  border-color: #f5cf98;
  background: var(--amber-soft);
  color: var(--amber);
}

.tag-safe {
  border-color: #a8d8cf;
  background: var(--teal-soft);
  color: var(--teal);
}

.section-list,
.copy-list {
  display: grid;
  gap: 10px;
}

.copy-heading {
  margin-top: 16px;
}

.section-card,
.copy-card,
.principle-card,
.influence-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.section-card h4,
.copy-card h4,
.principle-card h4,
.influence-card h4,
.bridge-step h4 {
  margin: 0 0 6px;
  font-size: 14px;
}

.section-card p,
.copy-card p,
.principle-card p,
.influence-card p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.45;
}

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

.principle-card {
  display: grid;
  gap: 10px;
  align-content: start;
  background: #ffffff;
}

.principle-card strong,
.influence-card strong {
  display: block;
  color: var(--text);
  font-size: 12px;
  margin-bottom: 4px;
}

.principle-evidence {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-left: 18px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.influence-list {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.copy-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}

.copy-text {
  color: var(--text);
  white-space: pre-wrap;
}

.copy-key {
  margin-top: 6px;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.bridge-panel {
  margin-top: 18px;
}

.bridge-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 16px;
}

.bridge-step {
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
  padding: 14px;
}

.bridge-step span {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 800;
  margin-bottom: 14px;
}

.bridge-step.is-done {
  border-color: #a8d8cf;
  background: var(--teal-soft);
}

.prototype-panel,
.review-panel {
  min-height: 700px;
}

.prototype-stage {
  display: grid;
  min-height: 620px;
  place-items: center;
  background:
    linear-gradient(#eef1f5 1px, transparent 1px),
    linear-gradient(90deg, #eef1f5 1px, transparent 1px);
  background-color: #f9fafb;
  background-size: 24px 24px;
  padding: 24px;
}

.prototype-frame {
  width: 390px;
  min-height: 620px;
  border: 1px solid #c9d1df;
  border-radius: 28px;
  background: #ffffff;
  box-shadow: 0 22px 60px rgba(24, 32, 47, 0.18);
  overflow: hidden;
}

.phone-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 44px;
  border-bottom: 1px solid var(--line);
  padding: 0 18px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

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

.prototype-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 12px;
}

.prototype-section.is-warning {
  border-color: #f3c98d;
  background: var(--amber-soft);
}

.prototype-section.is-summary {
  background: #f8fbff;
}

.prototype-copy {
  display: block;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  padding: 4px;
  text-align: left;
  white-space: pre-wrap;
}

.prototype-copy:hover,
.prototype-copy.is-selected {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.prototype-copy.copy-title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
}

.prototype-copy.copy-body {
  color: var(--text-muted);
  line-height: 1.45;
}

.prototype-copy.copy-button {
  min-height: 40px;
  margin-top: 8px;
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
  font-weight: 800;
  text-align: center;
}

.prototype-copy.copy-secondary {
  min-height: 38px;
  margin-top: 8px;
  border-color: var(--line-strong);
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 800;
  text-align: center;
}

.prototype-copy.copy-label {
  color: var(--text);
  font-weight: 800;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin: 8px 0;
}

.review-panel {
  padding-bottom: 16px;
}

.review-panel .panel-header {
  margin-bottom: 16px;
}

.review-panel > *:not(.panel-header) {
  margin-left: 16px;
  margin-right: 16px;
}

.selected-copy {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
  padding: 10px;
  color: var(--text-muted);
  line-height: 1.45;
}

.field-label {
  display: block;
  margin-top: 14px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
}

.history-block {
  margin-top: 18px;
}

.history-list {
  display: grid;
  max-height: 230px;
  gap: 8px;
  overflow: auto;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}

.history-item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
}

.history-item p {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

.export-box {
  min-height: 620px;
  border: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 13px;
}

.code-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--text);
  color: #ffffff;
  padding: 10px 13px;
  box-shadow: var(--shadow);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0 10px;
}

@media (max-width: 1260px) {
  body {
    min-width: 1040px;
  }

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

  .workbench-layout {
    grid-template-columns: minmax(720px, 1fr) minmax(320px, 0.45fr);
  }

  .workbench-layout.is-spec-collapsed {
    grid-template-columns: minmax(720px, 1fr) 56px;
  }

  .bridge-grid,
  .principle-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
