:root {
  --bg: #0c141d;
  --bg-soft: rgba(12, 20, 29, 0.84);
  --panel: rgba(19, 31, 44, 0.88);
  --panel-2: rgba(29, 43, 58, 0.95);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f3efe7;
  --muted: #a7b7c7;
  --accent: #ffb44c;
  --accent-2: #73d6ca;
  --danger: #ef6a5b;
  --shadow: 0 28px 68px rgba(0, 0, 0, 0.38);
  --font-display: "Iowan Old Style", "Palatino Linotype", serif;
  --font-body: "IBM Plex Sans", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, rgba(255, 180, 76, 0.16), transparent 22%),
    radial-gradient(circle at 90% 0%, rgba(115, 214, 202, 0.18), transparent 24%),
    linear-gradient(180deg, #172433 0%, #091018 100%);
}

.background {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}

.app-shell {
  position: relative;
  max-width: 1540px;
  margin: 0 auto;
  padding: 28px 18px 48px;
}

.screen.hidden,
.hidden {
  display: none !important;
}

.auth-screen {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 12px;
  color: var(--accent-2);
}

.lede {
  max-width: 62ch;
  color: var(--muted);
}

.auth-forms {
  width: min(420px, 100%);
}

.auth-card {
  padding: 24px;
}

.auth-card form {
  display: grid;
  gap: 12px;
}

.auth-verification {
  display: grid;
  gap: 12px;
}

.auth-feedback {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(12, 20, 29, 0.8);
  color: var(--text);
}

.auth-feedback.error {
  border-color: rgba(239, 106, 91, 0.52);
  background: rgba(110, 30, 24, 0.28);
}

.auth-feedback.success {
  border-color: rgba(115, 214, 202, 0.42);
  background: rgba(21, 82, 74, 0.24);
}

.auth-switch {
  justify-self: start;
  padding: 0;
  margin-top: 4px;
}

.text-link {
  border: 0;
  background: transparent;
  color: var(--accent-2);
  font-weight: 600;
}

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

.form-card,
.topbar,
.project-header {
  padding: 18px;
}

.workspace-screen {
  display: grid;
  gap: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.topbar-primary {
  display: grid;
  gap: 8px;
}

.section-nav {
  display: flex;
  gap: 10px;
}

.section-nav-button.active {
  color: var(--text);
  border-color: rgba(115, 214, 202, 0.5);
  background: linear-gradient(135deg, rgba(255, 180, 76, 0.16), rgba(115, 214, 202, 0.18));
}

.topbar h1,
.project-header h2,
.panel h2,
.panel h3 {
  margin: 0;
  font-family: var(--font-display);
}

.session-box {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.session-group {
  display: grid;
  gap: 4px;
}

.session-link {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-weight: 700;
  text-align: left;
}

.session-link.active {
  color: var(--accent-2);
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--danger);
}

.status-dot.online {
  background: var(--accent-2);
  box-shadow: 0 0 18px rgba(115, 214, 202, 0.4);
}

.meta-label {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.12em;
}

.meta-value {
  margin: 2px 0 0;
  font-weight: 700;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.workspace-grid > .panel,
.asset-board,
.tab-bar,
.project-header {
  padding: 18px;
}

.workspace-bottom-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

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

.panel-actions {
  display: flex;
  gap: 10px;
}

.stack {
  display: grid;
  gap: 10px;
}

.compact {
  gap: 8px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.92rem;
}

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

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
}

textarea {
  resize: vertical;
  font-family: "IBM Plex Mono", "Menlo", monospace;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  background: linear-gradient(135deg, var(--accent) 0%, #ffd67f 100%);
  color: #1c1510;
  font-weight: 700;
  cursor: pointer;
}

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

.project-list,
.jobs-list {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
}

.project-card,
.job-card,
.asset-card,
.plus-card {
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
  padding: 14px;
}

.project-card.active,
.asset-card:hover {
  border-color: var(--accent-2);
  box-shadow: inset 0 0 0 1px rgba(115, 214, 202, 0.25);
}

.job-card pre,
.revision-json {
  margin: 10px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "IBM Plex Mono", "Menlo", monospace;
}

.project-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
}

.tab-bar {
  display: flex;
  gap: 10px;
}

.topbar-tabs {
  padding: 0;
}

.tab-button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.tab-button.active {
  background: linear-gradient(135deg, rgba(255, 180, 76, 0.16), rgba(115, 214, 202, 0.18));
  color: var(--text);
  border-color: rgba(115, 214, 202, 0.5);
}

.asset-board {
  display: grid;
  gap: 16px;
}

.asset-grid-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.plus-card,
.plus-card-button {
  display: flex;
  align-items: center;
  justify-content: center;
}

.plus-card {
  min-height: 300px;
  font-size: 1.2rem;
  border-style: dashed;
  flex-direction: column;
  gap: 8px;
}

.plus-card-cost,
.generation-cost-notice {
  color: var(--muted);
  font-size: 0.92rem;
}

.asset-card {
  cursor: pointer;
  display: grid;
  gap: 12px;
}

.asset-card.pending {
  border-color: rgba(255, 180, 76, 0.55);
  box-shadow: inset 0 0 0 1px rgba(255, 180, 76, 0.18);
}

.project-card-row {
  display: block;
}

.project-card-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.project-card-inner.gallery {
  align-items: stretch;
}

.project-card-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 16px;
}

.project-card-text {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.project-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-card-name-large {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  line-height: 1;
}

.project-card-meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.project-role-tag {
  padding: 4px 8px;
  font-size: 0.74rem;
}

.project-thumb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  overflow: hidden;
  justify-content: flex-start;
}

.project-thumb-row > * {
  flex: 0 0 170px;
}

.project-thumb-row {
  gap: 10px;
  min-height: 113px;
}

.project-thumb {
  position: relative;
  width: 170px;
  min-width: 170px;
  min-height: 113px;
  height: 113px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.04) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.04) 75%),
    rgba(255, 255, 255, 0.03);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.project-thumb img,
.project-sprite-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.project-thumb.sprite {
  background: rgba(255, 255, 255, 0.03);
}

.project-thumb.placeholder {
  color: var(--muted);
  align-items: center;
}

.project-inline-button {
  align-self: center;
  display: inline-flex;
  white-space: nowrap;
  pointer-events: auto;
}

.invite-card {
  cursor: default;
}

.project-plus-card {
  min-height: 96px;
}

.breadcrumb-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-2);
  font: inherit;
  font-weight: 700;
}

.breadcrumb-sep {
  margin: 0 10px;
  color: var(--muted);
}

.asset-preview {
  position: relative;
  height: 168px;
  border-radius: 14px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.04) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.04) 75%),
    rgba(255, 255, 255, 0.03);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.asset-spinner {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent);
  background: rgba(12, 20, 29, 0.76);
  animation: spin 0.75s linear infinite;
}

.asset-preview img,
.sprite-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.audio-preview,
.audio-preview-panel {
  width: 100%;
}

.audio-preview audio,
.audio-preview-panel audio {
  width: min(100%, 720px);
}

.asset-preview.placeholder {
  color: var(--muted);
  font-size: 0.92rem;
}

.asset-card-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.asset-card-name {
  font-weight: 700;
  font-size: 1rem;
}

.asset-card-subtitle {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.job-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
}

.job-slug {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 999px;
  background: rgba(12, 20, 29, 0.86);
  color: var(--text);
  border: 1px solid var(--line);
}

.card-arrow.left {
  left: 10px;
}

.card-arrow.right {
  right: 10px;
}

.tag-row,
.file-row,
.revision-list,
.variant-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag,
.file-link,
.revision-button,
.variant-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
  text-decoration: none;
  font-size: 0.84rem;
}

.asset-expanded {
  display: none;
}

.revision-button.active {
  border-color: var(--accent-2);
}

.inline-form {
  display: flex;
  gap: 8px;
  width: 420px;
  max-width: 100%;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-row input {
  width: auto;
}

#variantPathPreview {
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.jobs-panel {
  padding: 14px 14px 16px;
}

.jobs-panel .panel-head {
  margin-bottom: 8px;
}

.jobs-panel h2 {
  font-size: 1.1rem;
}

.jobs-panel .tag-row {
  flex-wrap: nowrap;
  justify-content: end;
}

.jobs-list {
  max-height: 208px;
}

.billing-panel {
  padding: 18px;
}

.billing-summary-grid,
.billing-grid,
.account-section-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.billing-balance-card,
.account-section-card {
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.account-settings-grid {
  margin-top: 16px;
}

.billing-balance-value {
  margin: 8px 0;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3.5rem);
}

.billing-transactions-head {
  margin-top: 10px;
}

.billing-transactions {
  display: grid;
  gap: 10px;
}

.billing-transaction-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.billing-transaction-values {
  display: flex;
  gap: 8px;
}

.tag.credit {
  border-color: rgba(115, 214, 202, 0.45);
}

.tag.debit {
  border-color: rgba(255, 180, 76, 0.45);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 12, 0.72);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding:
    max(12px, env(safe-area-inset-top))
    14px
    max(14px, env(safe-area-inset-bottom))
    14px;
  z-index: 20;
}

.modal {
  width: min(900px, 100%);
  padding: 18px;
  max-height: calc(100dvh - max(24px, env(safe-area-inset-top)) - max(24px, env(safe-area-inset-bottom)));
  overflow: auto;
  margin: auto 0;
}

.asset-detail-modal {
  width: min(1120px, 100%);
  max-height: min(92vh, 1080px);
  overflow: auto;
}

#generateForm > button[type="submit"] {
  position: sticky;
  bottom: 0;
  z-index: 1;
  box-shadow: 0 -10px 24px rgba(12, 20, 29, 0.45);
}

.asset-modal-content {
  display: grid;
  gap: 16px;
}

.modal-meta-header h3,
.preview-panel h3 {
  margin: 0;
  font-family: var(--font-display);
}

.modal-preview-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 16px;
}

.modal-preview-grid.single {
  grid-template-columns: 1fr;
}

.preview-panel,
.modal-section {
  display: grid;
  gap: 10px;
}

.modal-sprite-preview,
.modal-sheet-preview,
.sprite-canvas-large {
  min-height: 320px;
}

.cg-preview-tall {
  min-height: min(76vh, 960px);
}

.map-preview-tall {
  min-height: min(76vh, 960px);
  height: auto;
  align-items: stretch;
}

.map-preview-stage {
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.map-preview-stage img {
  width: auto;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
}

.map-preview-overlay {
  position: absolute;
  inset: 0;
  margin: auto;
  pointer-events: none;
}

.map-view-toolbar {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.map-overlay-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: rgba(12, 20, 29, 0.96);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.map-overlay-control input {
  width: 160px;
}

.map-view-buttons {
  align-items: center;
}

.map-view-toolbar .revision-button,
.map-overlay-toggle {
  justify-content: center;
  background: rgba(12, 20, 29, 0.96);
}

.modal-sheet-preview img {
  max-width: 100%;
  width: auto;
  height: 100%;
}

.modal-sheet-preview:not(.map-preview-tall) {
  min-height: min(76vh, 960px);
}

.map-preview-tall {
  position: relative;
}

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

.action-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 8px 12px;
  border: 1px dashed rgba(255, 180, 76, 0.55);
  background: rgba(255, 180, 76, 0.14);
  color: var(--text);
  font-weight: 700;
}

.kv-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.kv-table th,
.kv-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.kv-table th {
  width: 28%;
  color: var(--muted);
  font-weight: 600;
}

.kv-table tr:last-child th,
.kv-table tr:last-child td {
  border-bottom: 0;
}

.kv-table code {
  white-space: pre-wrap;
  word-break: break-word;
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
}

.three-col,
.structured-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.terrain-editor {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}

.terrain-editor-head,
.terrain-table-header,
.terrain-table-row {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(110px, 0.35fr) minmax(0, 1.4fr) auto;
  gap: 10px;
  align-items: center;
}

.terrain-table {
  display: grid;
  gap: 8px;
}

.terrain-table-header {
  color: var(--muted);
  font-size: 0.84rem;
  padding: 0 4px;
}

.terrain-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.terrain-checkbox input {
  width: auto;
}

.structured-fields.full-width > * {
  grid-column: 1 / -1;
}

details summary {
  cursor: pointer;
  margin-bottom: 8px;
}

.service-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.6fr);
  gap: 18px;
}

.service-panel,
.service-codes-section,
.service-users-column,
.service-detail-column,
.service-history-list,
.service-users-list {
  display: grid;
  gap: 12px;
}

.service-users-layout > .panel {
  padding: 16px;
}

.service-toolbar-form {
  display: grid;
  grid-template-columns: 1.4fr minmax(180px, 1fr) 130px 140px auto;
  gap: 12px;
  align-items: end;
}

.service-search-label,
.service-user-summary,
.service-subsection {
  display: grid;
  gap: 10px;
}

.service-users-list,
.service-history-list,
.service-codes-list {
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(8, 16, 24, 0.7);
}

.service-table {
  width: 100%;
  border-collapse: collapse;
}

.service-table th,
.service-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  text-align: left;
  vertical-align: middle;
}

.service-table th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.service-table tr:last-child td,
.service-table tr:last-child th {
  border-bottom: 0;
}

.service-table button {
  color: var(--text);
}

.service-table-row-button {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 0;
  font: inherit;
}

.service-table tr.active {
  background: rgba(255, 180, 76, 0.12);
}

.service-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.service-history-list {
  max-height: 320px;
  overflow: auto;
}

.service-code-actions {
  display: grid;
  grid-template-columns: minmax(110px, 140px) minmax(160px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.service-code-actions input {
  min-width: 0;
}

.jobs-panel {
  width: 100%;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1100px) {
  .auth-screen,
  .workspace-grid,
  .workspace-bottom-grid,
  .project-actions,
  .three-col,
  .structured-fields,
  .billing-summary-grid,
  .billing-grid {
    grid-template-columns: 1fr;
  }

  .service-layout {
    grid-template-columns: 1fr;
  }

  .service-toolbar-form,
  .service-code-actions {
    grid-template-columns: 1fr;
  }

  .topbar,
  .project-header,
  .asset-grid-header {
    align-items: start;
    flex-direction: column;
  }

  .modal-meta-header,
  .modal-preview-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .project-card-row {
    grid-template-columns: 1fr;
  }

  .modal {
    max-height: calc(100dvh - max(18px, env(safe-area-inset-top)) - max(18px, env(safe-area-inset-bottom)));
  }
}
