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

:root {
  --bg:             #0d0d0d;
  --sidebar-bg:     #111111;
  --sidebar-border: #222;
  --border:         #2a2a2a;
  --text:           #d4c9b8;
  --text-muted:     #6b6360;
  --text-dim:       #9a9085;
  --gold:           #c8a44a;
  --gold-dim:       #7a6530;
  --optional:       #5a7a5a;
  --optional-bg:    #1a2a1a;
  --reward:         #5a9a6a;
  --note:           #7a6a4a;
  --checked-text:   #3a3a3a;
  --zone-border:    #2a2218;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
}

/* ── Overlay (mobile) ── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 90;
}
.overlay.active { display: block; }

/* ── Sidebar ── */
.sidebar {
  width: 160px;
  min-height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 18px 16px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gold);
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-logo span {
  display: block;
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: .08em;
  margin-top: 2px;
}

.sidebar-total {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--sidebar-border);
}
.sidebar-total-info {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: .04em;
  margin-bottom: 4px;
}
.sidebar-progress-bar {
  height: 2px;
  background: var(--border);
  border-radius: 1px;
  overflow: hidden;
}
.sidebar-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--gold-dim);
  border-radius: 1px;
  transition: width .3s ease;
}

.act-nav { flex: 1; padding: 8px 0; }

.act-btn {
  display: block;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  text-align: left;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .04em;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.act-btn:hover  { background: #1a1a1a; color: var(--text); }
.act-btn.active { color: var(--gold); background: #1a1500; border-right: 2px solid var(--gold); }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.toggle-label input[type="checkbox"] { accent-color: var(--gold); width: 13px; height: 13px; cursor: pointer; }

.btn-clear {
  width: 100%;
  padding: 7px 10px;
  background: #1a0e0e;
  border: 1px solid #3a1a1a;
  border-radius: 4px;
  color: #8a4a4a;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-clear:hover { background: #2a1010; color: #c06060; }

/* ── Hamburger (mobile only) ── */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  flex-direction: column;
  gap: 5px;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--gold);
  border-radius: 2px;
  transition: opacity .2s;
}

/* ── Top bar (mobile only) ── */
.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 80;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--sidebar-border);
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  gap: 12px;
}
.topbar-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gold);
}

/* ── Language toggle ── */
.lang-toggle {
  display: flex;
  gap: 2px;
}
.lang-btn {
  padding: 4px 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.lang-btn:hover  { color: var(--text); border-color: #444; }
.lang-btn.active { color: var(--gold); border-color: var(--gold-dim); background: #1a1500; }

/* ── Main content ── */
.main {
  flex: 1;
  padding: 32px 40px 80px;
  max-width: 860px;
  min-width: 0;
}

.act-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 6px;
}
.act-header {
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold-dim);
}
.act-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--zone-border);
}

/* ── Progress ── */
.progress-bar-wrap { margin-bottom: 28px; }
.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.progress-bar { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--gold); border-radius: 2px; transition: width .3s ease; }

/* ── OPT legend ── */
.opt-legend {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 24px;
  padding: 8px 12px;
  background: var(--optional-bg);
  border: 1px solid #2a4a2a;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Zone ── */
.zone { margin-bottom: 26px; }
.zone-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gold-dim);
  padding: 6px 0;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--zone-border);
}

/* ── Step ── */
.step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 6px;
  border-radius: 4px;
  transition: background .1s;
}
.step:hover { background: #141414; }

.step-check {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  margin-top: 2px;
  accent-color: var(--gold);
  cursor: pointer;
}
.step-order {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  min-width: 20px;
  margin-top: 2px;
}
.step-order.is-letter { color: var(--text-muted); }

.badge-opt {
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--optional);
  background: var(--optional-bg);
  border: 1px solid #2a4a2a;
  border-radius: 3px;
  padding: 1px 5px;
  margin-top: 3px;
}

.step-body { flex: 1; min-width: 0; }
.step-text { color: var(--text); line-height: 1.5; }
.step-text.is-optional { color: var(--text-dim); }
.step-note  { font-size: 12px; color: var(--note);   margin-top: 2px; font-style: italic; line-height: 1.4; }
.step-note.hidden { display: none; }
.step-reward { font-size: 12px; color: var(--reward); margin-top: 2px; line-height: 1.4; }
.reward-label { font-weight: 700; letter-spacing: .04em; margin-right: 2px; }

/* Checked state */
.step.is-checked .step-text,
.step.is-checked .step-note,
.step.is-checked .step-reward { color: var(--checked-text); text-decoration: line-through; text-decoration-color: #2a2a2a; }
.step.is-checked .step-order,
.step.is-checked .badge-opt   { opacity: .3; }

/* ── Search ── */
.search-wrap {
  position: relative;
  margin-bottom: 24px;
}
.search-wrap::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b6360' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  background: #111;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color .15s, background .15s;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--gold-dim); background: #151515; }
.search-input::-webkit-search-cancel-button { cursor: pointer; }

/* ── Search highlight ── */
mark.search-hl {
  background: rgba(200, 164, 74, 0.25);
  color: var(--gold);
  border-radius: 2px;
  padding: 0 1px;
  font-style: normal;
}

/* ── Back to top ── */
.btn-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 38px;
  height: 38px;
  background: #1a1500;
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  color: var(--gold);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .2s, transform .2s, background .15s;
  z-index: 50;
  pointer-events: none;
}
.btn-top.visible          { opacity: 1; transform: translateY(0); pointer-events: auto; }
.btn-top:hover            { background: #2a2000; border-color: var(--gold); }

/* ── Next act button ── */
.next-act-wrap {
  margin-top: 40px;
  display: flex;
  justify-content: center;
}
.btn-next-act {
  padding: 12px 28px;
  background: #1a1500;
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  color: var(--gold);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-next-act:hover { background: #2a2000; border-color: var(--gold); }

.no-results {
  padding: 32px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.search-act-group { margin-bottom: 36px; }
.search-act-header {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gold);
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--zone-border);
}

/* ── Reference page TOC ── */
.ref-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 32px;
  padding: 12px;
  background: #111;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.ref-toc-item {
  padding: 4px 10px;
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  text-decoration: none;
  transition: color .15s, border-color .15s, background .15s;
}
.ref-toc-item:hover { color: var(--gold); border-color: var(--gold-dim); background: #1a1500; }

/* ── Nav separator ── */
.nav-sep {
  height: 1px;
  background: var(--sidebar-border);
  margin: 4px 12px;
}

/* ── Reference pages ── */
.ref-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 28px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--zone-border);
}

.ref-section { margin-bottom: 40px; }

.ref-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--zone-border);
}
.ref-section-num {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  padding: 0 5px;
  background: #1a1500;
  border: 1px solid var(--gold-dim);
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: .04em;
}

.ref-note {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  padding: 8px 12px;
  border-left: 2px solid var(--gold-dim);
  margin-bottom: 14px;
  line-height: 1.5;
}

/* Phases */
.ref-phase { margin-bottom: 20px; }

.ref-phase-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.ref-phase-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ref-phase-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  background: #131313;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.ref-phase-item--warn {
  border-color: #3a2a1a;
  background: #150f08;
}

.ref-phase-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
}

.ref-phase-item--warn .ref-phase-name { color: #c07840; }

.ref-phase-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Cards */
.ref-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.ref-card {
  padding: 16px;
  background: #131313;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.ref-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 4px;
}

.ref-card-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 12px;
}

.ref-card-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ref-card-items li {
  font-size: 13px;
  color: var(--text-dim);
  padding-left: 12px;
  position: relative;
  line-height: 1.4;
}

.ref-card-items li::before {
  content: '›';
  position: absolute;
  left: 0;
  color: var(--gold-dim);
}

/* Table */
.ref-table-wrap { overflow-x: auto; }

.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ref-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gold-dim);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.ref-table td {
  padding: 8px 12px;
  color: var(--text-dim);
  border-bottom: 1px solid #1a1a1a;
  vertical-align: top;
  line-height: 1.4;
}

.ref-table td:first-child {
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
}

.ref-table tbody tr:hover td { background: #141414; }

/* Groups (essences) */
.ref-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.ref-group {
  padding: 12px;
  background: #131313;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.ref-group-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.ref-essence {
  display: flex;
  flex-direction: column;
  padding: 5px 0;
  border-bottom: 1px solid #1a1a1a;
}

.ref-essence:last-child { border-bottom: none; }

/* Grouped table */
.ref-table--grouped .ref-table-group-header td {
  padding: 5px 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gold-dim);
  background: #0d0d0d;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.ref-table--grouped .ref-table-group-header:first-child td {
  border-top: none;
}

/* Workflow */
.ref-workflow {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.ref-workflow-step {
  display: flex;
  gap: 0;
  border-bottom: 1px solid #1a1a1a;
  align-items: stretch;
}
.ref-workflow-step:last-child { border-bottom: none; }
.ref-workflow-num {
  flex-shrink: 0;
  width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  border-right: 1px solid #1a1a1a;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold-dim);
  letter-spacing: .04em;
}
.ref-workflow-content {
  flex: 1;
  padding: 10px 14px;
  background: #131313;
}
.ref-workflow-step:hover .ref-workflow-content { background: #161616; }
.ref-workflow-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}
.ref-workflow-body {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Tricks */
.ref-tricks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.ref-trick {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  background: #131313;
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: border-color .15s;
}
.ref-trick:hover { border-color: var(--gold-dim); }
.ref-trick-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ref-trick-num {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: #1a1500;
  border: 1px solid var(--gold-dim);
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: .04em;
}
.ref-trick-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
}
.ref-trick-body {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.55;
}
.ref-trick-uses {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}
.ref-trick-tag {
  padding: 2px 8px;
  background: #0f0f0f;
  border: 1px solid #252525;
  border-radius: 3px;
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
}

.ref-essence-name {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
}

.ref-essence-mod {
  font-size: 11px;
  color: var(--note);
  font-style: italic;
}

/* ── Scrollbar ── */
::-webkit-scrollbar       { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a3a; }

/* ── Responsive ── */
@media (max-width: 767px) {
  body { flex-direction: column; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 100;
  }
  .sidebar.open { transform: translateX(0); }
  .overlay.active { display: block; }

  .topbar { display: flex; }
  .hamburger { display: flex; }

  .main { padding: 20px 16px 60px; }

  .act-meta { flex-direction: column; gap: 8px; }
}

@media (min-width: 768px) {
  .topbar    { display: none; }
  .hamburger { display: none; }
  .overlay   { display: none !important; }

  .lang-toggle-sidebar { display: flex; }
}

/* lang toggle inside sidebar footer (desktop) */
.lang-toggle-sidebar {
  display: flex;
  gap: 4px;
}

/* lang toggle inside topbar (mobile) */
.lang-toggle-topbar { display: flex; gap: 2px; }
