:root {
  color-scheme: light;
  --page: #f6efe1;
  --page-strong: #efe4cf;
  --ink: #1b1916;
  --muted: #685f54;
  --line: rgba(33, 28, 21, 0.14);
  --panel: rgba(255, 250, 240, 0.84);
  --shadow: 0 22px 60px rgba(55, 39, 21, 0.12);
  --accent: #8a2f2b;
  --accent-soft: rgba(138, 47, 43, 0.14);
  --success: #2d6952;
  --error: #982b34;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(198, 218, 199, 0.5), transparent 34%),
    radial-gradient(circle at 90% 10%, rgba(199, 206, 232, 0.45), transparent 30%),
    linear-gradient(180deg, #f9f4eb 0%, #efe4d4 100%);
}

.cardloom-app {
  position: relative;
  min-height: 100vh;
  padding-bottom: 2rem;
}

.backdrop {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(122, 108, 91, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(122, 108, 91, 0.08) 1px, transparent 1px);
  background-size: 3.5rem 3.5rem;
  mask-image: radial-gradient(circle at center, rgba(0, 0, 0, 0.9), transparent 80%);
  pointer-events: none;
}

.topbar,
.masthead,
.workspace {
  position: relative;
  z-index: 1;
  padding-left: clamp(1.25rem, 3vw, 3rem);
  padding-right: clamp(1.25rem, 3vw, 3rem);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding-top: 1.35rem;
}

.home-lockup,
.toolbar-pill,
.account-menu summary,
.account-menu button {
  border: 1px solid rgba(64, 49, 34, 0.14);
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
}

.home-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.9rem;
}

.home-lockup img {
  width: 1.45rem;
  height: 1.45rem;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.toolbar-pill,
.account-menu summary,
.account-menu button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1rem;
}

.toolbar-pill--accent,
.account-menu button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff8f2;
}

.account-menu {
  position: relative;
}

.account-menu summary {
  list-style: none;
}

.account-menu summary::-webkit-details-marker {
  display: none;
}

.account-menu[open] .account-menu__panel {
  display: grid;
}

.account-menu__panel {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  width: 15rem;
  gap: 0.5rem;
  padding: 0.9rem;
  border-radius: 1rem;
  border: 1px solid rgba(64, 49, 34, 0.14);
  background: rgba(255, 250, 240, 0.96);
  box-shadow: 0 18px 45px rgba(55, 39, 21, 0.14);
}

.account-menu__panel span {
  color: var(--muted);
  font-size: 0.92rem;
}

.account-menu__panel form {
  margin: 0;
}

.masthead {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  padding-top: 1.2rem;
  padding-bottom: 1.45rem;
}

.brand {
  max-width: 46rem;
}

.brand h1,
.panel__header h2,
.stage-toolbar h2,
.summary-card h3,
.proof-card__headline {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.brand h1 {
  font-size: clamp(2.8rem, 5vw, 4.6rem);
}

.brand p,
.mapping-group__header p,
.summary-card p,
.footnote {
  margin: 0.55rem 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.brand__eyebrow,
.kicker,
.stat-label {
  display: block;
  margin-bottom: 0.45rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--muted);
}

.masthead__chips,
.toolbar-actions {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.chip,
.ghost-button,
.export-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.7rem 1rem;
  font: inherit;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.chip,
.ghost-button {
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

.chip:hover,
.ghost-button:hover,
.export-button:hover,
.home-lockup:hover,
.toolbar-pill:hover,
.account-menu summary:hover,
.account-menu button:hover {
  transform: translateY(-1px);
}

.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff8f2;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(18rem, 20rem) minmax(0, 1fr) minmax(18rem, 22rem);
  gap: 1rem;
}

.panel,
.stage-shell {
  border: 1px solid rgba(69, 53, 31, 0.12);
  border-radius: 1.7rem;
  background: var(--panel);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.panel {
  padding: 1.1rem;
}

.panel--rail,
.panel--inspector {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel__header {
  padding: 0.25rem 0.1rem 0;
}

.dropzone {
  display: grid;
  gap: 0.35rem;
  padding: 1.3rem;
  border-radius: 1.2rem;
  border: 1.4px dashed rgba(77, 56, 40, 0.32);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.62), rgba(246, 236, 220, 0.85)),
    linear-gradient(90deg, rgba(138, 47, 43, 0.12), rgba(43, 109, 82, 0.06));
  color: var(--muted);
  cursor: pointer;
}

.dropzone input {
  display: none;
}

.dropzone strong {
  color: var(--ink);
}

.dataset-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.dataset-stats > div,
.summary-card {
  padding: 0.95rem;
  border-radius: 1.15rem;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(69, 53, 31, 0.08);
}

.dataset-stats strong {
  font-size: 1.25rem;
}

.mapping-group,
.inspector-section {
  display: grid;
  gap: 0.85rem;
}

.field-grid label,
.inspector-section label {
  display: grid;
  gap: 0.35rem;
}

.field-grid span,
.inspector-section span {
  font-size: 0.9rem;
}

input,
select,
.toggle {
  font: inherit;
}

input[type="text"],
select {
  width: 100%;
  border: 1px solid rgba(64, 49, 34, 0.18);
  border-radius: 0.9rem;
  padding: 0.72rem 0.85rem;
  background: rgba(255, 255, 255, 0.82);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.75rem 0.85rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(64, 49, 34, 0.12);
  background: rgba(255, 255, 255, 0.72);
}

.stage-shell {
  padding: 1rem;
  display: grid;
  gap: 1rem;
}

.stage-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.paper-stage {
  position: relative;
  overflow: hidden;
  min-height: 39rem;
  padding: 1.5rem;
  border-radius: 1.5rem;
  background:
    linear-gradient(180deg, rgba(245, 237, 224, 0.95), rgba(234, 223, 206, 0.98)),
    linear-gradient(45deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0));
  border: 1px solid rgba(71, 58, 44, 0.1);
}

.paper-stage::before,
.paper-stage::after {
  content: "";
  position: absolute;
  inset: 1rem;
  border: 1px solid rgba(83, 65, 47, 0.16);
  pointer-events: none;
}

.paper-stage::after {
  inset: 1.4rem;
  border-style: dashed;
  border-color: rgba(83, 65, 47, 0.14);
}

.paper-stage__meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

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

.card-grid[data-density="labels"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.proof-card {
  position: relative;
  min-height: 10.8rem;
  padding: 1rem 1rem 1.1rem;
  border: 1px solid rgba(58, 43, 30, 0.14);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(255, 251, 245, 0.76)),
    linear-gradient(180deg, var(--accent-soft), transparent 34%);
  border-radius: 1.25rem;
  box-shadow: 0 16px 26px rgba(82, 64, 43, 0.08);
}

.proof-card::before,
.proof-card::after {
  content: "";
  position: absolute;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(58, 43, 30, 0.18);
  background: rgba(255, 248, 240, 0.85);
}

.proof-card::before {
  top: 0.55rem;
  right: 0.55rem;
}

.proof-card::after {
  bottom: 0.55rem;
  left: 0.55rem;
}

.proof-card__badge {
  display: inline-flex;
  max-width: 100%;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 0.68rem;
}

.proof-card__headline {
  margin: 0.9rem 0 0.45rem;
  font-size: 1.45rem;
  line-height: 1.04;
}

.proof-card__support,
.proof-card__detail {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.proof-card__detail {
  margin-top: 0.75rem;
  font-size: 0.92rem;
}

.summary-list {
  margin: 0.9rem 0 0;
  padding-left: 1rem;
  color: var(--muted);
}

.summary-list li + li {
  margin-top: 0.4rem;
}

.export-button {
  background: linear-gradient(135deg, var(--accent), #c05247);
  color: #fff9f3;
  font-weight: 600;
}

.export-button[disabled] {
  opacity: 0.58;
  cursor: wait;
}

.footnote.is-success {
  color: var(--success);
}

.footnote.is-error {
  color: var(--error);
}

[data-tone="spruce"] {
  --accent: #2d6952;
  --accent-soft: rgba(45, 105, 82, 0.14);
}

[data-tone="cobalt"] {
  --accent: #294ea7;
  --accent-soft: rgba(41, 78, 167, 0.14);
}

@media (max-width: 1280px) {
  .workspace {
    grid-template-columns: minmax(16rem, 18rem) minmax(0, 1fr);
  }

  .panel--inspector {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .panel--inspector .panel__header {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .panel--inspector {
    grid-template-columns: 1fr;
  }

  .paper-stage {
    min-height: 30rem;
  }
}

@media (max-width: 760px) {
  .topbar,
  .masthead,
  .stage-toolbar,
  .paper-stage__meta {
    flex-direction: column;
  }

  .topbar__actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .card-grid,
  .card-grid[data-density="labels"] {
    grid-template-columns: 1fr;
  }

  .dataset-stats {
    grid-template-columns: 1fr;
  }

  .paper-stage {
    min-height: auto;
    padding: 1rem;
  }
}
