/* Idle Ores Crafting Planner */

:root {
  --bg:        #10141b;
  --bg-raised: #171d27;
  --bg-inset:  #0c1016;
  --line:      #263041;
  --line-soft: #1c2431;
  --text:      #dfe6f0;
  --muted:     #8794a8;
  --accent:    #4ea3ff;
  --accent-dim:#1d4d80;
  --ok:        #4ec98c;
  --warn:      #e2b23c;
  --error:     #ef6b6b;
  --gold:      #e8c25a;
  --radius:    8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 600; }
h1 { font-size: 1.3rem; }
h2 { font-size: 1.05rem; letter-spacing: .01em; }
h3 { font-size: .95rem; margin-top: 1.25rem; color: var(--text); }
h4 { font-size: .85rem; margin-top: 1.1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
p  { margin: 0 0 .75rem; }
a  { color: var(--accent); }

.muted  { color: var(--muted); }
.small  { font-size: .85em; }
.strong { font-weight: 600; }
.num    { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.zero   { color: var(--muted); }
.error  { color: var(--error); }
.ok     { color: var(--ok); }

/* ------------------------------------------------------------------ layout */

.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem;
  padding: .75rem 1rem;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: .5rem; margin-right: auto; }
.brand h1 { margin: 0; }
.topbar-controls { display: flex; gap: .5rem; align-items: center; }

.tabs { display: flex; flex-wrap: wrap; gap: .25rem; width: 100%; }
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); padding: .4rem .7rem; cursor: pointer;
  font: inherit; font-size: .9rem; border-radius: 4px 4px 0 0;
}
.tab:hover { color: var(--text); background: var(--bg-inset); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.wrap { max-width: 1100px; margin: 0 auto; padding: 1rem; }

.panel {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.panel h2 { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* Panels that fold away. Closed by default; the summary stays informative while shut. */
.panel.collapsible { padding: 0; }
.panel.collapsible > summary {
  padding: .8rem 1rem; cursor: pointer;
  display: flex; align-items: baseline; justify-content: space-between;
  gap: .5rem 1rem; flex-wrap: wrap;
}
.panel.collapsible > summary:hover { background: var(--bg-inset); }
.panel.collapsible > summary::-webkit-details-marker { color: var(--muted); }
.panel.collapsible[open] > summary { border-bottom: 1px solid var(--line); }
.panel-title { font-size: 1.05rem; font-weight: 600; letter-spacing: .01em; }
.panel-hint { margin-left: auto; text-align: right; }
.panel-body { padding: 1rem; }
.panel-body > h3:first-child { margin-top: 0; }

/* ------------------------------------------------------------------ tables */

.grid { width: 100%; border-collapse: collapse; font-size: .92rem; }
.grid th, .grid td { padding: .4rem .55rem; border-bottom: 1px solid var(--line-soft); }
.grid th {
  text-align: left; color: var(--muted); font-weight: 600;
  font-size: .78rem; text-transform: uppercase; letter-spacing: .05em;
  border-bottom-color: var(--line);
}
.grid tbody tr:hover { background: var(--bg-inset); }
.grid .total td { border-top: 1px solid var(--line); font-weight: 600; }

.stats td.strong { color: var(--gold); }
.stats tr.covered td { color: var(--muted); }
.stats tr.covered .done { color: var(--ok); }

.item-name { font-weight: 500; }

/* ------------------------------------------------------------------ inputs */

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

input[type="text"], input[type="search"], select, textarea {
  background: var(--bg-inset);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: .4rem .55rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-dim); outline-offset: 1px; }

.qty-input   { width: 8.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.name-input  { min-width: 12rem; }
.item-picker { flex: 1 1 16rem; min-width: 0; }
.search      { width: 100%; max-width: 22rem; }

.button {
  background: var(--bg-inset); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: .4rem .8rem; cursor: pointer; text-decoration: none;
  display: inline-block; white-space: nowrap;
}
.button:hover  { border-color: var(--accent-dim); background: #131a24; }
.button.primary { background: var(--accent-dim); border-color: var(--accent); color: #eaf4ff; }
.button.primary:hover { background: #235c96; }
.button.danger:hover { border-color: var(--error); color: var(--error); }
.button.subtle { font-size: .85rem; padding: .3rem .6rem; }

.link {
  background: none; border: 0; padding: 0; color: var(--accent);
  cursor: pointer; font: inherit; text-align: left; text-decoration: underline;
  text-decoration-color: var(--accent-dim);
}
.link:hover { text-decoration-color: var(--accent); }

.toggle { display: inline-flex; align-items: center; gap: .3rem; font-size: .88rem; color: var(--muted); font-weight: 400; }
.toggle input { accent-color: var(--accent); }

.row-controls { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .75rem 0; }
.add-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .75rem; }

/* ------------------------------------------------------------- target list */

.target-list { list-style: none; margin: .5rem 0 0; padding: 0; }
.target-list li {
  display: flex; align-items: center; gap: .6rem;
  padding: .35rem 0; border-bottom: 1px solid var(--line-soft);
}
.target-list .item-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.qty-badge { color: var(--gold); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- craft steps */

.steps { list-style: none; counter-reset: none; margin: 0; padding: 0; }
.step { border-left: 2px solid var(--line); padding: .1rem 0 .9rem 1rem; margin-left: .5rem; }
.step:last-child { padding-bottom: 0; }
.step-head { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.step-number {
  display: inline-grid; place-items: center;
  width: 1.5rem; height: 1.5rem; margin-left: -2rem; margin-right: .1rem;
  background: var(--bg-inset); border: 1px solid var(--line);
  border-radius: 50%; font-size: .75rem; color: var(--muted);
}
.step-title strong { color: var(--gold); }

.ingredients { list-style: none; margin: .35rem 0 0; padding: 0; font-size: .9rem; }
.ingredients li { padding: .12rem 0; }
.ingredients .num { display: inline-block; min-width: 4.5rem; color: var(--text); }
.ingredients.columns { columns: 2; column-gap: 1.5rem; }

.coin-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .45rem; }
.coin-chip {
  background: var(--bg-inset); border: 1px solid var(--line);
  border-radius: 999px; padding: .12rem .6rem;
  font-size: .8rem; color: var(--gold); white-space: nowrap;
}

/* --------------------------------------------------------------- inventory */

.inv-group { border: 1px solid var(--line-soft); border-radius: 6px; margin-bottom: .5rem; }
.inv-group summary {
  cursor: pointer; padding: .5rem .7rem;
  display: flex; justify-content: space-between; gap: 1rem; align-items: baseline;
}
.inv-group summary:hover { background: var(--bg-inset); }
.cat-name { font-weight: 600; }

.inv-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: .3rem .9rem; padding: .3rem .7rem .7rem;
}
.inv-grid.coins {
  padding: 0 0 .9rem; margin-bottom: .5rem; border-bottom: 1px solid var(--line);
}
.inv-row { display: flex; align-items: center; gap: .5rem; }
.inv-row .item-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; font-weight: 400; }
.inv-row .qty-input { width: 7rem; flex: 0 0 auto; }

/* ----------------------------------------------------------------- browser */

.browse-layout { display: grid; grid-template-columns: minmax(0, 15rem) minmax(0, 1fr); gap: 1rem; margin-top: .75rem; }
.browse-list {
  max-height: 30rem; overflow-y: auto;
  border: 1px solid var(--line-soft); border-radius: 6px; padding: .25rem;
}
.browse-item {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; color: var(--text);
  padding: .3rem .5rem; border-radius: 4px; cursor: pointer; font-size: .9rem;
}
.browse-item:hover { background: var(--bg-inset); color: var(--accent); }
.detail { min-width: 0; }

/* Craftable-now shortfall lists */
.grid .group-row td {
  background: var(--bg-inset); color: var(--muted);
  font-size: .75rem; text-transform: uppercase; letter-spacing: .07em;
  padding-top: .5rem; padding-bottom: .3rem; border-bottom-color: var(--line);
}
.needs td { vertical-align: top; }
.need-list { display: flex; flex-wrap: wrap; gap: .3rem; }
.need-chip {
  background: var(--bg-inset); border: 1px solid var(--line-soft);
  border-radius: 4px; padding: .1rem .45rem; font-size: .85rem; white-space: nowrap;
}
.need-chip .num { color: var(--gold); }
.need-chip.coins { border-color: var(--accent-dim); }
.need-chip.coins .num { color: var(--accent); }

/* Intro card on an empty plan */
.panel.intro { border-color: var(--accent-dim); background: linear-gradient(180deg, #14202e 0%, var(--bg-raised) 60%); }
.panel.intro h2 { color: var(--accent); }
.panel.intro p { max-width: 62ch; }

/* Gather quick-add */
.action-col { width: 1%; white-space: nowrap; }
.gather-add { display: flex; gap: .3rem; align-items: center; justify-content: flex-end; }
.qty-input.mini { width: 6.5rem; }

/* Undo */
.button.undo { border-color: var(--warn); color: var(--warn); }
.button.undo:hover { background: #2b2413; }

/* Credits */
.credits-list { list-style: none; margin: 0; padding: 0; }
.credit { padding: .7rem 0; border-bottom: 1px solid var(--line-soft); }
.credit:last-child { border-bottom: 0; }
.credit-who { font-weight: 600; color: var(--gold); font-size: 1.02rem; margin-bottom: .15rem; }
.credit .muted { max-width: 62ch; }

/* Gather sort toggle */
.sort-control { display: flex; align-items: center; gap: .4rem; margin: .25rem 0 .75rem; }
.sort-control .button.active { border-color: var(--accent); color: var(--accent); background: #131f2c; }
.chip-label { align-self: center; margin-right: .1rem; }

/* ---------------------------------------------------------------- banners */

.banner { padding: .6rem .8rem; border-radius: 6px; border: 1px solid var(--line); }
.ok-banner    { border-color: #2c5f47; background: #142a20; color: #a8e8c6; }
.warn-banner  { border-color: #6b5620; background: #2b2413; color: #f0d79a; }
.error-banner { border-color: #6d2f2f; background: #2a1616; color: #f5b8b8; }
.share-banner {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: center;
  margin: 1rem auto; max-width: 1100px;
  border-color: var(--accent-dim); background: #12243a;
}

.issues { margin: 0 0 1rem; padding-left: 1.2rem; }
.issues li { margin: .2rem 0; }
.issues li.error { color: #f5b8b8; }
.issues li.warn  { color: #f0d79a; }

.code {
  width: 100%; font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: .82rem; line-height: 1.45; resize: vertical;
}

.check-page .topbar { justify-content: space-between; }

/* ----------------------------------------------------------------- mobile */

@media (max-width: 720px) {
  .browse-layout { grid-template-columns: 1fr; }
  .browse-list { max-height: 14rem; }
  .ingredients.columns { columns: 1; }
  .brand span { display: none; }
  .wrap { padding: .75rem; }
  .panel { padding: .75rem; }
  .grid th, .grid td { padding: .35rem .3rem; }
  .qty-input { width: 6rem; }
}
