*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg: #0b0f1a;
  --surface: rgba(20, 27, 44, 0.86);
  --surface-alt: rgba(22, 33, 58, 0.92);
  --text: #eef2ff;
  --muted: #a4b0cf;
  --accent: #5cff5c;
  --accent-strong: #7fff7f;
  --accent-lime: #5cff5c;
  --border: rgba(127, 177, 255, 0.2);
  --success: #6dd58c;
  --glass-bg: rgba(12, 18, 32, 0.6);
  --glass-border: rgba(127, 177, 255, 0.25);
  --glow-accent: rgba(92, 159, 255, 0.4);
  --glow-success: rgba(109, 213, 140, 0.3);
  --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 24px var(--glow-accent);
  --gradient-primary: linear-gradient(135deg, #2c4b90 0%, #1e3261 50%, #0f1a2e 100%);
  --gradient-accent: linear-gradient(135deg, #5c9fff 0%, #7fb1ff 50%, #9fc5ff 100%);
  --gradient-surface: linear-gradient(135deg, rgba(20, 27, 44, 0.95) 0%, rgba(22, 33, 58, 0.98) 100%);
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f5f7fb;
    --surface: rgba(255, 255, 255, 0.9);
    --surface-alt: rgba(238, 241, 250, 0.92);
    --text: #111526;
    --muted: #5a6789;
    --accent: #2c6bff;
    --accent-strong: #3f7dff;
    --border: rgba(16, 25, 46, 0.12);
    --success: #1e8f4d;
    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(16, 25, 46, 0.12);
  }
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: -20%;
  background: 
    radial-gradient(60% 40% at 20% 10%, rgba(92, 159, 255, 0.4), transparent 60%),
    radial-gradient(50% 35% at 80% 0%, rgba(127, 177, 255, 0.35), transparent 60%),
    radial-gradient(40% 35% at 50% 75%, rgba(115, 145, 255, 0.3), transparent 70%),
    radial-gradient(30% 30% at 50% 50%, rgba(109, 213, 140, 0.15), transparent 80%),
    linear-gradient(135deg, rgba(9, 14, 26, 0.9), rgba(5, 8, 16, 0.98));
  filter: blur(80px);
  opacity: 0.8;
  z-index: -2;
  animation: backgroundShift 20s ease-in-out infinite;
}

@keyframes backgroundShift {
  0%, 100% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(-2%, -2%) scale(1.05);
  }
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.08), transparent 55%);
  opacity: 0.4;
  z-index: -1;
  pointer-events: none;
}

main {
  padding: 0 1.25rem 4rem;
  display: grid;
  gap: 1.5rem;
}

/* Hide main content when landing page is active */
#landingHero:not([style*="display: none"]) ~ main,
#landingHero:not([style*="display: none"]) ~ header.app-topbar,
#landingHero:not([style*="display: none"]) ~ header.hero {
  display: none;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 12;
  display: grid;
  gap: 0.6rem;
  padding: calc(0.6rem + env(safe-area-inset-top)) 1.25rem 0.75rem;
  background: var(--glass-bg);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}

.app-topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--gradient-surface);
  opacity: 0.6;
  z-index: -1;
  border-radius: 0 0 1rem 1rem;
}

.app-topbar__title {
  font-weight: 600;
  letter-spacing: 0.04em;
}

.app-topbar__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tab-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 0.45rem 0.9rem;
  border-radius: 0.8rem;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  transition: border 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.tab-btn--active {
  color: var(--text);
  border-color: rgba(127, 177, 255, 0.4);
  background: rgba(127, 177, 255, 0.12);
  box-shadow: inset 0 -2px 0 rgba(127, 177, 255, 0.6);
}

.tab-panels {
  display: grid;
  gap: 1.5rem;
}

.tab-panel {
  display: none;
  gap: 1.5rem;
}

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

.hero {
  padding: 2.5rem 1.5rem 1.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #151e32, #0f1422);
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin: 0.5rem 0 0.75rem;
}

.hero p {
  margin: 0 0 1.5rem;
  color: var(--muted);
  max-width: 44rem;
}

.hero__tag {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.hero__status {
  margin-top: 0.75rem;
  color: var(--muted);
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.6rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s ease, border 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.btn:hover:enabled {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn--small {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.btn--primary {
  background: var(--gradient-primary);
  border-color: rgba(127, 177, 255, 0.5);
  box-shadow: 0 4px 16px rgba(92, 159, 255, 0.3);
  position: relative;
  overflow: hidden;
}

.btn--primary::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--gradient-accent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.btn--primary:hover::before {
  opacity: 0.2;
}

.btn--primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(92, 159, 255, 0.4);
}

.panel {
  background: var(--surface);
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  box-shadow: 0 12px 30px rgba(6, 9, 16, 0.35);
}

.panel__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
}

.panel__meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.panel__description {
  color: var(--muted);
  margin-bottom: 1rem;
}

.panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
  align-items: center;
}

.panel__status {
  margin-top: 0.5rem;
  color: var(--muted);
}

.panel--status {
  background: linear-gradient(140deg, #101827, #16213a);
}

.panel--flow {
  background: linear-gradient(140deg, #151e33, #101827);
}

.flow-chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 1fr);
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scroll-snap-type: x mandatory;
}

.flow-chart::-webkit-scrollbar {
  height: 6px;
}

.flow-chart::-webkit-scrollbar-thumb {
  background: rgba(127, 177, 255, 0.35);
  border-radius: 999px;
}

.flow-node {
  position: relative;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  min-height: 140px;
  display: grid;
  gap: 0.65rem;
  scroll-snap-align: start;
}

.flow-node__title {
  font-size: 1.05rem;
  margin: 0;
}

.flow-node__description {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.flow-node__action {
  justify-self: flex-start;
}

.flow-node::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -0.75rem;
  width: 0.75rem;
  height: 2px;
  background: var(--border);
}

.flow-node:last-child::after {
  display: none;
}

.status-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.status-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 0.9rem;
  display: grid;
  gap: 0.4rem;
}

.status-card__label {
  color: var(--muted);
  font-size: 0.85rem;
}

.status-card__value {
  font-size: 1rem;
  font-weight: 600;
}

.link-list {
  display: grid;
  gap: 0.75rem;
}

.link-item {
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.85rem;
  display: grid;
  gap: 0.4rem;
}

.link-item__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.input {
  width: 100%;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: #0b1220;
  padding: 0.65rem 0.75rem;
  color: var(--text);
  font-size: 0.9rem;
}

.input--compact {
  width: auto;
  min-width: 90px;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
}

input[type="file"].input {
  padding: 0.45rem 0.6rem;
}

.card-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card {
  padding: 1rem;
  border-radius: 0.9rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  display: grid;
  gap: 0.6rem;
}

.card h3 {
  margin: 0;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.field {
  display: grid;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.field--inline {
  grid-auto-flow: column;
  align-items: center;
  gap: 0.5rem;
}

.field--inline input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

textarea {
  width: 100%;
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  color: var(--text);
  padding: 0.75rem;
  font-family: "SF Mono", "JetBrains Mono", monospace;
  font-size: 0.85rem;
  min-height: 120px;
}

.terminal-list {
  display: grid;
  gap: 0.75rem;
}

.terminal-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.terminal-output {
  margin-top: 0.75rem;
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.75rem;
  font-family: "SF Mono", "JetBrains Mono", monospace;
  font-size: 0.85rem;
  color: var(--text);
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.terminal-entry {
  margin-bottom: 0.85rem;
}

.terminal-entry__meta {
  font-size: 0.75rem;
  color: var(--accent-strong);
  margin-bottom: 0.35rem;
}

.terminal-entry__stderr {
  color: #ff9aa0;
}

.monitor-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 0.75rem;
}

.monitor-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 0.85rem;
  display: grid;
  gap: 0.4rem;
}

.monitor-card__label {
  font-size: 0.85rem;
  color: var(--muted);
}

.monitor-card__value {
  font-weight: 600;
  font-size: 0.95rem;
}

.monitor-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  border: 1px solid rgba(127, 177, 255, 0.2);
}

.monitor-bar__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5c9fff, #7fb1ff);
  transition: width 0.3s ease;
}

.setup-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 0.75rem;
}

.setup-grid--single {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.setup-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 1rem;
  display: grid;
  gap: 0.6rem;
}

.setup-card h3 {
  margin: 0;
}

.setup-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.setup-code {
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  padding: 0.5rem 0.65rem;
  font-family: "SF Mono", "JetBrains Mono", monospace;
  font-size: 0.85rem;
  word-break: break-all;
}

.setup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.setup-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.integration-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.integration-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 1rem;
  display: grid;
  gap: 0.6rem;
}

.integration-card__title {
  margin: 0;
  font-size: 1rem;
}

.integration-card__meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.integration-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.integration-tag {
  justify-self: flex-start;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(127, 177, 255, 0.15);
  color: var(--accent-strong);
  font-size: 0.75rem;
}

.app-hub {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
}

.app-hub__list {
  display: grid;
  gap: 0.75rem;
}

.app-card {
  background: rgba(12, 18, 32, 0.85);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 0.85rem;
  display: grid;
  gap: 0.45rem;
  cursor: pointer;
}

.app-card--active {
  border-color: rgba(127, 177, 255, 0.6);
  box-shadow: 0 0 0 1px rgba(127, 177, 255, 0.3);
}

.app-card__title {
  font-weight: 600;
}

.app-card__meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.app-card__tag {
  justify-self: flex-start;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(127, 177, 255, 0.15);
  color: var(--accent-strong);
  font-size: 0.75rem;
}

.app-hub__viewer {
  display: grid;
  gap: 0.75rem;
}

.app-hub__header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
}

.app-hub__title {
  font-size: 1.1rem;
  font-weight: 600;
}

.app-hub__meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.app-hub__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.app-hub__frame {
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  overflow: hidden;
  background: #0b1220;
  min-height: 320px;
}

.app-hub__frame iframe {
  width: 100%;
  height: 420px;
  border: none;
}

@media (max-width: 980px) {
  .app-hub {
    grid-template-columns: 1fr;
  }
}

.monitor-cores {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-top: 0.75rem;
}

.monitor-core {
  background: rgba(12, 18, 32, 0.8);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.5rem 0.65rem;
  display: grid;
  gap: 0.35rem;
}

.monitor-core__label {
  font-size: 0.75rem;
  color: var(--muted);
}

.monitor-core__value {
  font-size: 0.85rem;
  font-weight: 600;
}

.chart-output {
  margin-top: 0.75rem;
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.75rem;
  font-family: "SF Mono", "JetBrains Mono", monospace;
  font-size: 0.85rem;
  color: var(--text);
  min-height: 120px;
  white-space: pre;
  overflow-x: auto;
}

.tool-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.tool-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 1rem;
  display: grid;
  gap: 0.6rem;
}

.tool-card__title {
  margin: 0;
  font-size: 1rem;
}

.tool-card__meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.tool-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tool-tag {
  justify-self: flex-start;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(127, 177, 255, 0.15);
  color: var(--accent-strong);
  font-size: 0.75rem;
}

.chat-window {
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.75rem;
  display: grid;
  gap: 0.75rem;
  min-height: 200px;
  max-height: 320px;
  overflow-y: auto;
}

body[data-active-tab="chat"] .chat-window {
  padding-bottom: 1rem;
}

body[data-active-tab="chat"] .chat-composer {
  display: grid;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.chat-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.chat-title__label {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.chat-profile {
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  background: rgba(20, 27, 44, 0.9);
  color: var(--text);
  padding: 0.3rem 0.6rem;
  font-size: 1rem;
}

.chat-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chat-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(12, 18, 32, 0.9);
}

.chat-toggle__btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.chat-toggle__btn--active {
  color: var(--text);
  background: rgba(127, 177, 255, 0.2);
}

.chat-stream {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.chat-stream::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.chat-stream--active {
  color: var(--accent-strong);
}

.chat-stream--active::before {
  background: var(--accent-strong);
  box-shadow: 0 0 8px rgba(127, 177, 255, 0.9);
}

.chat-stream--error {
  color: #ff9aa0;
}

.chat-stream--error::before {
  background: #ff9aa0;
}

.chat-composer {
  position: relative;
  width: 100%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 0.9rem;
  padding: 0.6rem 0.75rem;
  display: none;
  gap: 0.5rem;
  backdrop-filter: blur(18px) saturate(160%);
  box-shadow: 0 12px 24px rgba(5, 8, 16, 0.2);
}

.chat-composer__input {
  display: grid;
}

.chat-composer textarea {
  min-height: 44px;
  max-height: 160px;
  resize: none;
  background: rgba(5, 8, 16, 0.35);
  border: 1px solid var(--glass-border);
  border-radius: 0.75rem;
  padding: 0.6rem 0.7rem;
  color: var(--text);
  font-size: 1rem;
  transition: all 0.2s ease;
}

.chat-composer textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(92, 159, 255, 0.1);
}

/* Mobile-specific enhancements */
@media (max-width: 768px) {
  .chat-composer {
    padding: 1rem;
    border-radius: 1.25rem 1.25rem 0 0;
  }
  
  .chat-composer textarea {
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 52px;
  }
  
  .app-topbar {
    padding: 0.75rem 1rem;
  }
  
  .floating-menu {
    flex-wrap: wrap;
    gap: 0.25rem;
  }
  
  .floating-menu .tab-btn {
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem;
  }
}

/* Touch-friendly improvements */
.has-touch .btn {
  min-height: 44px;
  min-width: 44px;
}

.has-touch .tab-btn {
  min-height: 36px;
  padding: 0.5rem 0.9rem;
}

/* Smooth animations */
* {
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Glow effects for active states */
.tab-btn--active,
.btn--primary {
  position: relative;
}

.tab-btn--active::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: var(--glow-accent);
  filter: blur(8px);
  opacity: 0.4;
  z-index: -1;
  animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% {
    opacity: 0.4;
  }
  50% {
    opacity: 0.6;
  }
}

.chat-composer textarea:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(92, 159, 255, 0.3);
}

.chat-composer__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.floating-menu {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: rgba(20, 27, 44, 0.5);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
}

.floating-menu .tab-btn {
  flex: 1;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  text-align: center;
}

body[data-active-tab="code"] .hero {
  display: none;
}

body[data-active-tab="chat"] .hero {
  display: none;
}

body[data-active-tab="chat"] .chat-composer {
  display: grid;
}

.input,
textarea {
  background: rgba(5, 8, 16, 0.35);
  border: 1px solid var(--glass-border);
  border-radius: 0.75rem;
  color: var(--text);
}

.input:focus,
textarea:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(92, 159, 255, 0.25);
}

.app-hub__frame {
  min-height: 60vh;
}

.app-hub__frame iframe {
  height: 60vh;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.chat-message {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 0.75rem;
  padding: 0.6rem 0.75rem;
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.chat-message--user {
  background: rgba(92, 159, 255, 0.2);
  justify-self: end;
}

.chat-message__meta {
  color: var(--muted);
  font-size: 0.75rem;
}

.chat-settings {
  margin-top: 1rem;
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.75rem;
}

.chat-settings summary {
  cursor: pointer;
  color: var(--accent-strong);
  margin-bottom: 0.5rem;
}

.terminal-item {
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.85rem;
  display: grid;
  gap: 0.4rem;
}

.terminal-item code {
  color: var(--accent-strong);
  word-break: break-all;
}

.terminal-item button {
  justify-self: flex-start;
}

.footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.85rem;
}

code {
  background: rgba(127, 177, 255, 0.12);
  padding: 0.15rem 0.4rem;
  border-radius: 0.35rem;
  color: var(--accent-strong);
}

.dock-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 0.5rem;
  justify-content: space-around;
  padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom));
  background: rgba(10, 15, 25, 0.9);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(12px);
  z-index: 10;
}

.dock-item {
  flex: 1;
  text-align: center;
  padding: 0.5rem 0.4rem;
  border-radius: 0.8rem;
  border: 1px solid transparent;
  background: rgba(20, 27, 44, 0.9);
  color: var(--text);
  text-decoration: none;
  font-size: 0.82rem;
}

.dock-item:hover {
  border-color: var(--accent);
}

/* Local Launchpad Summary Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal--hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal__overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(11, 15, 26, 0.85);
  backdrop-filter: blur(8px);
}

.modal__content {
  position: relative;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: var(--shadow-soft), var(--shadow-glow);
  backdrop-filter: blur(20px);
  z-index: 1;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal__header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
}

.modal__close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.2s ease, background 0.2s ease;
}

.modal__close:hover {
  color: var(--text);
  background: var(--glass-bg);
}

.modal__close:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.modal__body {
  padding: 1.5rem;
}

.summary-section {
  margin-bottom: 2rem;
}

.summary-section:last-child {
  margin-bottom: 0;
}

.summary-section h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.summary-meta {
  margin: 0 0 1rem 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.summary-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.summary-status-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
}

.summary-status-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.summary-status-value {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.summary-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.summary-action-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 1rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  color: var(--text);
}

.summary-action-btn:hover {
  background: var(--surface-alt);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.summary-action-btn:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.summary-action-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.summary-action-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.summary-action-content strong {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.summary-action-content span {
  font-size: 0.8125rem;
  color: var(--muted);
}

.summary-action-arrow {
  font-size: 1.25rem;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.summary-action-btn:hover .summary-action-arrow {
  transform: translateX(4px);
  color: var(--accent);
}

@media (max-width: 768px) {
  .modal__content {
    max-width: 100%;
    max-height: 95vh;
    border-radius: 16px 16px 0 0;
    margin-top: auto;
  }
  
  .summary-status-grid {
    grid-template-columns: 1fr;
  }
}

/* Markdown Viewer Styles */
.markdown-viewer {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
}

.markdown-toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  padding: 0.75rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  backdrop-filter: blur(12px);
}

.input--inline {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
}

.markdown-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  min-height: 400px;
}

@media (max-width: 980px) {
  .markdown-container {
    grid-template-columns: 1fr;
  }
}

.markdown-editor,
.markdown-preview {
  display: flex;
  flex-direction: column;
  min-height: 400px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  overflow: hidden;
  backdrop-filter: blur(12px);
}

.markdown-textarea {
  flex: 1;
  width: 100%;
  padding: 1rem;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
  font-size: 0.875rem;
  line-height: 1.6;
  resize: none;
  outline: none;
}

.markdown-textarea:focus {
  background: rgba(92, 159, 255, 0.05);
}

.markdown-preview {
  padding: 1rem;
  overflow-y: auto;
  overflow-x: hidden;
}

.markdown-preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  text-align: center;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4,
.markdown-preview h5,
.markdown-preview h6 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}

.markdown-preview h1 {
  font-size: 2em;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.3em;
}

.markdown-preview h2 {
  font-size: 1.5em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3em;
}

.markdown-preview h3 {
  font-size: 1.25em;
}

.markdown-preview p {
  margin: 1em 0;
  line-height: 1.6;
}

.markdown-preview code {
  background: rgba(92, 159, 255, 0.15);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
  font-size: 0.9em;
  color: var(--accent-strong);
}

.markdown-preview pre {
  background: rgba(11, 15, 26, 0.8);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  margin: 1em 0;
}

.markdown-preview pre code {
  background: transparent;
  padding: 0;
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.5;
}

.markdown-preview blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 1em;
  margin: 1em 0;
  color: var(--muted);
  font-style: italic;
}

.markdown-preview ul,
.markdown-preview ol {
  margin: 1em 0;
  padding-left: 2em;
}

.markdown-preview li {
  margin: 0.5em 0;
  line-height: 1.6;
}

.markdown-preview table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
}

.markdown-preview th,
.markdown-preview td {
  border: 1px solid var(--border);
  padding: 0.5em;
  text-align: left;
}

.markdown-preview th {
  background: var(--glass-bg);
  font-weight: 600;
}

.markdown-preview a {
  color: var(--accent);
  text-decoration: none;
}

.markdown-preview a:hover {
  text-decoration: underline;
}

.markdown-preview img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1em 0;
}

/* Terminal Injection Panel (nbpreview-style) */
.terminal-injection {
  display: none;
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(11, 15, 26, 0.95);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
  font-size: 0.875rem;
  line-height: 1.5;
}

.terminal-injection.active {
  display: block;
}

.terminal-injection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.terminal-injection-title {
  font-weight: 600;
  color: var(--accent);
}

.terminal-injection-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.25rem;
  padding: 0;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.2s ease, background 0.2s ease;
}

.terminal-injection-close:hover {
  color: var(--text);
  background: var(--glass-bg);
}

.terminal-injection-output {
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.terminal-injection-output .command {
  color: var(--accent);
  font-weight: 600;
}

.terminal-injection-output .stdout {
  color: var(--text);
}

.terminal-injection-output .stderr {
  color: #ff6b6b;
}

.terminal-injection-output .exit-code {
  color: var(--muted);
  font-style: italic;
}

/* Mobile optimizations for markdown viewer */
@media (max-width: 768px) {
  .markdown-container {
    min-height: 300px;
  }
  
  .markdown-editor,
  .markdown-preview {
    min-height: 300px;
  }
  
  .markdown-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .input--inline {
    width: 100%;
  }
  
  .markdown-textarea {
    font-size: 16px; /* Prevent iOS zoom */
  }
}

/* Landing Page Hero with Map */
.landing-hero {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100vh;
  background: #f5f7fb;
  overflow: hidden;
  z-index: 1000;
  display: none;
  visibility: hidden;
}

body.landing-active .landing-hero {
  display: block;
  visibility: visible;
}

.landing-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 0.75rem) 1.25rem 0.75rem;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid rgba(92, 255, 92, 0.3);
}

.landing-header__content {
  flex: 1;
}

.landing-header__title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: #111526;
  letter-spacing: -0.02em;
}

.landing-header__subtitle {
  margin: 0.25rem 0 0 0;
  font-size: 0.875rem;
  color: #5a6789;
  font-weight: 400;
}

.landing-header__notify {
  background: rgba(92, 255, 92, 0.15);
  border: 1px solid rgba(92, 255, 92, 0.3);
  border-radius: 8px;
  padding: 0.5rem;
  color: #111526;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.landing-header__notify:hover {
  background: rgba(92, 255, 92, 0.2);
  border-color: var(--accent-lime);
}

.landing-days {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0.75rem) + 5rem);
  left: 0;
  right: 0;
  z-index: 99;
  padding: 0 1.25rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.landing-days::-webkit-scrollbar {
  display: none;
}

.landing-days__scroll {
  display: flex;
  gap: 0.75rem;
  padding-bottom: 0.5rem;
}

.landing-day-btn {
  flex-shrink: 0;
  min-width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  border: 2px solid rgba(92, 255, 92, 0.4);
  background: rgba(255, 255, 255, 0.9);
  color: #111526;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(12px);
  position: relative;
}

.landing-day-btn::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  padding: 2px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.landing-day-btn--active {
  background: var(--accent-lime);
  border-color: var(--accent-lime);
  color: #111526;
  box-shadow: 0 0 20px rgba(92, 255, 92, 0.5), 0 4px 12px rgba(0, 0, 0, 0.2);
  transform: scale(1.1);
}

.landing-day-btn--active::before {
  opacity: 1;
}

.landing-day-btn:not(.landing-day-btn--active):hover {
  border-color: rgba(92, 255, 92, 0.6);
  background: rgba(92, 255, 92, 0.15);
  transform: scale(1.05);
}

.landing-map-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100vh;
  z-index: 1;
}

.landing-map {
  width: 100%;
  height: 100%;
  background: #f5f7fb;
}

.landing-map-overlay {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0.75rem) + 10rem);
  left: 1.25rem;
  right: 1.25rem;
  z-index: 10;
  pointer-events: none;
}

.landing-map-stats {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.landing-stat {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(92, 255, 92, 0.3);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  min-width: 120px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.landing-stat__label {
  font-size: 0.75rem;
  color: #5a6789;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.landing-stat__value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent-lime);
  line-height: 1.2;
}

.landing-stat__unit {
  font-size: 0.875rem;
  color: #5a6789;
  font-weight: 400;
}

/* Map markers styling */
.maplibregl-marker {
  cursor: pointer;
}

.maplibregl-popup {
  max-width: 200px;
}

.maplibregl-popup-content {
  background: rgba(12, 18, 32, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(92, 255, 92, 0.3);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  color: var(--text);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.maplibregl-popup-close-button {
  color: var(--muted);
  font-size: 1.25rem;
  padding: 0.25rem 0.5rem;
  transition: color 0.2s ease;
}

.maplibregl-popup-close-button:hover {
  color: var(--text);
}

/* Enhanced chat composer for landing page */
#landingHero ~ * .chat-composer,
.landing-hero ~ main .chat-composer {
  display: flex !important;
  flex-direction: column;
  background: rgba(12, 18, 32, 0.9);
  backdrop-filter: blur(24px) saturate(180%);
  border-top: 1px solid rgba(92, 255, 92, 0.3);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.3), 0 0 32px rgba(92, 255, 92, 0.1);
  z-index: 1001;
}

#landingHero:not([style*="display: none"]) ~ * .chat-composer::before,
.landing-hero ~ main .chat-composer::before {
  background: linear-gradient(135deg, rgba(92, 255, 92, 0.2), rgba(92, 255, 92, 0.1));
}

/* Hide original hero when landing is active */
.hero--hidden {
  display: none;
}

/* Ensure landing page takes full viewport */
#landingHero {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  display: block;
}

/* Hide app topbar on landing page */
#landingHero:not([style*="display: none"]) ~ header.app-topbar,
#landingHero[style*="display: block"] ~ header.app-topbar {
  display: none !important;
  visibility: hidden !important;
}

/* Mobile optimizations for landing page */
@media (max-width: 768px) {
  .landing-header {
    padding-top: calc(env(safe-area-inset-top, 0.75rem) + 0.5rem);
  }
  
  .landing-days {
    top: calc(env(safe-area-inset-top, 0.75rem) + 4.5rem);
  }
  
  .landing-day-btn {
    min-width: 3rem;
    height: 3rem;
    font-size: 0.8125rem;
  }
  
  .landing-map-overlay {
    top: calc(env(safe-area-inset-top, 0.75rem) + 8rem);
  }
  
  .landing-stat {
    min-width: 100px;
    padding: 0.5rem 0.75rem;
  }
  
  .landing-stat__value {
    font-size: 1.125rem;
  }
}

/* Map route/path styling */
.maplibregl-ctrl-group {
  background: rgba(12, 18, 32, 0.9);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(92, 255, 92, 0.3);
  border-radius: 8px;
}

.maplibregl-ctrl button {
  background-color: transparent;
  color: var(--text);
}

.maplibregl-ctrl button:hover {
  background-color: rgba(92, 255, 92, 0.15);
}

/* Map Marker Styling */
.map-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, filter 0.2s ease;
  position: relative;
  transform-origin: center center;
}

.map-marker-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border: 2px solid var(--accent-lime);
  border-radius: 50%;
  font-size: 1.25rem;
  box-shadow: 0 0 16px rgba(92, 255, 92, 0.4), 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
  position: relative;
}

.map-marker:hover .map-marker-icon {
  transform: scale(1.15);
  box-shadow: 0 0 24px rgba(92, 255, 92, 0.6), 0 6px 16px rgba(0, 0, 0, 0.4);
}
