* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #0d0f14;
  color: #d4c9a8;
  font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, 'Georgia', serif;
  min-height: 100vh;
}

#app { display: flex; flex-direction: column; min-height: 100vh; }

/* ── Header ─────────────────────────────────────────── */
#header {
  border-bottom: 1px solid #2a2510;
  padding: 1.5rem 2rem 1rem;
  background: linear-gradient(180deg, #13100a 0%, #0d0f14 100%);
}
#header > div { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.header-title-group { display: flex; align-items: center; gap: 1rem; }
#header h1 {
  font-size: 26px; font-weight: normal; letter-spacing: 0.12em;
  color: #c8a96e; text-transform: uppercase;
}
#location-count { font-size: 13px; color: #5a5040; letter-spacing: 0.06em; }
.subtitle { margin-top: 0.4rem; font-size: 13px; color: #5a5040; font-style: italic; }

/* ── Layout ─────────────────────────────────────────── */
#layout { display: flex; flex: 1; }

/* ── Sidebar ────────────────────────────────────────── */
#sidebar {
  width: 220px; min-width: 220px; border-right: 1px solid #1e1c14;
  padding: 1rem 0 95px; background: #0b0d11; overflow-y: auto;
  display: flex; flex-direction: column;
}
.sidebar-label {
  font-size: 10px; letter-spacing: 0.15em; color: #3a3020;
  text-transform: uppercase; padding: 0 1rem; margin-bottom: 0.75rem;
}
.sidebar-divider { border-top: 1px solid #1e1c14; margin-top: 0.5rem; padding-top: 0.5rem; }
.sidebar-btn {
  width: 100%; background: transparent; border: none; border-left: 3px solid transparent;
  padding: 0.6rem 1rem; text-align: left; cursor: pointer;
  color: #5a5040; font-family: inherit; font-size: 14px; transition: all 0.15s;
}
.sidebar-btn:hover { color: #9a8e6e; }
.sidebar-btn.active { background: #161210; color: #d4c9a8; }
.sidebar-btn .size-label { font-size: 11px; margin-top: 2px; opacity: 0.8; }
.sidebar-add { padding: 0.75rem 1rem 0; margin-top: auto; }
.btn-add {
  width: 100%; background: none; border: 1px dashed #2a2518; border-radius: 3px;
  color: #4a4030; font-family: inherit; font-size: 12px; letter-spacing: 0.08em;
  padding: 0.5rem; cursor: pointer; transition: all 0.15s;
}
.btn-add:hover { border-color: #5a5030; color: #7a7050; }

/* ── Main ───────────────────────────────────────────── */
#main-content { flex: 1; padding: 1.5rem 2rem 7rem; overflow-y: auto; }

/* ── City header ────────────────────────────────────── */
.city-header { margin-bottom: 1.5rem; }
.city-header-row { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.city-name { font-size: 32px; font-weight: normal; color: #e8ddb8; letter-spacing: 0.08em; }
.city-name-input {
  background: transparent; border: none; border-bottom: 1px solid #3a3020;
  outline: none; color: #e8ddb8; font-family: inherit; font-size: 28px;
  width: 100%; padding: 0 0 4px; margin-bottom: 0.5rem;
}
.size-badge {
  font-size: 12px; padding: 3px 10px; border-radius: 2px;
  letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 4px;
}
.traits-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 0.6rem; }
.trait-tag {
  font-size: 12px; color: #7a7060; background: #161410;
  padding: 2px 8px; border-radius: 2px; border: 1px solid #2a2518;
}

/* ── Tabs ───────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 1px solid #2a2518; margin-bottom: 1.5rem; }
.tab-btn {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: #5a5040; font-family: inherit; font-size: 13px; letter-spacing: 0.1em;
  text-transform: uppercase; padding: 0.5rem 1.25rem; cursor: pointer;
  margin-bottom: -1px; transition: color 0.15s;
}
.tab-btn:hover { color: #9a8e6e; }
.tab-btn.active { border-bottom-color: #c8a96e; color: #c8a96e; }

/* ── Stat boxes ─────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 1.5rem; }
.stat-box {
  background: #10100e; border: 1px solid #1e1c14; border-radius: 3px; padding: 0.75rem 1rem;
}
.stat-label {
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: #4a4030; margin-bottom: 4px;
}
.stat-val { font-size: 20px; color: #c8a96e; }

/* ── Flavor quote ───────────────────────────────────── */
.flavor-quote {
  font-size: 15px; font-style: italic; color: #9a8e6e; line-height: 1.7;
  border-left: 3px solid #2a2518; padding-left: 1rem; margin-bottom: 1.5rem;
}

/* ── Content boxes ──────────────────────────────────── */
.box { background: #10100e; border: 1px solid #1e1c14; border-radius: 3px; padding: 1rem; }
.box-label {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: #4a4030; margin-bottom: 0.6rem;
}
.box-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.list-item { font-size: 13px; color: #9a8e6e; padding: 3px 0; border-bottom: 1px solid #1a1810; }

/* ── Shop/Faction cards grid ────────────────────────── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.card-btn {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; background: #10100e; border: 1px solid #1e1c14;
  border-radius: 3px; cursor: pointer; text-align: left; width: 100%;
  font-family: inherit; transition: background 0.15s;
}
.card-btn:hover { background: #161410; }
.card-btn .card-name { font-size: 13px; color: #a09070; }
.card-btn .card-count { font-size: 16px; font-weight: bold; color: #c8a96e; min-width: 24px; text-align: right; }
.card-btn .dot { margin-left: 6px; font-size: 10px; color: #5a5030; }
.card-btn.has-note { border-color: #3a3020; }
.footer-note { font-size: 12px; color: #3a3020; margin-top: 1rem; font-style: italic; }
.fav-btn {
  background: none; border: none; cursor: pointer; padding: 3px 4px;
  color: #3a3020; display: flex; align-items: center; flex-shrink: 0;
  line-height: 1; border-radius: 2px; transition: color 0.15s;
}
.fav-btn:hover { color: #c8a96e; }
.fav-btn.fav-active { color: #c8a96e; }

/* ── Faction card colors ────────────────────────────── */
.faction-danger { background: #3a1a1a; border-color: #6b2f2f; }
.faction-danger .card-name, .faction-danger .card-count { color: #e07070; }
.faction-warning { background: #2e2410; border-color: #6b5020; }
.faction-warning .card-name, .faction-warning .card-count { color: #d4a550; }
.faction-neutral { background: #1a1e2e; border-color: #2e3a5e; }
.faction-neutral .card-name, .faction-neutral .card-count { color: #8090c0; }
.faction-nature { background: #162213; border-color: #2a4a30; }
.faction-nature .card-name, .faction-nature .card-count { color: #5db87a; }
.faction-arcane { background: #1e1530; border-color: #3d2870; }
.faction-arcane .card-name, .faction-arcane .card-count { color: #a07ed8; }

/* ── Faction legend ─────────────────────────────────── */
.faction-legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 1rem; }
.faction-legend span { font-size: 11px; letter-spacing: 0.06em; }

/* ── Detail page ────────────────────────────────────── */
.back-btn {
  background: none; border: none; color: #5a5040; font-family: inherit;
  font-size: 13px; cursor: pointer; padding: 0 0 1rem; letter-spacing: 0.06em;
}
.back-btn:hover { color: #9a8e6e; }
.detail-header {
  border-radius: 3px; padding: 1rem 1.25rem; margin-bottom: 1.5rem;
  display: flex; justify-content: space-between; align-items: flex-start;
}
.detail-label { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.6; margin-bottom: 4px; }
.detail-title { font-size: 20px; font-weight: normal; }
.detail-count-label { font-size: 11px; opacity: 0.5; letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 2px; }
.detail-count { font-size: 28px; font-weight: bold; }

/* ── Instance buttons ───────────────────────────────── */
.instance-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 1.5rem; }
.instance-btn {
  padding: 6px 14px; background: #10100e; border: 1px solid #1e1c14;
  border-radius: 3px; font-size: 12px; color: #5a5040; letter-spacing: 0.06em;
  cursor: pointer; font-family: inherit; transition: all 0.15s;
  display: flex; align-items: center; gap: 5px;
}
.instance-btn.active { border-color: #c8a96e; color: #c8a96e; }
.instance-btn.has-note { border-color: #3a3020; color: #7a7050; }
.instance-btn .dot { font-size: 8px; opacity: 0.7; }
.instance-btn .pencil { font-size: 8px; opacity: 0.4; }
.instance-rename-input {
  background: transparent; border: none; outline: none;
  color: #c8a96e; font-family: inherit; font-size: 12px; letter-spacing: 0.06em;
}
.instance-rename-wrap {
  display: flex; align-items: center; gap: 4px; padding: 3px 6px;
  border: 1px solid #c8a96e; border-radius: 3px; background: #10100e;
}

/* ── Section label ──────────────────────────────────── */
.section-label {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: #3a3020; margin-bottom: 0.6rem;
}
.section-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; }

/* ── Textarea & inputs ──────────────────────────────── */
.note-textarea {
  width: 100%; min-height: 220px; background: #0a0a08; border: 1px solid #2a2518;
  border-radius: 3px; color: #c8b880; font-family: inherit; font-size: 14px;
  line-height: 1.7; padding: 0.75rem 1rem; resize: vertical; outline: none;
}
.note-textarea:focus { border-color: #4a4030; }
.edit-textarea {
  width: 100%; min-height: 90px; background: #0a0a08; border: 1px solid #2a2518;
  border-radius: 3px; color: #c8b880; font-family: inherit; font-size: 14px;
  line-height: 1.7; padding: 0.5rem 0.75rem; resize: vertical; outline: none;
}
.edit-textarea:focus { border-color: #4a4030; }
.edit-input {
  background: #0a0a08; border: 1px solid #2a2518; border-radius: 3px;
  color: #c8b880; font-family: inherit; font-size: 13px; padding: 5px 10px; outline: none;
}
.edit-input:focus { border-color: #4a4030; }

/* ── Save button ────────────────────────────────────── */
.save-row { display: flex; justify-content: flex-end; margin-top: 0.6rem; }
.btn-save {
  background: #10100e; border: 1px solid #1e1c14; border-radius: 3px;
  color: #3a3020; font-family: inherit; font-size: 13px; letter-spacing: 0.08em;
  padding: 6px 18px; cursor: pointer; transition: all 0.15s;
}
.btn-save:hover { border-color: #4a4020; }
.btn-save.dirty { background: #1e1c10; border-color: #4a4020; color: #c8a96e; }
.btn-save-loc {
  background: #10100e; border: 1px solid #1e1c14; border-radius: 3px;
  color: #3a3020; font-family: inherit; font-size: 13px; letter-spacing: 0.08em;
  padding: 6px 20px; cursor: default; transition: all 0.2s;
}
.btn-save-loc.dirty { background: #1e1c10; border-color: #4a4020; color: #c8a96e; cursor: pointer; }
.save-status { font-size: 11px; transition: color 0.3s; }

/* ── Small buttons ──────────────────────────────────── */
.btn-sm {
  background: #1a180e; border: 1px solid #3a3020; border-radius: 3px;
  color: #c8a96e; font-family: inherit; font-size: 12px; padding: 4px 14px; cursor: pointer;
}
.btn-sm-ghost {
  background: none; border: 1px solid #2a2518; border-radius: 3px;
  color: #5a5040; font-family: inherit; font-size: 12px; padding: 4px 14px; cursor: pointer;
}
.btn-delete {
  background: none; border: 1px solid #2a1818; border-radius: 3px;
  color: #5a3030; font-family: inherit; font-size: 11px; padding: 3px 8px; cursor: pointer;
}
.btn-edit {
  background: none; border: 1px solid #2a2518; border-radius: 3px;
  color: #5a5040; font-family: inherit; font-size: 11px; padding: 3px 8px;
  cursor: pointer; letter-spacing: 0.06em;
}
.btn-dashed {
  width: 100%; background: none; border: 1px dashed #2a2518; border-radius: 3px;
  color: #4a4030; font-family: inherit; font-size: 13px; letter-spacing: 0.08em;
  padding: 0.75rem; cursor: pointer; margin-top: 4px; transition: all 0.15s;
}
.btn-dashed:hover { border-color: #5a5030; color: #7a7050; }
.btn-rename {
  background: none; border: 1px solid #2a2518; border-radius: 3px;
  color: #4a4030; font-family: inherit; font-size: 11px; padding: 2px 8px;
  cursor: pointer; letter-spacing: 0.06em;
}

/* ── Lore cards ─────────────────────────────────────── */
.lore-card {
  padding: 1rem 1.25rem; background: #0e0c09; border: 1px solid #1e1c14;
  border-left: 3px solid #3a3020; border-radius: 3px; margin-bottom: 10px;
  display: flex; align-items: flex-start; gap: 8px; transition: border-color 0.15s;
}
.lore-card:hover { border-left-color: #5a5030; }
.lore-card p { flex: 1; font-size: 14px; color: #9a8e6e; line-height: 1.7; font-style: italic; }
.lore-card-editing {
  background: #0e0c09; border: 1px solid #4a4020; border-left: 3px solid #c8a96e;
  border-radius: 3px; padding: 0.75rem 1rem; margin-bottom: 10px;
}
.lore-btns { display: flex; gap: 6px; flex-shrink: 0; padding-top: 2px; }

/* ── Tags ───────────────────────────────────────────── */
.tag-list { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.tag {
  display: flex; align-items: center; gap: 4px; font-size: 12px;
  padding: 2px 8px; background: #161410; border: 1px solid #2a2518;
  border-radius: 2px; color: #9a8e6e;
}
.tag .btn-x {
  background: none; border: none; color: #5a3030; cursor: pointer; padding: 0; font-size: 11px; line-height: 1;
}
.tag-input-row { display: flex; gap: 6px; }
.tag-input {
  flex: 1; background: #0a0a08; border: 1px solid #2a2518; border-radius: 3px;
  color: #c8b880; font-family: inherit; font-size: 13px; padding: 4px 8px; outline: none;
}
.tag-input:focus { border-color: #4a4030; }

/* ── Shop/faction editor rows ───────────────────────── */
.sf-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.sf-row.sf-header { color: #5a5040; font-weight: 600; }
.sf-row .sf-name { flex: 1; font-size: 13px; color: #9a8e6e; }
.sf-row .sf-count { font-size: 13px; color: #c8a96e; min-width: 20px; text-align: center; }
.sf-row .sf-type { font-size: 11px; color: #5a5040; min-width: 50px; }
.sf-add-row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.sf-input {
  background: #0a0a08; border: 1px solid #2a2518; border-radius: 3px;
  color: #c8b880; font-family: inherit; font-size: 13px; padding: 4px 8px; outline: none;
}
.sf-input:focus { border-color: #4a4030; }
.sf-select {
  background: #0a0a08; border: 1px solid #2a2518; border-radius: 3px;
  color: #c8b880; font-family: inherit; font-size: 12px; padding: 4px 6px; outline: none;
}

/* ── Custom location section labels ─────────────────── */
.custom-section-label {
  margin: 1.25rem 0 0.5rem; font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: #4a4030;
}
.custom-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.75rem;
}

/* ── Popup ──────────────────────────────────────────── */
.popup-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.popup-overlay.hidden { display: none; }
.popup-card {
  background: #13110e; border: 1px solid #3a3020; border-radius: 6px;
  padding: 2rem; width: 340px; font-family: inherit;
}
.popup-label { font-size: 11px; letter-spacing: 0.15em; text-transform: uppercase; color: #5a5040; margin-bottom: 0.4rem; }
.popup-title { font-size: 20px; font-weight: normal; color: #c8a96e; margin-bottom: 1.5rem; }
.popup-desc { font-size: 13px; color: #7a6e50; margin-bottom: 1rem; }
.popup-options { display: flex; flex-direction: column; gap: 10px; }
.popup-option {
  background: #0e0c09; border: 1px solid #2a2518; border-radius: 4px;
  padding: 0.75rem 1rem; cursor: pointer; text-align: left; font-family: inherit;
  transition: border-color 0.15s;
}
.popup-option:hover { border-color: #5a504088; }
.popup-option-title { font-size: 14px; margin-bottom: 3px; }
.popup-option-desc { font-size: 12px; color: #5a5040; line-height: 1.4; }
.popup-cancel {
  margin-top: 1.25rem; background: none; border: none; color: #4a4030;
  font-family: inherit; font-size: 12px; cursor: pointer; letter-spacing: 0.06em;
}

/* ── Hotbar ─────────────────────────────────────────── */
#hotbar {
  position: fixed; bottom: 0; left: 0; right: 0; height: 88px;
  background: #0b0d11; border-top: 1px solid #1e1c14; display: flex;
  justify-content: center; align-items: center; gap: 20px; z-index: 50;
}
.hotbar-btn {
  width: 50px; height: 50px; border-radius: 50%; background: #10100e;
  border: 1px solid #2a2518; color: #5a5040; display: flex; align-items: center;
  justify-content: center; cursor: pointer; transition: all 0.15s;
}
.hotbar-btn:hover { border-color: #5a5030; color: #9a8e6e; }
.hotbar-btn.active { background: #161210; border-color: #c8a96e; color: #c8a96e; }
.hotbar-btn svg { width: 24px; height: 24px; }

/* ── Global search ──────────────────────────────────────────────────────── */
.header-search-wrap { position: relative; flex-shrink: 0; }
.global-search-input {
  background: #0a0a08; border: 1px solid #2a2518; border-radius: 3px;
  color: #c8b880; font-family: inherit; font-size: 13px;
  padding: 6px 10px 6px 32px; outline: none; width: 200px;
  transition: border-color 0.15s, width 0.2s;
}
.global-search-input:focus { border-color: #4a4030; width: 260px; }
.global-search-input::placeholder { color: #3a3020; }
.search-icon {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  color: #3a3020; pointer-events: none; width: 15px; height: 15px;
}
.search-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: #0b0d11; border: 1px solid #2a2518; border-radius: 3px;
  z-index: 200; min-width: 300px; max-height: 380px; overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  scrollbar-width: thin; scrollbar-color: #2a2518 transparent;
}
.search-dropdown.hidden { display: none; }
.search-group-label {
  font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase;
  color: #3a3020; padding: 8px 12px 4px;
  border-top: 1px solid #1e1c14; background: #080a0e;
}
.search-result {
  padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #0f0e0c;
  transition: background 0.1s; display: flex; flex-direction: column; gap: 2px;
}
.search-result:hover { background: #161410; }
.search-result-label { font-size: 13px; color: #a09070; }
.search-result-meta { font-size: 11px; color: #5a5040; }
.search-empty { padding: 16px 12px; font-size: 13px; color: #3a3020; font-style: italic; text-align: center; }

/* ── Page headings ──────────────────────────────────────────────────────────── */
.page-title { font-size: 22px; font-weight: normal; color: #c8a96e; letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 0.25rem; }
.page-subtitle-sm { font-size: 13px; color: #5a5040; font-style: italic; }

/* ── Favorites panels ────────────────────────────────────────────────────────── */
.fav-panel { background: #0b0d11; border: 1px solid #1e1c14; border-radius: 3px; overflow: hidden; display: flex; flex-direction: column; }
.fav-panel-header { padding: 8px 12px; border-bottom: 1px solid #1e1c14; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.fav-panel-count { font-size: 11px; color: #3a3020; }
.fav-row { padding: 7px 12px; border-bottom: 1px solid #131210; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.fav-row:hover { background: #161410; }
.fav-row-body { flex: 1; min-width: 0; }
.fav-row-label { font-size: 13px; color: #a09070; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fav-row-meta { font-size: 11px; color: #5a5040; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fav-empty { padding: 18px 12px; text-align: center; color: #252010; font-size: 12px; font-style: italic; }

/* ── Settings sections ───────────────────────────────────────────────────────── */
.settings-section { border-radius: 2px; padding: 1.25rem 1.5rem; margin-bottom: 1.5rem; }
.ss-appearance { background: #10100e; border: 1px solid #1e1c14; border-left: 3px solid #c8a96e; }
.ss-races      { background: #0e1214; border: 1px solid #1e2a1e; border-left: 3px solid #5db87a; }
.ss-stores     { background: #0e1214; border: 1px solid #1e1e14; border-left: 3px solid #d4a550; }
.ss-factions   { background: #0e1214; border: 1px solid #1a1e2e; border-left: 3px solid #5a8ab0; }
.ss-data       { background: #0e0c0a; border: 1px solid #2a2010; border-left: 3px solid #7a5a30; }
.settings-section-title { font-size: 14px; color: #d4c9a8; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 3px; }
.settings-section-sub { font-size: 12px; color: #5a5040; font-style: italic; }
.ss-sub { border-radius: 2px; padding: 0.75rem 1rem; margin-bottom: 1rem; }
.ss-sub-races    { background: #0a0c0a; border: 1px solid #1e2a1e; }
.ss-sub-stores   { background: #0a0c0a; border: 1px solid #2a2010; }
.ss-sub-factions { background: #0a0c0e; border: 1px solid #1a2030; }
.ss-sub-label { font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase; margin-bottom: 0.5rem; }
.ss-sub-label-green { color: #3a5a3a; }
.ss-sub-label-gold  { color: #5a4a20; }
.ss-sub-label-blue  { color: #2a3a5a; }

/* ── Light mode ──────────────────────────────────────────────────────────── */
body.light-mode { background: #f5f0e5; color: #2a2010; }
body.light-mode #header { background: linear-gradient(180deg, #ece4cc 0%, #f0ead8 100%); border-bottom-color: #d4c8a0; }
body.light-mode #header h1 { color: #7a5e14; }
body.light-mode #location-count { color: #9a8860; }
body.light-mode .subtitle { color: #9a8860; }
body.light-mode .mobile-menu-toggle { color: #9a8860; }
body.light-mode #sidebar { background: #ede5d0; border-right-color: #d4c8a0; }
body.light-mode .sidebar-label { color: #c8b890; }
body.light-mode .sidebar-divider { border-top-color: #d4c8a0; }
body.light-mode .sidebar-btn { color: #9a8860; }
body.light-mode .sidebar-btn:hover { color: #3a2a10; }
body.light-mode .sidebar-btn.active { background: #e0d8c0; color: #2a2010; }
body.light-mode .btn-add { border-color: #c8b890; color: #9a8860; }
body.light-mode .btn-add:hover { border-color: #7a6030; color: #5a4020; }
body.light-mode #hotbar { background: #ede5d0; border-top-color: #d4c8a0; }
body.light-mode .hotbar-btn { background: #e0d8c0; border-color: #c8b890; color: #9a8860; }
body.light-mode .hotbar-btn:hover { border-color: #7a6030; color: #5a4020; }
body.light-mode .hotbar-btn.active { background: #d8cc9e; border-color: #7a5e14; color: #7a5e14; }
body.light-mode .tabs { border-bottom-color: #d4c8a0; }
body.light-mode .tab-btn { color: #9a8860; }
body.light-mode .tab-btn:hover { color: #3a2a10; }
body.light-mode .tab-btn.active { border-bottom-color: #7a5e14; color: #7a5e14; }
body.light-mode .stat-box { background: #ede8d8; border-color: #d4c8a0; }
body.light-mode .stat-label { color: #9a8860; }
body.light-mode .stat-val { color: #7a5e14; }
body.light-mode .flavor-quote { color: #6a5a40; border-left-color: #d4c8a0; }
body.light-mode .box { background: #ede8d8; border-color: #d4c8a0; }
body.light-mode .box-label { color: #9a8860; }
body.light-mode .list-item { color: #5a4020; border-bottom-color: #d4c8a0; }
body.light-mode .card-btn { background: #ede8d8; border-color: #d4c8a0; }
body.light-mode .card-btn:hover { background: #e0d8c0; }
body.light-mode .card-btn .card-name { color: #5a4020; }
body.light-mode .card-btn .card-count { color: #7a5e14; }
body.light-mode .back-btn { color: #9a8860; }
body.light-mode .back-btn:hover { color: #3a2a10; }
body.light-mode .section-label { color: #9a8860; }
body.light-mode .lore-card { background: #f0ead8; border-color: #d4c8a0; border-left-color: #c8b890; }
body.light-mode .lore-card:hover { border-left-color: #7a6030; }
body.light-mode .lore-card p { color: #5a4020; }
body.light-mode .lore-card-editing { background: #f8f4ec; border-color: #c8b890; border-left-color: #7a6030; }
body.light-mode .note-textarea { background: #f8f4ec; border-color: #c8b890; color: #2a2010; }
body.light-mode .note-textarea:focus { border-color: #8a7040; }
body.light-mode .edit-textarea { background: #f8f4ec; border-color: #c8b890; color: #2a2010; }
body.light-mode .edit-textarea:focus { border-color: #8a7040; }
body.light-mode .edit-input { background: #f8f4ec; border-color: #c8b890; color: #2a2010; }
body.light-mode .edit-input:focus { border-color: #8a7040; }
body.light-mode .sf-input, body.light-mode .sf-select, body.light-mode .tag-input { background: #f8f4ec; border-color: #c8b890; color: #2a2010; }
body.light-mode .btn-save { background: #ede8d8; border-color: #d4c8a0; color: #9a8860; }
body.light-mode .btn-save.dirty { background: #e8e0cc; border-color: #7a6030; color: #7a5e14; }
body.light-mode .btn-save-loc { background: #ede8d8; border-color: #d4c8a0; color: #9a8860; }
body.light-mode .btn-save-loc.dirty { background: #e8e0cc; border-color: #7a6030; color: #7a5e14; cursor: pointer; }
body.light-mode .btn-sm { background: #e8e0cc; border-color: #c8b890; color: #7a5e14; }
body.light-mode .btn-sm-ghost { border-color: #d4c8a0; color: #9a8860; }
body.light-mode .btn-dashed { border-color: #c8b890; color: #9a8860; }
body.light-mode .btn-dashed:hover { border-color: #7a6030; color: #5a4020; }
body.light-mode .btn-delete { border-color: #d4a0a0; color: #8a4040; }
body.light-mode .btn-edit, body.light-mode .btn-rename { border-color: #d4c8a0; color: #9a8860; }
body.light-mode .instance-btn { background: #ede8d8; border-color: #d4c8a0; color: #9a8860; }
body.light-mode .instance-btn.active { border-color: #7a5e14; color: #7a5e14; }
body.light-mode .instance-btn.has-note { border-color: #c8b890; color: #7a6840; }
body.light-mode .trait-tag { color: #6a5a40; background: #e8e0cc; border-color: #c8b890; }
body.light-mode .tag { background: #e8e0cc; border-color: #c8b890; color: #5a4020; }
body.light-mode .city-name { color: #2a2010; }
body.light-mode .city-name-input { color: #2a2010; border-bottom-color: #c8b890; }
body.light-mode .footer-note { color: #9a8860; }
body.light-mode .fav-btn { color: #c8b890; }
body.light-mode .fav-btn:hover, body.light-mode .fav-btn.fav-active { color: #7a5e14; }
body.light-mode .popup-overlay { background: rgba(0,0,0,0.4); }
body.light-mode .popup-card { background: #f0ead8; border-color: #c8b890; }
body.light-mode .popup-label { color: #9a8860; }
body.light-mode .popup-title { color: #7a5e14; }
body.light-mode .popup-desc { color: #7a6840; }
body.light-mode .popup-option { background: #ede8d8; border-color: #d4c8a0; }
body.light-mode .popup-option:hover { border-color: #9a8060; }
body.light-mode .popup-cancel { color: #9a8860; }
body.light-mode #sidebar-backdrop { background: rgba(0,0,0,0.3); }
body.light-mode .hotbar-disabled { opacity: 0.3; }
body.light-mode .global-search-input { background: #f8f4ec; border-color: #c8b890; color: #2a2010; }
body.light-mode .global-search-input:focus { border-color: #8a7040; }
body.light-mode .global-search-input::placeholder { color: #c8b890; }
body.light-mode .search-icon { color: #c8b890; }
body.light-mode .search-dropdown { background: #f0ead8; border-color: #c8b890; box-shadow: 0 4px 20px rgba(0,0,0,0.15); }
body.light-mode .search-group-label { color: #c8b890; background: #ece5d5; border-top-color: #d4c8a0; }
body.light-mode .search-result { border-bottom-color: #e0d8c8; }
body.light-mode .search-result:hover { background: #e8e0cc; }
body.light-mode .search-result-label { color: #5a4020; }
body.light-mode .search-result-meta { color: #9a8860; }
body.light-mode .search-empty { color: #9a8860; }
body.light-mode .page-title { color: #7a5e14; }
body.light-mode .page-subtitle-sm { color: #9a8860; }
body.light-mode .fav-panel { background: #ede8d8; border-color: #d4c8a0; }
body.light-mode .fav-panel-header { border-bottom-color: #d4c8a0; }
body.light-mode .fav-panel-count { color: #9a8860; }
body.light-mode .fav-row { border-bottom-color: #d4c8a0; }
body.light-mode .fav-row:hover { background: #e0d8c0; }
body.light-mode .fav-row-label { color: #5a4020; }
body.light-mode .fav-row-meta { color: #9a8860; }
body.light-mode .fav-empty { color: #c8b890; }
body.light-mode .settings-section-title { color: #2a2010; }
body.light-mode .settings-section-sub { color: #9a8860; }
body.light-mode .ss-appearance { background: #f0ead8; border-color: #d4c8a0; border-left-color: #7a5e14; }
body.light-mode .ss-races      { background: #eef5ee; border-color: #c0d0c0; border-left-color: #3a8a5a; }
body.light-mode .ss-stores     { background: #f5f0e8; border-color: #d0c8a0; border-left-color: #9a7820; }
body.light-mode .ss-factions   { background: #eeeff5; border-color: #c0c0d4; border-left-color: #4a6a9a; }
body.light-mode .ss-data       { background: #f0ece8; border-color: #d0c0a8; border-left-color: #7a5a30; }
body.light-mode .ss-sub-races    { background: #e8f0e8; border-color: #c0d0c0; }
body.light-mode .ss-sub-stores   { background: #f0ece0; border-color: #d4c4a0; }
body.light-mode .ss-sub-factions { background: #e8eaf0; border-color: #c0c8d4; }
body.light-mode .ss-sub-label-green { color: #5a8a5a; }
body.light-mode .ss-sub-label-gold  { color: #8a6a30; }
body.light-mode .ss-sub-label-blue  { color: #4a5a8a; }
body.light-mode .editor-header {
  background: #f0ead8 !important;
  border-top-color: #d4c8a0 !important;
  border-right-color: #d4c8a0 !important;
  border-bottom-color: #d4c8a0 !important;
}

/* ── PC editor responsive grids ─────────────────────────────────────────── */
.pc-combat-grid   { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.pc-passives-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

/* ── Mobile menu toggle (hidden on desktop/tablet) ──────────────────────── */
.mobile-menu-toggle {
  display: none;
  background: none; border: none; color: #5a5040; cursor: pointer;
  padding: 4px; border-radius: 4px; align-items: center; justify-content: center;
  flex-shrink: 0; transition: color 0.15s;
}
.mobile-menu-toggle:hover { color: #9a8e6e; }

/* ── Sidebar backdrop (mobile overlay, JS-controlled) ───────────────────── */
#sidebar-backdrop {
  display: none; position: fixed; inset: 0; bottom: 88px;
  background: rgba(0, 0, 0, 0.6); z-index: 59;
}
#sidebar-backdrop.active { display: block; }

/* ── Mobile overrides (≤767px) ───────────────────────────────────────────── */
@media (max-width: 767px) {
  /* Show hamburger; wrap header so search drops to its own row */
  .mobile-menu-toggle { display: flex; }
  #header > div { flex-wrap: wrap; }

  /* Search — full width below title on mobile */
  .header-search-wrap { width: 100%; }
  .global-search-input { width: 100% !important; box-sizing: border-box; }
  .search-dropdown { right: auto; left: 0; min-width: 100%; }

  /* Sidebar — slide-in overlay */
  #sidebar {
    position: fixed;
    top: 0; bottom: 88px; left: 0;
    z-index: 60;
    width: 260px; min-width: 260px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    padding-bottom: 1rem;
  }
  #sidebar.sidebar-open { transform: translateX(0); }

  /* Main content fills full width (sidebar is out of flow) */
  #main-content { padding: 1rem 1rem 7rem; }

  /* Hotbar — horizontally scrollable */
  #hotbar {
    justify-content: flex-start;
    overflow-x: auto; overflow-y: hidden;
    padding: 0 20px;
    gap: 18px;
    scrollbar-width: none;
    height: auto;
    padding-top: 14px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
    /* Prevent iOS swipe-between-apps gesture from firing on hotbar swipes */
    touch-action: pan-x;
    overscroll-behavior-x: contain;
  }
  #hotbar::-webkit-scrollbar { display: none; }
  /* Larger touch targets on mobile */
  .hotbar-btn { flex-shrink: 0; width: 72px; height: 72px; border-radius: 14px; }
  .hotbar-btn svg { width: 32px; height: 32px; }
  /* Extra bottom padding on main content to clear taller hotbar + safe area */
  #main-content { padding-bottom: calc(9rem + env(safe-area-inset-bottom)); }

  /* Favorites page — single column vertical list */
  .fav-grid { grid-template-columns: 1fr !important; }

  /* Hotbar disabled while sidebar is open */
  .hotbar-disabled { pointer-events: none; opacity: 0.4; }

  /* PC editor — fewer columns so labels don't wrap */
  .pc-combat-grid   { grid-template-columns: repeat(3, 1fr); }
  .pc-passives-grid { grid-template-columns: 1fr; }

  /* Landing mode cards — stack on mobile */
  .mode-card { min-width: 100% !important; max-width: 100% !important; }
}

/* ── Mode selection landing ──────────────────────────────────────────────────── */
#mode-select-overlay {
  position: fixed; inset: 0; z-index: 100;
  overflow-y: auto;
}

.mode-card {
  outline: none;
}
.mode-card:hover {
  border-color: #c8a96e !important;
  box-shadow: 0 0 0 1px #c8a96e40;
}
.body.light-mode .mode-card:hover {
  border-color: #8a6010 !important;
  box-shadow: 0 0 0 1px #8a601040;
}
