:root {
  color-scheme: dark;
  --bg: #101111;
  --panel: #1a1b1b;
  --panel-2: #202222;
  --line: #323535;
  --line-soft: #282a2a;
  --text: #e6e0cf;
  --muted: #9c988b;
  --gold: #b9a46d;
  --gold-2: #776b45;
  --blue: #5b86b3;
  --cyan: #7fc7d9;
  --red: #b85b55;
  --green: #6f9164;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.36);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(185, 164, 109, 0.14), transparent 34rem),
    linear-gradient(135deg, #111313 0%, #171818 55%, #0d0f10 100%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: rgba(15, 16, 16, 0.94);
  padding: 22px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-mark,
.trader-avatar {
  display: grid;
  place-items: center;
  border: 1px solid var(--gold-2);
  background: linear-gradient(145deg, #353225, #191a19);
  color: var(--gold);
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  font-size: 22px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.side-note span,
.stat-card small,
.panel-head p {
  color: var(--muted);
}

.trader-nav {
  display: grid;
  gap: 7px;
}

.nav-item {
  width: 100%;
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 8px 10px;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  border-color: var(--gold-2);
  background: rgba(185, 164, 109, 0.1);
}

.nav-item em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.nav-icon,
.trader-avatar {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  color: var(--gold);
}

.trader-avatar {
  position: relative;
  overflow: hidden;
  flex: 0 0 auto;
  isolation: isolate;
}

.trader-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
}

.trader-avatar span {
  position: relative;
  z-index: 1;
  font-size: 11px;
}

.trader-avatar.chart {
  width: 38px;
  height: 38px;
  border-radius: 8px;
}

.side-note {
  margin-top: 22px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #171818;
  line-height: 1.45;
}

.side-note strong {
  display: block;
  margin-bottom: 6px;
  color: var(--gold);
}

.content {
  min-width: 0;
  padding: 28px;
}

.topbar,
.section-title,
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 32px;
}

h2 {
  margin-bottom: 4px;
  font-size: 18px;
}

.actions {
  display: flex;
  gap: 10px;
}

.ghost-btn,
.danger-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 13px;
  cursor: pointer;
}

.ghost-btn {
  background: #1b1d1d;
  text-decoration: none;
}

.ghost-btn.active {
  border-color: var(--gold-2);
  color: var(--gold);
  background: rgba(185, 164, 109, 0.12);
}

.danger-btn {
  background: rgba(184, 91, 85, 0.14);
  border-color: rgba(184, 91, 85, 0.4);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 26px 0 16px;
}

.stat-card,
.dashboard-panel,
.error-panel,
.focus-card,
.tools,
.quest-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(26, 27, 27, 0.92);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 16px;
}

.stat-card-wide {
  min-width: 0;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-card strong {
  display: block;
  margin: 8px 0;
  font-size: 30px;
}

.meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #0d0f0f;
  border: 1px solid var(--line-soft);
}

.meter span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold-2), var(--gold));
}

.focus-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.focus-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(185, 164, 109, 0.12), transparent 42%),
    rgba(26, 27, 27, 0.92);
}

.focus-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.4;
}

.radial {
  --value: 0%;
  width: 86px;
  height: 86px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #181a1a 0 52%, transparent 53%),
    conic-gradient(var(--gold) var(--value), #303333 0);
  border: 1px solid var(--line);
}

.radial span {
  color: var(--text);
  font-weight: 800;
}

.radial.kappa {
  background:
    radial-gradient(circle at center, #181a1a 0 52%, transparent 53%),
    conic-gradient(var(--gold) var(--value), #303333 0);
}

.radial.lightkeeper {
  background:
    radial-gradient(circle at center, #181a1a 0 52%, transparent 53%),
    conic-gradient(var(--cyan) var(--value), #303333 0);
}

.dashboard-panel {
  padding: 18px;
  margin-bottom: 16px;
}

.error-panel {
  padding: 16px;
  margin-bottom: 16px;
  background:
    linear-gradient(135deg, rgba(184, 91, 85, 0.1), transparent 42%),
    rgba(26, 27, 27, 0.92);
}

.error-panel:not(.has-errors) {
  background: rgba(26, 27, 27, 0.72);
}

.error-count {
  border: 1px solid rgba(184, 91, 85, 0.45);
  border-radius: 999px;
  color: #f0aaa4;
  background: rgba(184, 91, 85, 0.12);
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.error-summary {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.error-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  border: 1px solid rgba(184, 91, 85, 0.35);
  border-left: 4px solid var(--red);
  border-radius: 8px;
  background: rgba(17, 19, 19, 0.86);
  padding: 12px;
}

.error-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.error-title span {
  color: var(--muted);
  font-size: 13px;
}

.error-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.error-reasons span {
  border: 1px solid rgba(184, 91, 85, 0.45);
  border-radius: 999px;
  background: rgba(184, 91, 85, 0.11);
  color: #f0aaa4;
  font-size: 12px;
  padding: 4px 8px;
}

.error-actions {
  display: flex;
  gap: 8px;
}

.danger-btn.small {
  padding: 7px 10px;
  font-size: 13px;
}

.user-bar {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 19, 19, 0.96);
  box-shadow: var(--shadow);
  padding: 8px;
}

.user-bar span {
  color: var(--muted);
  padding-inline: 6px;
}

.auth-page,
.admin-page {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(185, 164, 109, 0.12), transparent 42%),
    var(--bg);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.auth-card {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(26, 27, 27, 0.94);
  box-shadow: var(--shadow);
  padding: 22px;
}

.auth-card p {
  color: var(--muted);
}

.auth-tabs,
.auth-form,
.admin-users {
  display: grid;
  gap: 10px;
}

.auth-tabs {
  grid-template-columns: 1fr 1fr;
  margin: 18px 0 12px;
}

.auth-form label,
.admin-user label {
  display: grid;
  gap: 6px;
}

.auth-form label span,
.admin-user label span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.auth-form small {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.auth-status {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--gold);
}

.auth-status.error {
  color: #f0aaa4;
}

.admin-topbar,
.admin-shell {
  max-width: 1200px;
  margin-inline: auto;
  padding: 22px;
}

.admin-user {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px 180px;
  gap: 12px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #171919;
  padding: 12px;
}

.admin-user strong,
.admin-user span {
  display: block;
}

.admin-user span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.setup-layout {
  align-items: start;
}

.setup-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.setup-summary article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111313;
  padding: 12px;
}

.setup-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.setup-summary strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.setup-search {
  margin: 12px 0;
}

.setup-quest-list {
  display: grid;
  gap: 8px;
  max-height: 620px;
  overflow: auto;
  padding-right: 4px;
}

.setup-quest {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-left: 4px solid #555b5b;
  border-radius: 8px;
  background: #171919;
  padding: 10px;
  cursor: pointer;
}

.setup-quest.selected {
  border-left-color: var(--gold);
  background: rgba(185, 164, 109, 0.1);
}

.setup-quest input {
  margin-top: 3px;
  accent-color: var(--gold);
}

.setup-quest strong,
.setup-quest small {
  display: block;
}

.setup-quest small {
  margin-top: 4px;
  color: var(--muted);
}

.compact-skills .skill-field {
  grid-template-columns: minmax(140px, 1fr) 74px;
}

.decision-panel {
  background:
    linear-gradient(135deg, rgba(127, 199, 217, 0.08), transparent 36%),
    rgba(26, 27, 27, 0.92);
}

.decision-actions {
  display: flex;
  gap: 8px;
}

.decision-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.decision-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--cyan);
  border-radius: 8px;
  background: #171919;
  padding: 12px;
}

.decision-card.active {
  border-left-color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(185, 164, 109, 0.2);
}

.decision-main {
  display: flex;
  gap: 10px;
  min-width: 0;
  align-items: center;
}

.decision-main div {
  display: grid;
  min-width: 0;
}

.decision-main strong,
.decision-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.decision-main span {
  color: var(--muted);
  font-size: 12px;
}

.decision-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.decision-tags i {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #111313;
  font-size: 11px;
  font-style: normal;
  padding: 3px 7px;
}

.decision-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quest-tree-panel {
  overflow: hidden;
}

.tree-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tree-mode {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: #111313;
  padding: 8px 12px;
  cursor: pointer;
}

.tree-mode.active {
  border-color: var(--gold-2);
  color: var(--gold);
  background: rgba(185, 164, 109, 0.12);
}

.tree-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin: 12px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.tree-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-line {
  width: 34px;
  height: 4px;
  border-radius: 999px;
}

.legend-line.kappa {
  background: var(--gold);
}

.legend-line.lightkeeper {
  background: var(--cyan);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-dot.done {
  background: var(--green);
}

.quest-tree {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(230px, 270px);
  gap: 12px;
  overflow-x: auto;
  padding: 2px 0 10px;
}

.tree-column {
  position: relative;
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 220px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(14, 16, 16, 0.56);
}

.tree-column::before,
.tree-column::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  height: 2px;
  pointer-events: none;
}

.tree-column::before {
  top: 42px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.tree-column::after {
  top: 48px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
}

.tree-column-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 28px;
  color: var(--gold);
  font-weight: 800;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(14, 16, 16, 0.92);
}

.tree-column-head span {
  color: var(--muted);
  font-weight: 600;
}

.tree-card {
  position: relative;
  display: grid;
  gap: 7px;
  width: 100%;
  min-height: 82px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #181a1a;
  padding: 10px;
  text-align: left;
}

.tree-card.done {
  box-shadow: inset 0 0 0 1px rgba(111, 145, 100, 0.55);
}

.tree-card.kappa-path {
  border-left-color: var(--gold);
}

.tree-card.lightkeeper-path {
  border-right: 4px solid var(--cyan);
}

.tree-card.kappa-path.lightkeeper-path {
  background:
    linear-gradient(90deg, rgba(185, 164, 109, 0.12), transparent 42%),
    linear-gradient(270deg, rgba(127, 199, 217, 0.1), transparent 40%),
    #181a1a;
}

.tree-card-top {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

.tree-card-top strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.tree-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
}

.tree-card-meta i,
.tree-card-meta b {
  border: 1px solid var(--line);
  border-radius: 999px;
  font-style: normal;
  padding: 2px 6px;
}

.tree-card-meta b {
  color: var(--gold);
  border-color: var(--gold-2);
}

.tree-card-meta b.lk {
  color: var(--cyan);
  border-color: rgba(127, 199, 217, 0.42);
}

.trader-chart {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.chart-row {
  display: grid;
  grid-template-columns: 170px 1fr 66px 96px;
  gap: 12px;
  align-items: center;
}

.chart-trader {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.chart-trader b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  position: relative;
  height: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #101212;
}

.bar-total,
.bar-done {
  position: absolute;
  inset: 0 auto 0 0;
}

.bar-total {
  background: rgba(230, 224, 207, 0.18);
}

.bar-done {
  background: linear-gradient(90deg, var(--gold-2), var(--gold));
}

.chart-pills {
  display: flex;
  gap: 6px;
}

.chart-pills i {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #141616;
  font-size: 11px;
  font-style: normal;
  padding: 3px 7px;
}

.tools {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 180px 180px 210px 180px;
  gap: 12px;
  padding: 12px;
  margin-bottom: 16px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.search-box,
select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111313;
  color: var(--text);
  padding: 10px 12px;
}

.fr-status {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--gold);
  background: #111313;
  padding: 10px 12px;
  font-size: 13px;
  white-space: nowrap;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.quest-section {
  padding-bottom: 30px;
}

#visibleCount {
  color: var(--muted);
}

.quest-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.quest-card {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 14px;
  padding: 14px;
}

.quest-check {
  width: 24px;
  height: 24px;
  accent-color: var(--gold);
  margin-top: 3px;
}

.quest-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.quest-title .trader-avatar {
  width: 30px;
  height: 30px;
}

.quest-title strong {
  font-size: 16px;
}

.quest-fr-name {
  color: var(--gold);
  border-left: 1px solid var(--line);
  padding-left: 8px;
  font-size: 14px;
  font-weight: 700;
}

.quest-fr-name.muted {
  color: var(--muted);
  font-weight: 500;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
  background: #141616;
  font-size: 12px;
}

.tag.gold {
  color: var(--gold);
  border-color: var(--gold-2);
}

.tag.blue {
  color: #b8d7f5;
  border-color: rgba(91, 134, 179, 0.5);
}

.tag.progress {
  color: var(--cyan);
  border-color: rgba(127, 199, 217, 0.46);
}

.tag.locked {
  color: var(--red);
  border-color: rgba(184, 91, 85, 0.5);
}

.tag.warning {
  color: #ffd28a;
  border-color: rgba(255, 210, 138, 0.55);
}

.quest-card.inaccessible {
  border-left: 4px solid rgba(184, 91, 85, 0.82);
}

.quest-card.invalid-complete {
  box-shadow: inset 0 0 0 1px rgba(255, 210, 138, 0.5), var(--shadow);
}

.missing-conditions {
  display: grid;
  gap: 5px;
  margin-top: 10px;
}

.missing-conditions span {
  width: fit-content;
  border: 1px solid rgba(184, 91, 85, 0.45);
  border-radius: 999px;
  background: rgba(184, 91, 85, 0.11);
  color: #f0aaa4;
  font-size: 12px;
  padding: 4px 8px;
}

.missing-conditions .skill-note {
  border-color: rgba(185, 164, 109, 0.45);
  background: rgba(185, 164, 109, 0.11);
  color: var(--gold);
}

.tag.skill {
  color: #d7cda9;
  border-color: rgba(185, 164, 109, 0.32);
}

.quest-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.quest-meta b {
  display: block;
  color: var(--text);
  font-weight: 600;
}

.quest-actions {
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: flex-start;
}

.wiki-link {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #141616;
  color: var(--gold);
  text-decoration: none;
  padding: 7px 9px;
  white-space: nowrap;
  cursor: pointer;
}

.wiki-link.subtle {
  color: var(--muted);
}

.empty {
  padding: 34px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.empty.compact {
  padding: 16px;
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .trader-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-grid,
  .focus-grid,
  .decision-list,
  .tools {
    grid-template-columns: 1fr 1fr;
  }

  .chart-row {
    grid-template-columns: 150px 1fr 58px;
  }

  .chart-pills {
    grid-column: 2 / -1;
  }
}

@media (max-width: 700px) {
  .content {
    padding: 18px;
  }

  .topbar,
  .section-title,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats-grid,
  .focus-grid,
  .decision-list,
  .tools,
  .quest-meta,
  .trader-nav {
    grid-template-columns: 1fr;
  }

  .quest-card {
    grid-template-columns: 30px 1fr;
  }

  .error-item {
    grid-template-columns: 1fr;
  }

  .error-actions {
    flex-wrap: wrap;
  }

  .quest-actions {
    grid-column: 2;
  }
}
