.storage-warning { max-width: 40rem; margin: -12px 0 24px; }

.roster-layout {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

@media (max-width: 900px) {
  .roster-layout { grid-template-columns: minmax(0, 1fr); }
}

/* Roster: like the game's character select list, name over level and class. */
.roster-list { list-style: none; margin: 0 0 16px; padding: 0; }

.roster-item {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 10px 14px;
  font: inherit;
  text-align: left;
  color: var(--text);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}
.roster-item:hover { background: rgb(255 255 255 / 0.04); }
.roster-item[aria-current="true"] {
  background: var(--tooltip);
  border-color: #3b3b3b;
}
.roster-name { font-family: var(--font-display); font-size: var(--step-1); }
.roster-item[aria-current="true"] .roster-name { color: var(--q-unique); }
.roster-meta { font-size: var(--step--1); color: var(--text-dim); }
.roster-empty { color: var(--text-dim); padding: 4px 0; }
.roster-hardcore { font-size: var(--step--1); color: var(--q-red); }
.roster-ladder { font-size: var(--step--1); color: var(--q-crafted); }
.roster-item.hardcore .roster-name { color: var(--q-red); }
/* Dead hardcore characters: greyed out, as on the game's character select. */
.roster-item.dead .roster-name { color: var(--q-socketed); text-decoration: line-through; text-decoration-color: var(--q-red); }
.roster-item.dead .roster-meta { color: var(--q-socketed); }
.dead-check[hidden] { display: none; }

.roster-files { display: flex; gap: 20px; margin: 20px 0 6px; }

/* Editor: the character's name, then Details, Attributes and Gear, each
   under a gilt rule. */
.editor-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.editor h2 { font-size: var(--step-3); color: var(--q-unique); text-shadow: var(--engrave-gilt); }
.editor h3 { font-size: var(--step-1); margin: 28px 0 10px; }
.editor .editor-section {
  margin: 24px 0 12px;
  padding-bottom: 6px;
  font-variant: small-caps;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  border-bottom: 1px solid;
  border-image: var(--gilt-line) 1;
}
.editor-head + .editor-section { margin-top: 12px; }
/* Fields sit closer in the editor than in the calculators' forms. */
.editor .field { margin-bottom: 14px; }
.editor .hint { margin-top: 4px; }

/* Groups of tick boxes, labelled like the other fields, boxes in a row. */
.checks { border: 0; padding: 0; min-width: 0; }
.checks legend { padding: 0; margin-bottom: 4px; font-weight: 500; }
.check-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; min-height: 2.6rem; }
.checks[hidden] { display: none; }
/* Cube and tomes: across the whole row. */
.editor-grid .carries { grid-column: 1 / -1; }

/* Details: three across (name, class, level; difficulty, quest, game type),
   two on medium screens, one on phones. */
.editor { container-type: inline-size; }
.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0 20px;
}
@container (min-width: 30rem) {
  .editor-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container (min-width: 40rem) {
  .editor-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.field-error { margin: 6px 0 0; font-size: var(--step--1); }

.stats-table { width: 100%; max-width: 42rem; border-collapse: collapse; font-variant-numeric: lining-nums tabular-nums; }
.stats-table th, .stats-table td { padding: 3px 8px 3px 0; text-align: left; }
.stats-table thead th { font-weight: 500; font-size: var(--step--1); color: var(--text-dim); }
.stats-table tbody th { font-weight: 400; }
.stats-table input { max-width: 6.5rem; padding-top: 5px; padding-bottom: 5px; }
.stats-table .num { width: 3.5rem; }
.stats-table .total { font-weight: 700; color: var(--q-normal); }
.stats-table .total[data-quality="magic"] { color: var(--q-magic); }

@media (max-width: 560px) {
  .stats-table thead th { font-size: 0.75rem; }
  .stats-table input { padding: 6px; }
}

.points-left { margin: 8px 0 0; font-weight: 500; }
.levelup-note { margin: 4px 0 10px; padding: 8px 12px; color: var(--text); background: rgb(255 168 0 / 0.08); border-left: 3px solid var(--q-crafted); }
#attributes-title { scroll-margin-top: calc(var(--topbar-height) + 16px); }

/* ---- Gear: a row per slot, click to edit ---- */

.gear h4 { font-family: var(--font-display); font-weight: 400; font-size: var(--step-0); color: var(--text-dim); margin: 14px 0 6px; }
.gear-layout h4:first-child { margin-top: 0; }
.gear-status { margin: 4px 0 8px; }
.gear-status:empty { margin: 0; }
.gear-status .link-button { margin-left: 12px; }

/* Side by side only when the editor is wide enough for both. */
.gear { container-type: inline-size; }
.gear-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px 24px;
  align-items: start;
}
@container (min-width: 40rem) {
  .gear-layout { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
}

.gear-list { display: flex; flex-direction: column; gap: 3px; margin: 0 0 10px; padding: 0; list-style: none; }

/* Slot name, art, item name, then any note: a sunken row like a stash cell. */
.gear-slot {
  display: grid;
  grid-template-columns: 6.5rem 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 2.3rem;
  padding: 3px 12px;
  font: inherit;
  font-size: var(--step--1);
  line-height: 1.25;
  text-align: left;
  color: var(--text);
  background: rgb(0 0 0 / 0.45);
  border: 1px solid #2e2a25;
  border-radius: var(--radius);
  box-shadow: var(--well);
  cursor: pointer;
}
.gear-slot:hover:not(:disabled) { border-color: var(--q-socketed); background: rgb(0 0 0 / 0.6); }
.gear-slot:disabled { cursor: default; }
.gear-slot .footprint, .gear-slot .footprint-none { justify-self: center; }
.gear-slot-label { color: var(--text-dim); }
.gear-slot-name { overflow-wrap: anywhere; }
.gear-slot.empty { background: rgb(0 0 0 / 0.2); box-shadow: none; border-style: dashed; }
.gear-slot.empty .gear-slot-name { color: #6d655a; font-style: italic; }
.gear-slot-note { font-size: 0.75rem; color: var(--text-dim); text-align: right; }
.gear-slot-note.req { color: var(--q-red); }
@media (max-width: 560px) {
  .gear-slot { grid-template-columns: 5rem 24px minmax(0, 1fr); }
  .gear-slot-note { grid-column: 3; text-align: left; }
}

/* ---- The item dialog ---- */

.gear-dialog {
  width: min(56rem, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  color: var(--text);
  background: var(--stone-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.gear-dialog::backdrop { background: rgb(0 0 0 / 0.65); }
.dialog-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 16px 22px 12px;
  background: var(--stone-raised);
  border-bottom: 1px solid var(--line);
}
.dialog-head h2 { font-size: var(--step-2); }
.gear-dialog > :not(.dialog-head) { padding: 16px 22px 22px; }
.dialog-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 18px; }

.pick input[type="search"] { margin: 10px 0 12px; }
.pick-list { list-style: none; margin: 0; padding: 0; max-height: 55dvh; overflow-y: auto; }
.pick-list > li.hint { padding: 8px 0; }
button.pick {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 6px 8px;
  font: inherit;
  text-align: left;
  color: var(--text);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
button.pick:hover, button.pick:focus-visible { background: rgb(255 255 255 / 0.05); }
.pick-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pick-name { color: var(--q-normal); }
.pick-name[data-quality="unique"] { color: var(--q-unique); }
.pick-name[data-quality="set"] { color: var(--q-set); }
.pick-name[data-quality="magic"] { color: var(--q-magic); }
.pick-name[data-quality="rare"] { color: var(--q-rare); }
.pick-name[data-quality="crafted"] { color: var(--q-crafted); }
.pick-meta, .pick-kind { font-size: var(--step--1); color: var(--text-dim); }
.rw-name { color: var(--q-unique); font-family: var(--font-display); font-size: var(--step-1); }

.edit-title { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.edit-title p { margin: 0; font-size: var(--step--1); }
.edit-title .dim { color: var(--text-dim); }
.edit-name { font-family: var(--font-display); font-size: var(--step-2); text-decoration: none; }
.edit-name[data-quality="normal"] { color: var(--q-normal); }
.edit-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 18rem); gap: 20px; align-items: start; }
@media (max-width: 720px) {
  .edit-columns { grid-template-columns: minmax(0, 1fr); }
}
.edit-group { margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.edit-group legend { padding: 0 6px; font-size: var(--step--1); color: var(--text-dim); }
.roll-line { margin: 0 0 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; color: var(--q-magic); }
.roll-line .dim { color: var(--text-dim); font-size: var(--step--1); }
.roll-input, .mod-value { width: 5.5rem; padding: 4px 8px; }
.inline-field { display: flex; align-items: center; gap: 10px; }
.inline-field label { margin: 0; font-weight: 400; }
.inline-field select { width: auto; }
.inline-field.grow { flex: 1; min-width: 12rem; }
.quality-row { display: flex; flex-wrap: wrap; gap: 10px 20px; }
.socket-fillers { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: 6px; margin-top: 10px; }
.mods { margin-top: 12px; }
.mods .hint { margin-bottom: 8px; }
.mod-list { list-style: none; margin: 0 0 10px; padding: 0; }
.mod-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 6px; }
.mod-row select { width: auto; max-width: 100%; }
.item-preview { padding: 16px; }
.item-preview .socket { color: var(--q-magic); opacity: 0.85; }
.item-preview .small { font-size: var(--step--1); margin-top: 8px; }

/* Save stays in reach while the form scrolls: a bar along the bottom of
   the screen, on the panel's own stone. */
.editor-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 24px;
  margin: 28px -24px -24px;
  padding: 14px 24px;
  background-color: var(--stone-raised);
  background-image: var(--stone-surface);
  background-size: var(--stone-surface-size);
  border-top: 1px solid var(--iron);
  box-shadow: 0 -8px 16px -8px rgb(0 0 0 / 0.6);
}
.save-status { color: var(--text-dim); }
