:root,
:root[data-theme="dark"] {
  color-scheme: dark;

  --surface-0: #0b0a12;
  --surface-1: #131225;
  --surface-2: #1c1a34;
  --surface-3: #25223f;

  --line: #2b2948;
  --line-strong: #403d63;

  --text: #f4f0df;
  --muted: #b6b0d0;
  --link: #e6dfff;

  --primary: #d54435;
  --primary-strong: #ff6654;
  --accent: #52b788;
  --accent-soft: rgba(82, 183, 136, 0.15);
  --danger: #ff5c75;
  --gold: #f8c350;

  --on-primary: #fff;
  --on-accent: #0b0a12;

  --comp-red:    #e88579;
  --comp-orange: #e8a86d;
  --comp-yellow: #e8d77a;
  --comp-green:  #90d6a0;
  --comp-bright: #a5e0b3;
  --comp-tint:   rgba(255, 255, 255, 0.06);

  --topbar-bg: rgba(10, 9, 18, 0.92);
  --row-stripe: rgba(255, 255, 255, 0.02);

  --focus: rgba(248, 195, 80, 0.85);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;

    --surface-0: #d6c79a;
    --surface-1: #e6dab2;
    --surface-2: #decea0;
    --surface-3: #cabe92;

    --line: #b8a87f;
    --line-strong: #8f7e58;

    --text: #1f1a12;
    --muted: #5a4f3a;
    --link: #4a3422;

    --primary: #b3392a;
    --primary-strong: #d54435;
    --accent: #2f7d52;
    --accent-soft: rgba(47, 125, 82, 0.18);
    --danger: #a8324a;
    --gold: #8a5b15;

    --on-primary: #fff8e6;
    --on-accent: #f4eccd;

    --comp-red:    #b04032;
    --comp-orange: #b06820;
    --comp-yellow: #8a6a14;
    --comp-green:  #2f7d52;
    --comp-bright: #1f6a42;
    --comp-tint:   rgba(31, 26, 18, 0.05);

    --topbar-bg: rgba(214, 199, 154, 0.92);
    --row-stripe: rgba(31, 26, 18, 0.03);

    --focus: rgba(138, 91, 21, 0.85);
    --shadow: 0 18px 48px rgba(76, 60, 26, 0.18);
  }
}

:root[data-theme="light"] {
  color-scheme: light;

  --surface-0: #d6c79a;
  --surface-1: #e6dab2;
  --surface-2: #decea0;
  --surface-3: #cabe92;

  --line: #b8a87f;
  --line-strong: #8f7e58;

  --text: #1f1a12;
  --muted: #5a4f3a;
  --link: #4a3422;

  --primary: #b3392a;
  --primary-strong: #d54435;
  --accent: #2f7d52;
  --accent-soft: rgba(47, 125, 82, 0.18);
  --danger: #a8324a;
  --gold: #8a5b15;

  --on-primary: #fff8e6;
  --on-accent: #f4eccd;

  --comp-red:    #b04032;
  --comp-orange: #b06820;
  --comp-yellow: #8a6a14;
  --comp-green:  #2f7d52;
  --comp-bright: #1f6a42;
  --comp-tint:   rgba(31, 26, 18, 0.05);

  --topbar-bg: rgba(214, 199, 154, 0.92);
  --row-stripe: rgba(31, 26, 18, 0.03);

  --focus: rgba(138, 91, 21, 0.85);
  --shadow: 0 18px 48px rgba(76, 60, 26, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: var(--surface-0);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

.skip-link {
  position: absolute;
  top: -48px;
  left: 8px;
  z-index: 1000;
  border-radius: 8px;
  background: #000;
  color: #fff;
  padding: 10px 16px;
  font-weight: 800;
  text-decoration: none;
  transition: top 140ms ease;
}

.skip-link:focus,
.skip-link:focus-visible {
  top: 8px;
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .skip-link {
    transition: none;
  }
}

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

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.3rem, 1.1rem + 0.8vw, 1.85rem);
  line-height: 1.15;
}

h2 {
  font-size: 1rem;
  letter-spacing: 0;
}

h3 {
  font-size: 0.98rem;
  letter-spacing: 0;
}

.app-shell {
  width: min(1920px, 100%);
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto auto auto auto;
  align-items: center;
  gap: 16px;
  min-height: 70px;
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  padding: 12px 18px;
  backdrop-filter: blur(10px);
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
}

.feedback-topbar-button {
  min-height: 38px;
  border: 1px solid var(--primary);
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  color: var(--primary-strong);
  padding: 8px 13px;
  font-size: 0.84rem;
  font-weight: 900;
  white-space: nowrap;
}

.feedback-topbar-button:hover {
  background: var(--primary);
  color: var(--on-primary);
}

.theme-toggle:hover {
  border-color: var(--text);
  background: var(--surface-3);
}

.theme-toggle-icon {
  display: inline-block;
  transition: transform 220ms ease;
}

.theme-toggle:hover .theme-toggle-icon {
  transform: rotate(20deg);
}

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

.league-icon {
  width: 68px;
  height: 68px;
  image-rendering: auto;
}

.brand p,
.panel-heading p,
.route-toolbar p {
  color: var(--muted);
  font-size: 0.9rem;
}

.resource-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.resource-links a,
.panel-link,
.site-footer a {
  color: var(--link);
  font-weight: 850;
  text-decoration: none;
}

.resource-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 7px 10px;
  font-size: 0.82rem;
}

.resource-links img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.countdown-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 132px;
  min-height: 34px;
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--gold) 14%, transparent);
  color: var(--gold);
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.resource-links a:hover,
.panel-link:hover,
.site-footer a:hover {
  color: var(--gold);
}

.panel-link {
  white-space: nowrap;
  font-size: 0.82rem;
}

#profile-summary {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.account-name {
  max-width: 100%;
  overflow: hidden;
  color: var(--text);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-stats {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 168px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 8px 12px;
  font-size: 0.86rem;
  white-space: nowrap;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 18px;
  font-size: 0.86rem;
}

.tool-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 70px;
  display: grid;
  gap: 12px;
  height: calc(100dvh - 70px);
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid var(--line);
  background: var(--surface-0);
  padding: 14px;
}

.main-panel {
  min-width: 0;
  padding: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-1);
  box-shadow: var(--shadow);
}

.account-panel,
.filters-panel,
.table-panel,
.manual-route,
.route-toolbar,
.profile-grid .panel {
  padding: 14px;
}

.panel-heading,
.route-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  margin-bottom: 14px;
}

.panel-heading.compact {
  margin-bottom: 12px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tab {
  min-width: 108px;
  border: 1px solid var(--line-strong);
  background: var(--surface-1);
  color: var(--muted);
  padding: 10px 14px;
  font-weight: 800;
}

.tab.active {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--on-primary);
}

.tab.active:focus-visible {
  outline-color: var(--on-primary);
  outline-offset: 3px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.field-grid.tight {
  gap: 8px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.field > span,
.toggle-row span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.field-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  overflow: visible;
}

.help-tip {
  position: relative;
  z-index: 50;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  min-height: 18px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--gold);
  padding: 0;
  font-size: 0.72rem;
  line-height: 1;
  cursor: help;
}

.help-tip:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.help-tip-content {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 1000;
  width: min(280px, 80vw);
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.help-tip:hover .help-tip-content,
.help-tip:focus .help-tip-content,
.help-tip:focus-within .help-tip-content {
  opacity: 1;
  transform: translate(-50%, 0);
}

.sidebar .help-tip-content {
  bottom: calc(100% + 8px);
  top: auto;
  right: 0;
  left: auto;
  width: min(210px, calc(100vw - 32px));
  transform: translate(0, 4px);
}

.sidebar .help-tip:hover .help-tip-content,
.sidebar .help-tip:focus .help-tip-content,
.sidebar .help-tip:focus-within .help-tip-content {
  transform: translate(0, 0);
}

.sidebar .field-grid .field:first-child .help-tip-content {
  right: auto;
  left: 0;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-0);
  color: var(--text);
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.75;
}

:root[data-theme="light"] input::placeholder,
:root[data-theme="light"] textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 70%, var(--surface-0));
  opacity: 1;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) input::placeholder,
  :root:not([data-theme]) textarea::placeholder {
    color: color-mix(in srgb, var(--muted) 70%, var(--surface-0));
    opacity: 1;
  }
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
}

.toggle-row input {
  width: 20px;
  min-height: 20px;
  accent-color: var(--primary);
}

.option-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-0);
  padding: 7px 10px;
  color: var(--text);
  cursor: pointer;
}

.option-chip:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.option-chip input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.button-row,
.export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.progress-card {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-0);
  padding: 10px;
}

.progress-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.progress-label span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-label strong {
  flex: 0 0 auto;
  color: var(--gold);
  white-space: nowrap;
}

.progress-track {
  overflow: hidden;
  height: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-0);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--gold));
  transition: width 180ms ease;
}

.primary-button,
.secondary-button,
.ghost-button,
.row-button {
  padding: 9px 12px;
  font-weight: 800;
}

.primary-button {
  background: var(--primary);
  color: var(--on-primary);
}

.primary-button:hover {
  background: var(--primary-strong);
}

.secondary-button {
  border: 1px solid var(--primary);
  background: transparent;
  color: var(--primary);
}

.secondary-button:hover {
  background: var(--primary);
  color: var(--on-primary);
}

.ghost-button,
.row-button {
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
}

.ghost-button:hover:not(:disabled),
.row-button:hover {
  border-color: var(--text);
  background: var(--surface-3);
}

.row-button.selected {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
}

.row-button.selected:hover {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 22%, transparent);
}

.icon-button {
  width: 44px;
  padding: 0;
  font-size: 1.1rem;
}

.full-width {
  width: 100%;
}

.message {
  min-height: 24px;
  margin-top: 12px;
  color: var(--muted);
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: var(--accent);
}

.message a {
  color: var(--gold);
  font-weight: 850;
}

.feedback-status {
  min-width: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.feedback-status.error {
  color: var(--danger);
}

.feedback-status.success {
  color: var(--accent);
}

.trap-field {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(6, 5, 10, 0.72);
  padding: 18px;
}

.modal-backdrop[hidden] {
  display: none;
}

.feedback-dialog {
  width: min(620px, 100%);
  max-height: min(720px, calc(100dvh - 36px));
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-1);
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.46);
  padding: 16px;
}

.modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.modal-heading p {
  max-width: 48ch;
  color: var(--muted);
  font-size: 0.9rem;
}

.feedback-dialog textarea {
  min-height: 132px;
}

.modal-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

.task-table-wrap {
  max-height: calc(100dvh - 190px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.task-table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.task-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  color: var(--muted);
  text-align: left;
  font-size: 0.76rem;
  text-transform: uppercase;
}

.sortable-header {
  cursor: pointer;
  user-select: none;
}

.sortable-header::after {
  content: "";
  color: var(--gold);
  font-size: 0.72rem;
  margin-left: 6px;
}

.sortable-header.active[data-direction="asc"]::after {
  content: "▲";
}

.sortable-header.active[data-direction="desc"]::after {
  content: "▼";
}

.task-table th,
.task-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  vertical-align: middle;
}

.task-table tbody tr:nth-child(even) {
  background: var(--row-stripe);
}

.task-table tbody tr:hover {
  background: var(--surface-3);
}

.task-table tr.completed {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.task-table tr.completed:nth-child(even) {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.task-table tr.completed:hover {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
}

.task-name {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 800;
}

.task-desc {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 2px;
}

.skill-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.area-icon {
  width: 24px;
  height: 30px;
  flex: 0 0 auto;
  object-fit: contain;
}

.area-icon.mini {
  width: 18px;
  height: 27px;
}

.route-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  object-fit: contain;
}

.tier-icon {
  width: 16px;
  height: 18px;
  margin-right: 4px;
  object-fit: contain;
}

.area-cell {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.area-shield {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 900;
}

.area-shield.mini {
  width: 22px;
  height: 22px;
  font-size: 0.7rem;
}

.points-pill,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-height: 24px;
  border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--gold) 14%, transparent);
  color: var(--gold);
  padding: 2px 8px;
  font-size: 0.76rem;
  font-weight: 900;
}

.req-met {
  color: var(--accent);
}

.req-missing {
  color: var(--danger);
}

.completion-cell {
  text-align: center;
}

.completion-pill {
  display: inline-flex;
  justify-content: center;
  min-width: 54px;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 2px 7px;
  background: var(--comp-tint);
  font-weight: 900;
}

.completion-pill.comp-empty {
  color: var(--muted);
}

.completion-pill.comp-red {
  color: var(--comp-red);
  background: color-mix(in srgb, var(--comp-red) 14%, transparent);
}

.completion-pill.comp-orange {
  color: var(--comp-orange);
  background: color-mix(in srgb, var(--comp-orange) 14%, transparent);
}

.completion-pill.comp-yellow {
  color: var(--comp-yellow);
  background: color-mix(in srgb, var(--comp-yellow) 14%, transparent);
}

.completion-pill.comp-green {
  color: var(--comp-green);
  background: color-mix(in srgb, var(--comp-green) 14%, transparent);
}

.completion-pill.comp-bright {
  color: var(--comp-bright);
  background: color-mix(in srgb, var(--comp-bright) 16%, transparent);
}

.profile-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(420px, 1.2fr);
  gap: 12px;
}

.area-grid {
  min-width: 0;
}

.area-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-0);
  padding: 9px;
  cursor: pointer;
}

.area-tile input {
  width: 20px;
  min-height: 20px;
  accent-color: var(--accent);
}

.area-tile:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.area-table-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.area-breakdown-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  background: var(--surface-0);
  font-size: 0.78rem;
}

.area-breakdown-table th,
.area-breakdown-table td {
  border-bottom: 1px solid var(--line);
  padding: 7px 4px;
  text-align: right;
  vertical-align: middle;
  white-space: nowrap;
}

.area-breakdown-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.62rem;
  text-transform: uppercase;
}

.area-breakdown-table th:first-child,
.area-breakdown-table th:nth-child(2),
.area-breakdown-table td:first-child,
.area-breakdown-table td:nth-child(2) {
  width: 28px;
  text-align: center;
}

.area-breakdown-table th:first-child,
.area-breakdown-table td:first-child {
  width: 24px;
}

.area-breakdown-table th:nth-child(3),
.area-breakdown-table td:nth-child(3) {
  text-align: left;
}

.area-breakdown-table th:nth-child(n + 4):nth-child(-n + 8),
.area-breakdown-table td:nth-child(n + 4):nth-child(-n + 8) {
  width: 48px;
}

.area-breakdown-table th:nth-child(9),
.area-breakdown-table td:nth-child(9) {
  width: 52px;
}

.area-breakdown-table th:nth-child(10),
.area-breakdown-table td:nth-child(10) {
  width: 64px;
}

.area-name-cell {
  overflow: hidden;
  text-overflow: ellipsis;
}

.area-breakdown-table tbody tr.selected-area {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.area-breakdown-table tbody tr:hover {
  background: var(--surface-3);
}

.area-breakdown-table input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.area-breakdown-table .area-icon,
.area-breakdown-table .area-shield {
  margin-inline: auto;
}

.area-name-cell a {
  color: var(--link);
  font-weight: 850;
  text-decoration: none;
}

.area-name-cell a:hover {
  color: var(--gold);
}

.area-breakdown-table tfoot td {
  border-bottom: 0;
  background: color-mix(in srgb, var(--gold) 14%, transparent);
  color: var(--gold);
  font-weight: 900;
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 8px;
  max-width: 900px;
}

.skill-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  align-items: center;
  gap: 8px;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-0);
  padding: 9px 10px;
}

.skill-link {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.skill-link:hover span {
  color: var(--gold);
}

.skill-field img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.skill-field span {
  color: var(--text);
  font-weight: 750;
  min-width: 0;
  overflow: hidden;
  font-size: clamp(0.78rem, 0.58rem + 0.45vw, 0.95rem);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-field input {
  min-height: 40px;
  padding: 6px 8px;
}

.total-level {
  grid-template-columns: minmax(0, 1fr) 58px;
  opacity: 0.78;
}

.total-label {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.total-level strong {
  color: var(--gold);
  font-size: 1rem;
  text-align: right;
}

.quest-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.quest-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
}

.quest-chip.done {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.quest-chip.missing {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.quest-chip input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.manual-route {
  margin: 12px 0;
}

.manual-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 8px 0;
}

.manual-row:first-child {
  border-top: 0;
}

.tiny-button {
  width: 34px;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  background: var(--surface-0);
  color: var(--text);
}

.tiny-button.danger {
  color: var(--danger);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-1);
  padding: 12px;
}

.metric strong {
  display: block;
  color: var(--gold);
  font-size: 1.3rem;
  line-height: 1.15;
}

.metric span {
  color: var(--muted);
  font-size: 0.82rem;
}

.checklist {
  display: grid;
  gap: 12px;
}

.section-block {
  overflow: clip;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-1);
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.section-header p {
  color: var(--muted);
  margin-top: 4px;
}

.section-count {
  color: var(--gold);
  font-weight: 900;
}

.check-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.task-check-row {
  background: var(--row-stripe);
}

.check-row:last-child {
  border-bottom: 0;
}

.check-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  min-height: 22px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.check-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.check-note {
  display: block;
  color: var(--muted);
  margin-top: 4px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.route-task-context {
  display: block;
  color: var(--accent);
  margin-top: 5px;
  font-size: 0.82rem;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.check-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.check-meta .points-pill,
.check-meta .tier-pill,
.check-meta .completion-pill {
  min-height: 28px;
  padding: 3px 10px;
  font-size: 0.82rem;
}

.tier-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--gold) 14%, transparent);
  color: var(--gold);
  padding: 2px 8px;
  font-size: 0.76rem;
  font-weight: 900;
}

.tag.custom {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: var(--accent-soft);
  color: var(--accent);
}

.check-row.done .check-title,
.check-row.done .check-note,
.check-row.done .route-task-context {
  color: var(--muted);
  text-decoration: line-through;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  padding: 20px;
}

.empty-state.small {
  padding: 12px;
}

@media (max-width: 1100px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .resource-links {
    justify-content: flex-start;
  }

  .tool-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }

  .main-panel {
    padding: 10px;
  }

  .tabs,
  .panel-heading,
  .route-toolbar,
  .modal-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .tab {
    width: 100%;
  }

  .field-grid,
  .metrics {
    grid-template-columns: 1fr;
  }

  .skills-grid {
    grid-template-columns: 1fr;
    max-width: none;
  }

  .check-row {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .check-meta {
    grid-column: 2;
    justify-content: flex-start;
  }

  .modal-backdrop {
    align-items: stretch;
    padding: 10px;
  }

  .feedback-dialog {
    max-height: calc(100dvh - 20px);
  }

  .modal-actions {
    grid-template-columns: 1fr;
  }

  .modal-actions .primary-button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
