:root {
  color-scheme: dark;
  --bg: #0b0d0c;
  --panel: #151816;
  --panel-strong: #20241f;
  --panel-plate: #1a211f;
  --line: #4a4334;
  --line-soft: #2d332d;
  --text: #f0eadc;
  --muted: #a9a08d;
  --blue: #5c8ea6;
  --blue-soft: #203642;
  --cyan: #9fc8d1;
  --gold: #d6aa55;
  --red: #b1604f;
  --danger: #e58a7d;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 0%, rgba(90, 65, 32, 0.18), transparent 32rem),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 42px 42px, 42px 42px, auto;
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.35;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  border: 1px solid var(--line);
  background: #101412;
  color: var(--text);
  border-radius: 3px;
}

button {
  cursor: pointer;
}

select,
input {
  width: 100%;
  min-height: 30px;
  padding: 4px 7px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

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

.app-shell {
  display: grid;
  gap: 8px;
  width: min(1480px, calc(100% - 12px));
  margin: 0 auto;
  padding: 8px 0 20px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 2px 6px;
  border-bottom: 1px solid rgba(214, 170, 85, 0.22);
}

.site-label {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.site-label a {
  color: inherit;
  text-decoration: none;
}

.site-label a:hover {
  text-decoration: underline;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.1rem, 2vw, 1.45rem);
  color: #fff6df;
  font-weight: 800;
}

.header-actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

.language-select {
  display: grid;
  gap: 3px;
  min-width: 130px;
}

.language-select span {
  color: var(--muted);
  font-size: 0.72rem;
}

h2 {
  margin-bottom: 2px;
  font-size: 0.95rem;
  color: #f3dfab;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.ghost-button,
.slot-clear {
  min-height: 28px;
  padding: 4px 9px;
  background: linear-gradient(#26312d, #171d1a);
  color: var(--gold);
}

.layout {
  display: grid;
  grid-template-columns: minmax(520px, 0.9fr) minmax(520px, 1.1fr);
  gap: 8px;
  align-items: start;
  order: 2;
}

.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 3px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 72px),
    var(--panel);
  box-shadow: var(--shadow);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.035);
  pointer-events: none;
}

.equipment-panel,
.skills-panel,
.search-panel,
.planner-panel,
.weapon-list-panel,
.share-panel {
  padding: 10px;
}

.planner-panel {
  order: 1;
}

.share-panel {
  order: 0;
}

.search-panel {
  order: 3;
}

.weapon-list-panel {
  order: 4;
}

.planner-panel {
  border-color: rgba(214, 170, 85, 0.58);
}

.equipment-panel {
  border-left: 3px solid #8e6a35;
}

.skills-panel {
  border-left: 3px solid #8e6a35;
}

.search-panel,
.weapon-list-panel {
  border-left: 3px solid #6f8790;
}

.share-panel {
  border-left: 3px solid #8d6a60;
}

.weapon-filter {
  display: grid;
  grid-template-columns: 64px minmax(0, 180px);
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}

label,
.summary-label {
  color: var(--muted);
  font-size: 0.82rem;
}

.slot-grid {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: #090c0b;
}

.equip-slot {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: linear-gradient(90deg, #121713, #101413);
}

.slot-head {
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-right: 1px solid var(--line);
  border-bottom: 0;
  background:
    linear-gradient(180deg, rgba(214, 170, 85, 0.14), transparent),
    #1b211c;
}

.slot-part {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  justify-content: center;
  color: var(--gold);
  font-weight: 700;
}

.slot-clear {
  min-height: 22px;
  padding: 2px 4px;
  font-size: 0.72rem;
}

.slot-body {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 7px;
  padding: 6px;
}

.thumb {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #0c100e;
  color: #817964;
  font-size: 0.72rem;
  text-align: center;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.slot-info {
  min-width: 0;
}

.slot-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff2d0;
}

.slot-sub,
.slot-meta {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.slot-select {
  margin: 4px 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 12px;
  margin: 8px 0;
}

.series-summary,
.slot-summary {
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #101412;
  color: #f5dfaa;
}

.series-skill-box {
  margin-bottom: 8px;
  border: 1px solid rgba(214, 170, 85, 0.58);
  border-radius: 2px;
  background:
    linear-gradient(90deg, rgba(107, 67, 32, 0.26), rgba(26, 24, 18, 0.72)),
    #11120f;
  overflow: hidden;
}

.box-title {
  padding: 5px 8px;
  border-bottom: 1px solid rgba(214, 170, 85, 0.24);
  color: var(--gold);
  font-weight: 700;
}

.series-skills {
  display: grid;
  gap: 8px;
  padding: 6px;
}

.series-skills.empty {
  color: var(--muted);
}

.series-badge,
.skill-row,
.category-block {
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  background: rgba(12, 16, 14, 0.72);
}

.series-badge {
  padding: 5px 7px;
  color: var(--gold);
}

.active-skills {
  display: grid;
  gap: 6px;
}

.category-block {
  overflow: hidden;
}

.category-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 7px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(90deg, rgba(214, 170, 85, 0.11), transparent);
  color: var(--gold);
  font-weight: 700;
}

.skill-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin: 0;
  padding: 5px 7px;
  border-width: 0 0 1px;
  border-radius: 0;
}

.skill-name {
  font-weight: 700;
}

.skill-desc {
  color: var(--muted);
  font-size: 0.82rem;
}

.skill-level {
  color: var(--cyan);
  font-weight: 800;
}

.skill-level.max {
  color: var(--gold);
}

.skill-level.over {
  color: var(--danger);
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 3px;
  color: var(--muted);
  background: rgba(12, 16, 14, 0.58);
  text-align: center;
}

.search-panel,
.planner-panel,
.weapon-list-panel,
.share-panel {
  margin-top: 0;
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.share-actions button,
.share-link,
.file-button {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: linear-gradient(#26312d, #161b18);
  color: var(--text);
  cursor: pointer;
  font-size: 0.82rem;
  text-decoration: none;
}

.file-button input {
  display: none;
}

.share-status {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.build-memo {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.build-memo textarea {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #101412;
  color: var(--text);
  font: inherit;
  line-height: 1.45;
}

.build-memo textarea:focus {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.search-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(214, 170, 85, 0.14);
}

.planner-panel {
  padding: 8px;
}

.planner-controls {
  display: grid;
  grid-template-columns: 130px minmax(160px, 0.8fr) minmax(220px, 1fr) 82px 72px;
  gap: 6px;
  width: min(100%, 860px);
  align-items: end;
}

.planner-controls label {
  display: grid;
  gap: 4px;
}

.target-skill-search input {
  min-width: 0;
}

.planner-controls button,
.planner-options button {
  min-height: 30px;
  padding: 4px 8px;
  background: linear-gradient(#344039, #1b221e);
}

.planner-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.check-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.check-option input {
  width: 18px;
  min-height: 18px;
}

.planner-limit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.planner-limit select {
  min-height: 30px;
  min-width: 82px;
}

.target-skill-list,
.planner-results {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.planner-results {
  overflow-x: auto;
}

.target-skill-list.empty {
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: 2px;
  background: rgba(12, 16, 14, 0.55);
  color: var(--muted);
}

.target-chip {
  display: inline-grid;
  grid-template-columns: minmax(0, 1fr) 86px auto;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background:
    linear-gradient(90deg, rgba(214, 170, 85, 0.1), transparent),
    #111613;
}

.target-chip select {
  min-height: 30px;
}

.target-chip button,
.apply-build-button {
  min-height: 30px;
  padding: 3px 8px;
  background: rgba(177, 96, 79, 0.16);
  color: #f0c2aa;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 23, 40, 0.78);
  overflow: hidden;
}

.table-caption {
  color: var(--muted);
  font-size: 0.78rem;
}

.result-table {
  width: 100%;
  min-width: 1280px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.78rem;
  background: #0d110f;
}

.result-table th,
.result-table td {
  padding: 4px 5px;
  border: 1px solid var(--line);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.result-table th {
  background:
    linear-gradient(180deg, rgba(214, 170, 85, 0.18), transparent),
    #22271f;
  color: #f1dca5;
  font-weight: 700;
}

.result-table tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.025);
}

.result-table td:nth-child(2) {
  color: var(--gold);
  font-weight: 800;
}

.score-cell {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.score-cell span {
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 500;
}

.score-settings {
  margin: 8px 0;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(12, 16, 14, 0.58);
}

.score-settings summary {
  padding: 7px 9px;
  color: var(--gold);
  cursor: pointer;
  font-weight: 700;
}

.score-weight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  padding: 0 9px 9px;
}

.score-weight-field {
  display: grid;
  gap: 4px;
}

.score-settings > button {
  margin: 0 9px 9px;
}

.table-button {
  min-height: 22px;
  padding: 1px 6px;
  background: linear-gradient(#3a463d, #1d241f);
  color: var(--text);
  font-size: 0.74rem;
}

.result-head,
.result-body {
  padding: 10px;
}

.result-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.result-title {
  font-weight: 800;
  color: var(--gold);
}

.result-parts,
.result-skills {
  display: grid;
  gap: 5px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.search-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 110px;
  gap: 6px;
  width: min(100%, 620px);
}

.weapon-search {
  width: min(100%, 360px);
}

.weapon-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  order: 5;
  padding: 12px 2px 4px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 0.84rem;
}

.site-footer__brand {
  display: grid;
  gap: 2px;
}

.site-footer__brand strong {
  color: var(--text);
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.site-footer__links a {
  color: var(--gold);
  text-decoration: none;
}

.site-footer__links a:hover {
  text-decoration: underline;
}

.search-controls label {
  display: grid;
  gap: 4px;
}

.item-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-top: 8px;
}

.series-group {
  border: 1px solid var(--line);
  background: #0f1311;
}

.series-group summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 4px 8px;
  background:
    linear-gradient(90deg, rgba(214, 170, 85, 0.16), transparent),
    #20251f;
  color: #f1dca5;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 700;
}

.series-group summary::-webkit-details-marker {
  display: none;
}

.series-group summary::before {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  grid-row: 1;
  grid-column: 1;
  border: 1px solid var(--line);
  color: var(--gold);
  font-size: 0.78rem;
}

.series-group[open] summary::before {
  content: "-";
}

.series-group summary span:first-child {
  padding-left: 24px;
  grid-column: 1;
}

.series-group-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
}

.item-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 7px;
  padding: 5px;
  border: 1px solid var(--line);
  border-width: 0 1px 1px 0;
  border-radius: 2px;
  background: rgba(16, 20, 18, 0.82);
}

.item-card .thumb {
  width: 34px;
  height: 34px;
}

.item-card h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.82rem;
}

.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 4px 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 1px 5px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(214, 170, 85, 0.06);
  color: var(--muted);
  font-size: 0.7rem;
}

.item-card button {
  min-height: 24px;
  padding: 2px 7px;
  background: linear-gradient(#26312d, #171d1a);
  color: var(--text);
}

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

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

  .search-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .search-controls,
  .planner-controls {
    width: 100%;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 18px, 1180px);
    padding-top: 10px;
  }

  .site-header {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    display: grid;
  }

  .equipment-panel,
  .skills-panel,
  .planner-panel,
  .search-panel,
  .weapon-list-panel,
  .share-panel {
    padding: 12px;
  }

  .weapon-filter,
  .summary-grid,
  .search-controls,
  .planner-controls {
    grid-template-columns: 1fr;
  }

  .planner-options {
    align-items: stretch;
    flex-direction: column;
  }

  .check-option {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    justify-content: start;
    width: 100%;
  }

  .check-option span {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .planner-limit {
    justify-content: space-between;
    width: 100%;
  }

  .share-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .share-actions button,
  .share-link,
  .file-button {
    justify-content: center;
    width: 100%;
  }

  .target-chip {
    grid-template-columns: minmax(0, 1fr) 86px;
  }

  .target-chip button {
    grid-column: 1 / -1;
  }

  .slot-body {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .thumb {
    width: 64px;
    height: 64px;
  }

  .result-table {
    display: block;
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
  }

  .result-table thead {
    display: none;
  }

  .result-table tbody,
  .result-table tr,
  .result-table td {
    display: block;
    width: 100%;
  }

  .result-table tr {
    margin-bottom: 8px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background:
      linear-gradient(180deg, rgba(214, 170, 85, 0.07), transparent 54px),
      rgba(14, 18, 16, 0.9);
    overflow: hidden;
  }

  .result-table td {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    border: 0;
    border-bottom: 1px solid var(--line-soft);
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .result-table td:last-child {
    display: block;
    border-bottom: 0;
  }

  .result-table td::before {
    color: var(--gold);
    font-weight: 700;
  }

  .result-table td:nth-child(1)::before { content: "No."; }
  .result-table td::before { content: attr(data-label); }

  .table-button {
    width: 100%;
    min-height: 32px;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}
