:root {
  color-scheme: dark;
  --bg: #101417;
  --panel: #181f23;
  --border: #635139;
  --gold: #efc578;
  --muted: #bdb5a8;
  font: 16px/1.5 system-ui, sans-serif;
  color: #faf3eb;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: radial-gradient(ellipse at top, #283034, var(--bg) 42rem); min-height: 100vh; }
header { padding: .8rem max(1rem, calc((100% - 72rem) / 2)); border-bottom: 1px solid var(--border); background: #141a1d; font: bold 1.35rem Georgia, serif; }
header span, h1, h2, legend { color: var(--gold); }
main { width: min(72rem, calc(100% - 2rem)); margin: 2rem auto; }
h1, h2 { font-family: Georgia, serif; line-height: 1.15; margin: 0 0 1rem; }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
.workspace { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1rem; align-items: start; }
.panel {
  background: linear-gradient(160deg, #21292c, var(--panel) 17rem);
  border: 1px solid var(--border);
  border-radius: .5rem;
  box-shadow: inset 0 1px #e8ba6e24, 0 .4rem 1rem #0003;
  padding: clamp(1rem, 3vw, 1.5rem);
}
.fields, .ingredient { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
label { display: grid; gap: .25rem; font-size: .9rem; }
input, select, button, .settings-download { font: inherit; color: inherit; border: 1px solid var(--border); border-radius: .4rem; padding: .55rem .65rem; min-width: 0; }
input, select { background: #10171a; width: 100%; }
button, .settings-download { cursor: pointer; background: linear-gradient(#39342a, #252521); }
button:hover, .settings-download:hover { border-color: var(--gold); }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.primary { color: #211723; background: var(--gold); font-weight: bold; }
fieldset { min-width: 0; margin: 1.25rem 0 0; border: 1px solid var(--border); border-radius: .4rem; }
.ingredient { grid-template-columns: minmax(0, 1.5fr) minmax(0, .7fr) minmax(0, 1fr) auto; align-items: end; margin-bottom: .75rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.workspace-tabs { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.workspace-tabs button { border-radius: .4rem .4rem 0 0; border-bottom: 0; padding-inline: 1rem; }
.workspace-tabs [aria-selected="true"] { color: var(--gold); background: #302619; box-shadow: inset 0 -3px var(--gold); font-weight: bold; }
#market-form { align-items: end; }
#market-actions { max-width: 32rem; }
.hint, dt { color: var(--muted); }
dl { margin: 0; }
.metric { display: grid; grid-template-columns: 1fr auto; gap: .5rem; border-bottom: 1px solid var(--border); padding: .55rem 0; }
dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.library { margin-top: 1rem; display: grid; gap: .8rem; }
.library h2 { margin: 0; }
.library label { max-width: 28rem; }
.account { max-width: 30rem; }
.account form { display: grid; gap: .75rem; }
.session { display: flex; justify-content: flex-end; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.market-stamp { margin: 0; font-size: .85rem; color: var(--muted); text-align: right; }
.market-stamp time { color: var(--gold); white-space: nowrap; }
.settings-menu { position: relative; flex: none; }
.settings-menu summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border: 1px solid var(--border);
  border-radius: .4rem;
  background: linear-gradient(#39342a, #252521);
  color: var(--gold);
  font-size: 1.35rem;
}
.settings-menu summary::-webkit-details-marker { display: none; }
.settings-menu summary:hover, .settings-menu[open] summary { border-color: var(--gold); }
.settings-popout {
  position: absolute;
  z-index: 4;
  inset: calc(100% + .4rem) 0 auto auto;
  display: grid;
  min-width: 10rem;
  gap: .4rem;
  padding: .55rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: .4rem;
  box-shadow: 0 .5rem 1rem #0008;
}
.settings-popout span { padding-inline: .35rem; color: var(--muted); overflow-wrap: anywhere; }
.settings-popout button, .settings-download { text-align: left; }
.settings-download {
  text-decoration: none;
  overflow-wrap: anywhere;
}
#sync-view, #manual-import-panel { width: min(32rem, calc(100% - 2rem)); }
#sync-view form { margin-top: .75rem; }
#sync-view::backdrop, #manual-import-panel::backdrop { background: #080b0bcc; }
.character { margin-bottom: 1rem; }
.character .actions { align-items: end; }
#status { min-height: 1.5rem; color: var(--gold); }
@media (max-width: 54rem) {
  .ingredient { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 44rem) {
  .workspace { grid-template-columns: 1fr; }
}
@media (max-width: 28rem) {
  .fields { grid-template-columns: 1fr; }
}
