:root {
  --shell-bg: #0f0b07;
  --shell-panel: #171008;
  --shell-panel-hi: #21160d;
  --shell-border: rgba(196, 160, 64, 0.22);
  --shell-border-hi: rgba(196, 160, 64, 0.42);
  --shell-text: #eadbb8;
  --shell-text-dim: #a79978;
  --shell-gold: #c4a040;
  --shell-blood: #8b1a1a;
  --shell-danger: #b33434;
  --shell-success: #507547;
  --shadow-heavy: 0 24px 80px rgba(0, 0, 0, 0.42);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

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

body {
  color: var(--shell-text);
  background:
    radial-gradient(1200px 700px at 50% -10%, rgba(154, 123, 46, 0.16), transparent 65%),
    radial-gradient(900px 600px at 5% 90%, rgba(90, 16, 16, 0.16), transparent 70%),
    var(--shell-bg);
  font-family: "EB Garamond", Georgia, serif;
}

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

button, .ghost-link {
  cursor: pointer;
}

.auth-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 32px;
}

.auth-card {
  width: min(560px, 100%);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.035), transparent),
    var(--shell-panel);
  border: 1px solid var(--shell-border);
  box-shadow: var(--shadow-heavy);
  border-radius: var(--radius-lg);
  padding: 34px;
}

.setup-card {
  width: min(760px, 100%);
}

.eyebrow {
  font-family: "Cinzel", serif;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.34em;
  color: var(--shell-gold);
  margin-bottom: 14px;
}

.auth-card h1,
.empty-card h1 {
  margin: 0 0 12px;
  font-family: "Cinzel Decorative", "Cinzel", serif;
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 1.08;
  color: #f2e6c8;
}

.auth-card h2,
.modal-card h2 {
  font-family: "Cinzel", serif;
  letter-spacing: 0.04em;
}

.lede {
  margin: 0 0 24px;
  color: var(--shell-text-dim);
  font-size: 1.12rem;
  line-height: 1.55;
}

.stack-form {
  display: grid;
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--shell-text-dim);
  font-family: "Cinzel", serif;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  color: var(--shell-text);
  background: rgba(255,255,255,0.045);
  border: 1px solid var(--shell-border);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  text-transform: none;
  letter-spacing: normal;
  font-family: "EB Garamond", Georgia, serif;
  font-size: 1rem;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--shell-border-hi);
  box-shadow: 0 0 0 3px rgba(196, 160, 64, 0.10);
}

textarea {
  resize: vertical;
}

.primary-button,
.ghost-button,
.mini-button,
.icon-button,
.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid var(--shell-border);
  text-decoration: none;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease,
    color 0.16s ease;
}

.primary-button {
  padding: 0 18px;
  color: #161007;
  background: linear-gradient(180deg, #e0c870, #b88f32);
  border-color: rgba(224, 200, 112, 0.65);
  font-family: "Cinzel", serif;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.ghost-button,
.ghost-link {
  padding: 0 16px;
  color: var(--shell-text);
  background: rgba(255,255,255,0.045);
  font-family: "Cinzel", serif;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.mini-button,
.icon-button {
  width: 34px;
  min-height: 34px;
  color: var(--shell-text);
  background: rgba(255,255,255,0.045);
}

.icon-button {
  font-size: 1.3rem;
}

.primary-button:hover,
.ghost-button:hover,
.mini-button:hover,
.icon-button:hover,
.ghost-link:hover {
  transform: translateY(-1px);
  border-color: var(--shell-border-hi);
}

.notice {
  border: 1px solid var(--shell-border);
  background: rgba(255,255,255,0.04);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 0 0 18px;
}

.notice p {
  margin: 0 0 6px;
}
.notice p:last-child {
  margin-bottom: 0;
}

.notice-error {
  border-color: rgba(179, 52, 52, 0.55);
  background: rgba(139, 26, 26, 0.18);
}

.notice-success {
  border-color: rgba(80, 117, 71, 0.55);
  background: rgba(80, 117, 71, 0.16);
}

.manual-config {
  margin-top: 24px;
}

.manual-config h2 {
  margin-bottom: 8px;
}

.manual-config textarea {
  min-height: 320px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

.app-body {
  height: 100vh;
  overflow: hidden;
}

.bookmaker-app {
  display: grid;
  grid-template-columns: 310px 1fr 340px;
  grid-template-rows: 82px 1fr;
  height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 22px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05), transparent),
    rgba(11, 8, 5, 0.92);
  border-bottom: 1px solid var(--shell-border);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-glyph {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 15px;
  color: var(--shell-gold);
  border: 1px solid var(--shell-border);
  background: rgba(255,255,255,0.04);
  font-size: 1.25rem;
}

.brand-title {
  font-family: "Cinzel Decorative", "Cinzel", serif;
  font-size: 1.28rem;
  color: #f0e3c0;
  line-height: 1.1;
}

.brand-subtitle {
  margin-top: 3px;
  font-family: "Cinzel", serif;
  font-size: 0.64rem;
  color: var(--shell-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.22em;
}

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

.save-state {
  min-width: 88px;
  color: var(--shell-text-dim);
  font-family: "Cinzel", serif;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  text-align: right;
}

.sidebar {
  min-height: 0;
  overflow-y: auto;
  background: rgba(18, 12, 7, 0.88);
}

.left-sidebar {
  border-right: 1px solid var(--shell-border);
}

.right-sidebar {
  border-left: 1px solid var(--shell-border);
}

.sidebar-section {
  padding: 20px;
  border-bottom: 1px solid var(--shell-border);
}

.sidebar-section h2 {
  margin: 0;
  color: #e9d9b0;
  font-family: "Cinzel", serif;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.24em;
}

.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.entity-list {
  display: grid;
  gap: 10px;
}

.entity-card {
  border: 1px solid var(--shell-border);
  background: rgba(255,255,255,0.035);
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease;
}

.entity-card:hover,
.entity-card.active {
  transform: translateY(-1px);
  border-color: var(--shell-border-hi);
  background: rgba(196, 160, 64, 0.10);
}

.entity-card-title {
  color: #f1e3c0;
  font-family: "Cinzel", serif;
  font-size: 0.86rem;
  letter-spacing: 0.05em;
}

.entity-card-meta {
  margin-top: 6px;
  color: var(--shell-text-dim);
  font-size: 0.92rem;
}

.entity-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.inline-action {
  border: 1px solid var(--shell-border);
  border-radius: 999px;
  background: transparent;
  color: var(--shell-text-dim);
  padding: 4px 10px;
  font-family: "Cinzel", serif;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.64rem;
}

.inline-action:hover {
  color: var(--shell-text);
  border-color: var(--shell-border-hi);
}

.compact-info p {
  margin: 10px 0 0;
  color: var(--shell-text-dim);
  line-height: 1.4;
}

.workspace {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  position: relative;
  background:
    radial-gradient(1000px 680px at 50% 0%, rgba(154,123,46,0.12), transparent 70%),
    rgba(8, 6, 4, 0.58);
}

.editor-toolbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 16px 22px;
  background: rgba(10, 7, 4, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--shell-border);
}

.editor-toolbar button {
  border: 1px solid var(--shell-border);
  color: var(--shell-text);
  background: rgba(255,255,255,0.045);
  border-radius: 999px;
  min-height: 34px;
  padding: 0 12px;
  font-family: "Cinzel", serif;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.editor-toolbar button:hover {
  border-color: var(--shell-border-hi);
  background: rgba(196,160,64,0.12);
}

.editor-empty {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 160px);
  padding: 40px;
}

.empty-card {
  width: min(620px, 100%);
  padding: 34px;
  background: rgba(20, 14, 8, 0.82);
  border: 1px solid var(--shell-border);
  border-radius: 28px;
  box-shadow: var(--shadow-heavy);
}

.empty-card p {
  color: var(--shell-text-dim);
  font-size: 1.14rem;
  line-height: 1.55;
}

.page-canvas {
  display: grid;
  justify-content: center;
  gap: 28px;
  padding: 32px 24px 64px;
}

.settings-stack {
  display: grid;
  gap: 12px;
}

.settings-stack .mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.settings-stack label {
  font-size: 0.68rem;
}

.settings-stack button {
  width: fit-content;
}

.empty-state {
  color: var(--shell-text-dim);
  font-size: 0.98rem;
  line-height: 1.5;
}

.inspector-note {
  color: var(--shell-text-dim);
  font-size: 0.92rem;
  line-height: 1.45;
  border: 1px solid var(--shell-border);
  background: rgba(255,255,255,0.035);
  border-radius: 12px;
  padding: 10px 12px;
}

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

.asset-card {
  position: relative;
  border: 1px solid var(--shell-border);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255,255,255,0.04);
  cursor: pointer;
}

.asset-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.asset-card-footer {
  padding: 8px;
  color: var(--shell-text-dim);
  font-size: 0.84rem;
  line-height: 1.25;
  word-break: break-word;
}

.asset-card .delete-asset {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(10, 7, 4, 0.78);
  color: #fff0dd;
  border: 1px solid var(--shell-border);
}

.modal-card {
  width: min(700px, calc(100vw - 40px));
  border: none;
  padding: 0;
  background: transparent;
}

.modal-card::backdrop {
  background: rgba(0,0,0,0.62);
  backdrop-filter: blur(4px);
}

.modal-shell {
  margin: 0;
  color: var(--shell-text);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05), transparent),
    var(--shell-panel);
  border: 1px solid var(--shell-border-hi);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow-heavy);
}

.modal-shell.wide {
  width: min(940px, calc(100vw - 40px));
}

.modal-shell > header,
.modal-shell > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--shell-border);
}

.modal-shell > footer {
  justify-content: flex-end;
  border-top: 1px solid var(--shell-border);
  border-bottom: none;
}

.modal-shell h2 {
  margin: 0;
  color: #f2e6c8;
}

.modal-body {
  padding: 20px;
  display: grid;
  gap: 16px;
}

.asset-picker-grid {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  max-height: 68vh;
  overflow: auto;
}

.asset-picker-item {
  border: 1px solid var(--shell-border);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255,255,255,0.035);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease;
}

.asset-picker-item:hover {
  transform: translateY(-2px);
  border-color: var(--shell-border-hi);
}

.asset-picker-item img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.asset-picker-item span {
  display: block;
  padding: 10px;
  color: var(--shell-text-dim);
  line-height: 1.25;
  word-break: break-word;
}

.danger-button {
  border-color: rgba(179,52,52,0.55);
  color: #ffd0d0;
}

.inline-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  text-transform: none;
  letter-spacing: normal;
  font-family: "EB Garamond", Georgia, serif;
  font-size: 1rem;
}

.inline-checkbox input {
  width: auto;
  margin: 0;
}

@media (max-width: 1360px) {
  .bookmaker-app {
    grid-template-columns: 280px 1fr 310px;
  }
}

@media (max-width: 1100px) {
  .bookmaker-app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto 1fr;
    height: auto;
    min-height: 100vh;
  }

  .app-body {
    height: auto;
    overflow: auto;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 60;
    flex-wrap: wrap;
  }

  .sidebar {
    overflow: visible;
    border: none;
  }

  .left-sidebar,
  .right-sidebar {
    border-bottom: 1px solid var(--shell-border);
  }

  .workspace {
    min-height: 70vh;
  }
}

@media (max-width: 760px) {
  .auth-body {
    padding: 18px;
  }

  .auth-card {
    padding: 24px;
  }

  .form-grid,
  .settings-stack .mini-grid,
  .asset-grid,
  .asset-picker-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }
}

.field-hint { display: block; margin-top: 0.35rem; font-size: 0.82rem; opacity: 0.78; line-height: 1.35; }

.color-field-row {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  align-items: center;
}

.color-field-row input[type="color"] {
  min-height: 42px;
  padding: 4px;
}

.settings-subhead {
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--shell-border);
  color: var(--shell-gold);
  font-family: "Cinzel", serif;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
