:root {
  --brand-accent: #fa233b;
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --bg-main: #f5f5f7;
}

html {
  color-scheme: light;
}

html.dark {
  color-scheme: dark;
}

:root.dark {
  --text-primary: #f5f5f7;
  --text-secondary: #b6bcc6;
  --bg-main: #0f1115;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--text-primary);
  background: var(--bg-main);
}

a,
button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

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

.glass {
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  background: rgba(255, 255, 255, 0.72);
}

.dark .glass {
  background: rgba(15, 18, 26, 0.78);
  border-color: rgba(255, 255, 255, 0.08);
}

.app-frame {
  min-height: 100vh;
  display: flex;
  background: var(--bg-main);
}

.shell-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 16rem;
  border-right: 1px solid rgba(0, 0, 0, 0.05);
  padding: 1.5rem;
  display: none;
  overflow-x: hidden;
}

.shell-brand {
  margin-bottom: 2.5rem;
}

.shell-brand-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  border-radius: 0.75rem;
}

.shell-brand-button:hover {
  background: rgba(0, 0, 0, 0.05);
}

.dark .shell-brand-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.shell-brand-badge {
  display: flex;
  height: 2rem;
  width: 2rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: white;
  color: #1d1d1f;
  font-size: 11px;
  font-weight: 700;
}

.shell-brand-name {
  display: none;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.shell-nav {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: 1.5rem;
  margin-top: 0;
}

.shell-nav-group {
  display: block;
  min-width: 0;
}

.shell-nav-label {
  display: none;
  margin: 0;
  padding: 0 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #86868b;
}

.shell-nav-item {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  border: 0;
  border-radius: 0.75rem;
  background: rgba(0, 0, 0, 0.05);
  color: var(--brand-accent);
  white-space: nowrap;
  overflow: hidden;
}

.dark .shell-nav-item {
  background: rgba(255, 255, 255, 0.08);
}

.shell-nav-icon {
  width: 1.25rem;
  height: 1.25rem;
}

.shell-nav-icon svg,
.shell-icon-button svg,
.shell-mobile-nav-icon svg {
  width: 100%;
  height: 100%;
}

.shell-nav-text {
  display: none;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shell-main {
  flex: 1;
  min-width: 0;
  padding: 0 1rem 1rem;
}

.shell-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0 1rem;
  background: white;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.dark .shell-topbar {
  background: #151a22;
  border-bottom-color: rgba(255, 255, 255, 0.12);
}

.shell-topbar-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #1d1d1f;
}

.dark .shell-topbar-title {
  color: #f3f4f6;
}

.shell-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.shell-icon-button {
  position: relative;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.05);
  color: #4b5563;
  text-decoration: none;
}

.shell-icon-button:hover {
  background: rgba(0, 0, 0, 0.1);
}

.dark .shell-icon-button {
  background: rgba(255, 255, 255, 0.08);
  color: #c3cad5;
}

.dark .shell-icon-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.theme-icon {
  position: absolute;
  inset: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.shell-icon-button svg {
  width: 1rem;
  height: 1rem;
}

#theme-toggle svg {
  width: 1rem;
  height: 1rem;
}

html.dark .theme-icon-sun,
html:not(.dark) .theme-icon-moon {
  opacity: 0;
}

.workspace {
  padding-top: 4rem;
  display: grid;
  gap: 1.5rem;
}

.workspace-card,
.rail-card {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 1.5rem;
  background: white;
  padding: 1.5rem;
}

.dark .workspace-card,
.dark .rail-card {
  background: #151a22;
  border-color: rgba(255, 255, 255, 0.12);
}

.workspace-kicker {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-accent);
}

.composer-panel {
  margin-top: 1rem;
  border-radius: 1rem;
  background: #f3f4f7;
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 1.25rem;
}

.dark .composer-panel {
  background: #11151d;
  border-color: rgba(255, 255, 255, 0.1);
}

.composer-copy h2,
.report-header h2,
.rail-card h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.composer-note,
.report-note {
  margin: 0.5rem 0 0;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

textarea {
  width: 100%;
  margin-top: 1rem;
  min-height: 7.5rem;
  resize: vertical;
  border-radius: 1rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: white;
  color: var(--text-primary);
  padding: 0.875rem 1rem;
  line-height: 1.55;
}

.dark textarea {
  background: #151a22;
  border-color: rgba(255, 255, 255, 0.12);
}

.composer-actions {
  margin-top: 0.875rem;
  display: flex;
  justify-content: flex-end;
}

.run-button,
.copy-button {
  border: 0;
  border-radius: 0.875rem;
  background: #1d1d1f;
  color: white;
  font-weight: 700;
  padding: 0.75rem 1rem;
}

.dark .run-button,
.dark .copy-button {
  background: #f5f5f7;
  color: #111315;
}

.report-panel {
  margin-top: 1.5rem;
}

.report-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.875rem;
}

.report-body {
  min-height: 26rem;
  border-radius: 1rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #f8f9fb;
  padding: 1.25rem;
  line-height: 1.6;
  overflow: auto;
}

.dark .report-body {
  background: #11151d;
  border-color: rgba(255, 255, 255, 0.12);
}

.workspace-rail {
  display: grid;
  gap: 1rem;
}

.metrics-grid {
  margin-top: 0.875rem;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-card {
  border-radius: 1rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #f8f9fb;
  padding: 0.875rem;
}

.dark .metric-card {
  background: #11151d;
  border-color: rgba(255, 255, 255, 0.12);
}

.metric-card strong,
.metric-card span {
  display: block;
}

.metric-card strong {
  font-size: 1.375rem;
  font-weight: 700;
}

.metric-card span {
  margin-top: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.stack-list {
  list-style: none;
  margin: 0.875rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.stack-list li {
  border-radius: 1rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #f8f9fb;
  padding: 0.875rem;
}

.dark .stack-list li {
  background: #11151d;
  border-color: rgba(255, 255, 255, 0.12);
}

.stack-list li strong {
  display: block;
  font-weight: 700;
}

.stack-list li span,
.stack-list li small {
  display: block;
  margin-top: 0.35rem;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-wrap;
}

.history-item {
  padding: 0;
}

.history-button {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 0.875rem;
}

.report-body h1 {
  margin: 0 0 1rem;
  font-size: 1.75rem;
  line-height: 1.1;
}

.report-body h3 {
  margin: 1.5rem 0 0.625rem;
  padding-top: 1rem;
  font-size: 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.dark .report-body h3 {
  border-top-color: rgba(255, 255, 255, 0.12);
}

.report-body p {
  margin: 0.5rem 0;
}

.report-body .bullet {
  position: relative;
  padding-left: 1rem;
}

.report-body .bullet::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.7rem;
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 999px;
  background: var(--brand-accent);
}

.report-body .numbered {
  font-weight: 650;
}

pre {
  margin: 0.875rem 0 0;
  line-height: 1.55;
  overflow: auto;
  white-space: pre-wrap;
}

.shell-mobile-nav {
  position: fixed;
  inset: auto 0 0;
  z-index: 50;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(17, 19, 21, 0.9);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.shell-mobile-nav-grid {
  display: grid;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem max(0.35rem, env(safe-area-inset-bottom));
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

.shell-mobile-nav-item {
  height: 3.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  border: 0;
  border-radius: 0.75rem;
  background: rgba(250, 35, 59, 0.12);
  color: var(--brand-accent);
}

.shell-mobile-nav-icon {
  width: 22px;
  height: 22px;
}

.shell-mobile-nav-text {
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.dark .shell-brand-badge {
  background: #151a22;
  border-color: rgba(255, 255, 255, 0.12);
  color: #f3f4f6;
}

.dark .workspace-card,
.dark .rail-card,
.dark textarea,
.dark .report-body,
.dark .metric-card,
.dark .stack-list li {
  color: var(--text-primary);
}

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 10px;
}

.dark ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
}

@media (min-width: 768px) {
  .shell-sidebar {
    display: flex;
    flex-direction: column;
    width: 5rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .shell-brand-button {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }

  .shell-main {
    margin-left: 5rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    padding-bottom: 1.5rem;
  }

  .shell-topbar {
    left: 5rem;
    height: 3.5rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  .workspace {
    padding-top: 5rem;
  }

  .shell-mobile-nav {
    display: none;
  }
}

@media (min-width: 1024px) {
  .shell-sidebar {
    width: 16rem;
    padding: 1.5rem;
  }

  .shell-brand {
    margin-bottom: 2rem;
  }

  .shell-nav {
    margin-top: 0;
    align-content: start;
  }

  .shell-main {
    margin-left: 16rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  .shell-topbar {
    left: 16rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  .shell-brand-name,
  .shell-nav-label,
  .shell-nav-text {
    display: inline;
  }

  .shell-brand-button {
    justify-content: flex-start;
    padding-left: 1rem;
    padding-right: 1rem;
    padding-top: 0.625rem;
    padding-bottom: 0.625rem;
  }

  .shell-nav-item {
    justify-content: flex-start;
    width: 100%;
  }

  .shell-nav-text {
    display: inline-block;
    flex: 1 1 auto;
    min-width: 0;
  }

  .workspace {
    grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
    align-items: start;
  }
}
