:root {
  --bg: var(--vault-background);
  --panel: var(--vault-surface);
  --raised: var(--vault-raised);
  --record: var(--vault-raised);
  --ink: var(--vault-ink);
  --muted: var(--vault-muted);
  --gold: var(--vault-accent);
  --line: var(--vault-border);
}

.app-shell > header .brand a {
  color: var(--gold);
  text-decoration: none;
  letter-spacing: .035em;
}

.app-shell .workspace-surface > .page-header h1 {
  font: 500 clamp(1.4rem, 3vw, 2rem)/1.15 var(--vault-heading);
  overflow-wrap: anywhere;
}

.app-shell .inventory-records {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 34rem), 1fr));
  gap: var(--vault-space);
  align-items: start;
}

.app-shell .inventory-record {
  border-radius: var(--vault-radius);
}

.app-shell :focus-visible {
  outline-color: var(--vault-focus);
}

/* Members use the storefront palette, with dense controls where they work. */
:root {
  color-scheme: light;
  --interactive: #e5eeea;
  --financial-well: var(--vault-background);
  --badge: var(--vault-raised);
  --field-border: var(--vault-control-border);
  --cost: var(--vault-muted);
  --melt: #235e83;
  --numismatic: #77501f;
  --profit: #17613f;
  --loss: #a82c39;
  --missing-value: #586e66;
}

:root.dark {
  --interactive: var(--vault-raised);
  --melt: #93c5fd;
  --numismatic: #fcd48e;
  --profit: #86efc0;
  --loss: #fda4af;
  --missing-value: var(--vault-muted);
}

.app-shell > header {
  background: var(--panel);
  padding-inline: clamp(.75rem, 3vw, 2.5rem);
}

.app-shell > header .brand a {
  font-size: 1.1rem;
  font-weight: 780;
  letter-spacing: -.035em;
  white-space: nowrap;
}

.app-shell .page-toolbar button {
  border-radius: var(--vault-control-radius);
}

.app-shell .workspace-surface > .page-header h1 {
  font-weight: 720;
  letter-spacing: -.035em;
}

.app-shell .workspace-content > :is(#homeSpotOverview, #homeMetalContent) {
  background: transparent;
  border-block-start: 1px solid var(--line);
  padding: 1rem 0 0;
  margin: .5rem 0 0;
}

.app-shell .metric {
  background: var(--raised);
  border-radius: var(--vault-radius);
  padding: clamp(.65rem, 2vw, 1.15rem);
}

.app-shell #login {
  flex: 0 1 auto;
  margin: auto;
  max-width: 32rem;
  border-radius: var(--vault-radius);
  border: 1px solid var(--line);
  padding: clamp(1rem, 4vw, 2rem);
}

.app-shell #login h1 {
  font: 750 clamp(1.5rem, 4vw, 2.15rem)/1.1 var(--vault-heading);
  letter-spacing: -.045em;
  margin-block: 0 1rem;
}

.app-shell .auth-actions { align-items: center; }
.app-shell .auth-actions button[type="submit"] { border-radius: 99rem; }

.app-shell :is(input, select, textarea):not([type="range"], [type="checkbox"], [type="radio"]) {
  background-color: var(--panel);
  color: var(--ink);
  border-color: var(--field-border);
}

.app-shell :is(button[type="submit"], form button:not([type]), #commit) {
  color: var(--vault-on-accent);
}

.app-shell :is(.icon-button, .file-upload-button, dialog .dialog-head button) {
  color: var(--ink);
  background: var(--interactive);
}
.app-shell :is(.owned, .missing) { background: var(--raised); }
.app-shell .owned { color: var(--profit); }
.app-shell .missing { color: var(--muted); }

.app-shell .inventory-record {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: .7rem;
}

.app-shell .inventory-record .financial-well {
  border-radius: var(--vault-control-radius);
}

.app-shell .inventory-record .record-header h3 {
  letter-spacing: -.01em;
}

.app-shell .notification {
  box-shadow: 0 5px 24px #15282522;
}
.app-shell .notification[data-tone="error"] { color: var(--loss); }

.app-shell .combo-control,
.app-shell .combo-menu {
  background: var(--panel);
  color: var(--ink);
}
.app-shell .combo-group { background: var(--raised); }
.app-shell .combo-arrow { background: var(--interactive); }
.app-shell .combo-option:is(:hover, .active, [aria-selected="true"]) { background: var(--interactive); }

.app-shell :is(.action-popover button, .vault-badge.rarity-key) { color: var(--ink); }
.app-shell :is(.action-popover .danger-action, .vault-badge.rarity-key) { color: var(--loss); }
.app-shell .vault-badge.rarity-key { background: #fbeaec; }

.app-shell .page-toolbar .page-tool { box-shadow: none; }
.app-shell .page-toolbar .page-tool:is([aria-current="page"], [aria-pressed="true"]) { box-shadow: inset 0 -2px var(--gold); }

.app-shell .coin-photo-editor [role="tab"][aria-selected="true"],
.app-shell .coin-photo-editor [data-crop-apply] { color: var(--vault-on-accent); }
.app-shell .coin-photo-editor canvas { background: #182421; }


.vault-auth-heading > a,
.vault-home-links > a {
  color: var(--gold);
  text-underline-offset: .2em;
}
.vault-auth-heading > a {
  display: inline-block;
  margin-block-end: 1rem;
  font-weight: 650;
}
.vault-home-links {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.4rem;
}
.vault-home-links > a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  font-weight: 650;
}

.app-shell :is(.combo-control, .assistant-message-entry) {
  background-color: var(--panel);
  border-color: var(--field-border);
}
.app-shell .combo-control input:not(.select-source),
.app-shell .assistant-message-entry textarea {
  background-color: transparent;
}
.app-shell :is(#login, #termsGate) .auth-actions button[type="submit"] {
  color: var(--vault-on-accent);
}

@media (min-width: 60rem) {
  .app-shell #workspace {
    width: min(100%, 100rem);
    justify-self: center;
  }
}

/* Keep Metal Vault's scroll and focus contracts on the Metronic cards. */
.app-shell .workspace-surface.kt-card:not(.assistant-workspace) {
  border: 1px solid var(--mv-kt-border, var(--line));
  border-radius: calc(var(--mv-kt-radius, var(--vault-control-radius)) + 4px);
}

.app-shell .workspace-surface > .kt-card-header {
  min-height: 0;
  padding: 0;
  border-bottom: 0;
}

.app-shell .dialog-head.kt-card-header {
  min-height: 0;
  padding-inline: 0;
  border-bottom-width: 0;
}

.app-shell :is(.kt-btn, .kt-input, .kt-select):focus-visible {
  outline: 2px solid var(--vault-focus);
  outline-offset: 2px;
}

.app-shell :is(.kt-btn, .kt-input, .kt-select) {
  border-radius: var(--mv-kt-radius, var(--vault-control-radius));
}

.app-shell .kt-btn {
  height: auto;
  min-height: var(--control-height);
  white-space: normal;
}

.app-shell :is(.record-toggle, .coin-photo-edit, .page-tool).kt-btn {
  box-shadow: none;
}

.app-shell .record-toggle.kt-btn {
  background: transparent;
  border: 0;
}

.record-toggle::before {
  position: absolute;
  inset-block-start: 11px;
  inset-inline-end: 13px;
  width: 8px;
  height: 8px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  content: '';
  transform: rotate(45deg);
}

.record-toggle[aria-expanded="true"]::before {
  inset-block-start: 15px;
  transform: rotate(225deg);
}

.app-shell .kt-label { line-height: 1.4; }

.app-shell select.kt-select {
  display: block;
  appearance: auto;
  background-image: none;
  text-overflow: ellipsis;
}

.app-shell textarea.kt-input { height: auto; }

.app-shell :is(.kt-checkbox, .kt-radio) {
  appearance: auto;
  min-width: 1rem;
  min-height: 1rem;
  accent-color: var(--gold);
}

.app-shell .notification.kt-alert {
  display: block;
  width: max-content;
}

@media (max-width: 430px) {
  .app-shell .inventory-record .financial-well:has(> :nth-child(4)),
  .app-shell .inventory-record .financial-well:has(+ .record-measurements[data-count="4"]),
  .app-shell .inventory-record .record-measurements[data-count="4"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
