:root {
  --bg: #f2ecdf;
  --bg-soft: #fbf7ef;
  --panel: rgba(252, 248, 240, 0.84);
  --panel-strong: #fffdf8;
  --text: #211a14;
  --muted: #67594c;
  --line: rgba(50, 37, 20, 0.14);
  --shadow: 0 24px 60px rgba(54, 34, 12, 0.12);
  --accent: #8f2d1f;
  --accent-deep: #61170f;
  --accent-soft: #f3d3b9;
  --ok: #315a43;
  --warn: #7a3f18;
  --mono: "IBM Plex Mono", monospace;
  --body: "IBM Plex Sans", sans-serif;
  --display: "Fraunces", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--body);
  background:
    radial-gradient(circle at 20% 0%, rgba(143, 45, 31, 0.15), transparent 28%),
    radial-gradient(circle at 100% 20%, rgba(99, 58, 24, 0.14), transparent 30%),
    linear-gradient(180deg, #f7f0e3 0%, var(--bg) 54%, #eee6d6 100%);
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.15;
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.04) 1px, transparent 1px);
  background-size: 3px 3px, 5px 5px;
  mix-blend-mode: multiply;
}

.shell {
  width: min(1280px, calc(100% - 40px));
  margin: 28px auto 60px;
}

.hero {
  padding: 28px 0 22px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  font-family: var(--mono);
}

.hero h1,
.topbar h2,
.panel h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.hero h1 {
  font-size: clamp(40px, 6vw, 82px);
  line-height: 0.96;
  max-width: 720px;
}

.hero-copy {
  max-width: 720px;
  margin: 20px 0 0;
  font-size: 18px;
  line-height: 1.7;
  color: var(--muted);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.hero-meta span,
.session-badge {
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(10px);
  font-family: var(--mono);
  font-size: 12px;
}

.panel,
.metric-card {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
}

.warning {
  background: linear-gradient(135deg, rgba(248, 228, 204, 0.96), rgba(255, 243, 228, 0.96));
}

.panel-header,
.topbar,
.result-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.panel-description {
  max-width: 420px;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.stack-form,
.create-grid {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.create-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wide {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

label span {
  color: var(--text);
  font-weight: 600;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(44, 32, 20, 0.16);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  padding: 14px 16px;
  outline: none;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(143, 45, 31, 0.55);
  box-shadow: 0 0 0 4px rgba(143, 45, 31, 0.1);
  transform: translateY(-1px);
}

.primary-button,
.ghost-button,
.tab-button {
  border: 0;
  border-radius: 18px;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

.primary-button {
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff8f2;
  box-shadow: 0 14px 24px rgba(97, 23, 15, 0.22);
}

.ghost-button {
  padding: 11px 16px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  color: var(--text);
}

.primary-button:hover,
.ghost-button:hover,
.tab-button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.hidden {
  display: none !important;
}

.topbar {
  margin: 18px 0 16px;
}

.topbar-actions,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

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

.metric-grid-wide {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.metric-card {
  padding: 18px 20px;
}

.metric-card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-card strong {
  font-family: var(--display);
  font-size: clamp(30px, 3vw, 46px);
  line-height: 1;
}

.tab-row {
  display: flex;
  gap: 10px;
  margin: 14px 0;
}

.tab-row-wrap {
  flex-wrap: wrap;
}

.tab-button {
  padding: 12px 16px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.54);
  color: var(--muted);
}

.tab-button.active {
  color: var(--text);
  border-color: rgba(143, 45, 31, 0.22);
  background: linear-gradient(135deg, rgba(248, 216, 190, 0.95), rgba(255, 252, 248, 0.9));
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 940px;
}

th,
td {
  padding: 14px 10px;
  border-bottom: 1px solid rgba(44, 32, 20, 0.08);
  text-align: left;
  vertical-align: top;
}

thead th {
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.48);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
}

.status-active {
  color: var(--ok);
}

.status-used {
  color: var(--accent-deep);
}

.status-disabled {
  color: var(--warn);
}

.result-box {
  margin-top: 18px;
  padding: 18px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.56);
}

.result-box h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 22px;
}

.result-box textarea {
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
}

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

.nav-card {
  padding: 22px;
  text-align: left;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
  box-shadow: var(--shadow);
}

.nav-card strong {
  display: block;
  font-family: var(--display);
  font-size: 24px;
  margin-bottom: 8px;
}

.nav-card span {
  color: var(--muted);
  line-height: 1.6;
}

.inline-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-actions.compact .ghost-button {
  padding: 8px 12px;
}

.callout {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.48);
  color: var(--muted);
  line-height: 1.7;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 14px 16px;
  border-radius: 18px;
  color: #fff;
  background: rgba(33, 26, 20, 0.92);
  box-shadow: 0 18px 34px rgba(15, 10, 6, 0.22);
  animation: toast-in 220ms ease;
}

code {
  font-family: var(--mono);
}

.muted,
small {
  color: var(--muted);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 920px) {
  .shell {
    width: min(100% - 24px, 1280px);
    margin-top: 18px;
  }

  .hero h1 {
    font-size: 42px;
  }

  .metric-grid,
  .metric-grid-wide,
  .create-grid,
  .home-grid {
    grid-template-columns: 1fr;
  }

  .panel-header,
  .topbar,
  .result-head {
    flex-direction: column;
  }

  .tab-row {
    overflow-x: auto;
    padding-bottom: 2px;
  }
}
