
:root {
  color-scheme: light dark;
  --bg: #f0f3f1;
  --surface: #f5f7f6;
  --surface-2: #eaeeec;
  --surface-3: #e2e7e4;
  --ink: #17211d;
  --muted: #5b6761;
  --line: #cdd6d2;
  --green: #2f6f5e;
  --green-2: #d8e4de;
  --gold: #b9852c;
  --table-surface: #f5f7f6;
  --table-row: #f1f4f2;
  --table-row-alt: #eaeeec;
  --table-head: #e2e7e4;
  --table-text: #17211d;
  --table-head-text: #34433e;
  --table-border: #c5cfcb;
  --chip-surface: var(--surface-2);
  --chip-border: var(--line);
  --chip-text: #34433e;
  --on-dark: #e7ede9;
  --shadow: 0 12px 30px rgba(20, 35, 31, 0.09);
}


html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101513;
  --surface: #18211d;
  --surface-2: #202825;
  --surface-3: #1b2320;
  --ink: #e2e8e4;
  --muted: #9da8a3;
  --line: #31403a;
  --green: #7bb9a4;
  --green-2: #1d312b;
  --gold: #d7b05e;
  --table-surface: #131917;
  --table-row: #171e1b;
  --table-row-alt: #1d2622;
  --table-head: #22302a;
  --table-text: #e6ece8;
  --table-head-text: #e6ece8;
  --table-border: #394943;
  --chip-surface: var(--surface-2);
  --chip-border: var(--line);
  --chip-text: var(--ink);
  --on-dark: #e7ede9;
  --shadow: 0 16px 34px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(185, 133, 44, 0.1), transparent 28%),
    radial-gradient(circle at top right, rgba(47, 111, 94, 0.08), transparent 24%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.4;
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  color: var(--ink);
  border-radius: 10px;
  padding: 0.68rem 0.95rem;
  cursor: pointer;
}

button:hover,
button.is-active {
  border-color: var(--gold);
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  color: var(--ink);
  padding: 0.7rem 0.85rem;
}

select option {
  background: var(--surface);
  color: var(--ink);
}

textarea {
  resize: vertical;
  min-height: 5.5rem;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  line-height: 1.45;
}

h1, h2, h3, p {
  margin: 0;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 16px clamp(16px, 3vw, 36px);
  background: #17211d;
  color: var(--on-dark);
  border-bottom: 4px solid var(--gold);
}

.theme-toggle {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: var(--on-dark);
  border-radius: 999px;
  padding: 0.62rem 0.95rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.theme-toggle:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
}

.brand h1 {
  font-size: clamp(1.25rem, 2.6vw, 2rem);
  line-height: 1.1;
  font-weight: 800;
}

.brand p,
.panel-note,
.footer-note,
.summary-line,
.subtle,
.section-hint,
.match-hint {
  color: var(--muted);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: flex-end;
  align-items: end;
}

html[data-theme="dark"] .theme-toggle {
  border-color: var(--line);
  background: linear-gradient(180deg, #222c27, #18201d);
  color: var(--ink);
}

html[data-theme="dark"] .theme-toggle:hover {
  border-color: var(--gold);
}

.file-button {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  color: var(--ink);
  border-radius: 10px;
  padding: 0.68rem 0.95rem;
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.load-status {
  margin: 0 10px;
  padding: 8px 12px 0;
  font-size: 0.92rem;
  color: var(--muted);
  min-height: 1.4rem;
}

.editor-shell {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  align-items: start;
}

.panel {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.nav-panel {
  position: sticky;
  top: 10px;
  max-height: calc(100vh - 20px);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto auto auto 1fr;
}

.info-panel {
  min-height: calc(100vh - 110px);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}

.panel-head-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-head h2 {
  font-size: 1.02rem;
}

.panel-head p {
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.75rem;
  padding: 0.12rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.search-box {
  display: grid;
  gap: 0.3rem;
  padding: 10px 14px 0;
}

.search-box span {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 700;
}

.civ-box {
  padding-top: 12px;
}

.panel-note {
  padding: 8px 14px 6px;
  font-size: 0.9rem;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.45rem;
  padding: 10px 14px 0;
}

.mode-button {
  padding: 0.72rem 0.9rem;
  font-weight: 700;
}

.mode-button.is-active {
  background: linear-gradient(180deg, #e4efe9, #dbe8e2);
  border-color: var(--green);
}

.scroll-list {
  overflow: auto;
  min-height: 0;
  padding: 8px 10px 12px;
  display: grid;
  gap: 8px;
}

.browser-card,
.tech-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  padding: 10px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 8px 10px;
  cursor: pointer;
}

.browser-card:hover,
.tech-card:hover {
  border-color: var(--gold);
}

.browser-card.is-active,
.tech-card.is-active {
  border-color: var(--green);
  background: linear-gradient(180deg, #e5f0eb, #dce9e4);
}

.browser-card img,
.tech-card img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 4px;
}

.nav-icons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}

.nav-icons img {
  width: 100%;
  height: 22px;
  padding: 2px;
  border-radius: 8px;
}

.card-copy {
  min-width: 0;
  display: grid;
  gap: 0.15rem;
}

.card-copy strong {
  font-size: 0.95rem;
  line-height: 1.15;
}

.card-copy span {
  font-size: 0.8rem;
  color: var(--muted);
}

.match-effect {
  display: block;
  margin-top: 0.1rem;
  color: var(--ink);
  font-size: 0.84rem;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.match-effect strong {
  font-weight: 800;
}

.match-line {
  display: block;
  margin-top: 0.1rem;
  color: var(--gold);
  font-size: 0.75rem;
  line-height: 1.2;
}

.nav-section {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.nav-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.nav-section-head h3 {
  margin: 0;
  font-size: 0.9rem;
}

.nav-section-list {
  display: grid;
  gap: 8px;
}

.civ-nav-card {
  grid-template-columns: 40px minmax(0, 1fr);
}

.civ-nav-card img {
  width: 40px;
  height: 40px;
}

.tag-row {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  align-content: flex-start;
}

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1.55rem;
  padding: 0.08rem 0.48rem;
  border-radius: 999px;
  border: 1px solid var(--chip-border);
  background: var(--chip-surface);
  color: var(--muted);
  font-size: 0.77rem;
  white-space: nowrap;
}

.tag.emphasis {
  background: #ede2c4;
  border-color: #dcc88a;
  color: #6b5320;
}

.resource-cost {
  height: 1.55rem;
  gap: 0.3rem;
}

.resource-cost img {
  width: 14px;
  height: 14px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.info-body {
  overflow: auto;
  min-height: 0;
  padding: 14px;
}

.info-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
  gap: 12px;
  align-items: start;
}

.info-main {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.info-stack {
  display: grid;
  gap: 12px;
}

.summary-card,
.linked-card,
.details-card,
.match-card,
.muted-box {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
}

.summary-card {
  padding: 12px;
}

.summary-head {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) minmax(220px, 280px);
  gap: 12px;
  align-items: center;
}

.summary-head img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  padding: 4px;
}

.summary-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.summary-title h3 {
  font-size: 1.05rem;
}

.summary-side {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
  align-self: start;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 10px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.24rem 0.58rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
}

.meta-chip strong {
  color: var(--ink);
}

.details-card {
  padding: 12px;
  min-width: 0;
}

.civ-unique-section .civ-icon {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 3px;
}

.checklist-civs {
  max-height: 12rem;
}

.section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.section h3 {
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.tech-effect-list {
  display: grid;
  gap: 8px;
}

.tech-effect-item {
  padding: 0.72rem 0.78rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.92rem;
}

.table-section {
  display: grid;
  gap: 8px;
}

.data-table-wrap {
  overflow: auto;
  border: 1px solid var(--table-border);
  border-radius: 12px;
  background: var(--table-surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--table-text);
}

.data-table th,
.data-table td {
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--table-border);
  vertical-align: top;
  text-align: left;
}

.data-table td {
  background: var(--table-row);
}

.data-table th {
  background: var(--table-head);
  color: var(--table-head-text);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.data-table tbody tr:nth-child(even) td {
  background: var(--table-row-alt);
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.table-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}

.table-tags .tag {
  height: 1.4rem;
  padding: 0.05rem 0.42rem;
}

.section-hint,
.match-hint {
  font-size: 0.84rem;
  margin-bottom: 8px;
}

.field-grid {
  display: grid;
  gap: 10px;
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field label,
.rule-field label,
.detail-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 700;
}

.field small,
.rule-note {
  color: var(--muted);
  font-weight: 500;
}

.inline-help {
  color: var(--muted);
  font-size: 0.82rem;
}

.field textarea {
  min-height: 4.5rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
}

.detail-item.wide {
  grid-column: 1 / -1;
}

.checklist {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 0.35rem 0.55rem;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  max-height: 14rem;
  overflow: auto;
}

.check-option {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.5rem;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.88rem;
}

.check-option.is-checked {
  background: #e1ebe6;
  border-color: #c8ddd4;
}

.check-option input {
  width: auto;
  margin: 0;
  accent-color: var(--green);
}

.linked-section {
  margin-top: 12px;
}

.linked-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 8px;
}

.linked-head h3 {
  margin: 0;
}

.linked-list {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-items: start;
}

.linked-card {
  padding: 10px;
  height: auto;
}

.mini-button {
  padding: 0.5rem 0.7rem;
  border-radius: 9px;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.muted-box {
  padding: 0.75rem;
  color: var(--muted);
}

.footer-note {
  padding: 0 14px 14px;
  font-size: 0.9rem;
}

.raw-details {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.raw-details summary {
  cursor: pointer;
  color: var(--green);
  font-weight: 700;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(circle at top left, rgba(215, 176, 94, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(123, 185, 164, 0.1), transparent 24%),
    var(--bg);
}

html[data-theme="dark"] .app-header {
  background: #0c1210;
  color: var(--ink);
}

html[data-theme="dark"] .brand p,
html[data-theme="dark"] .panel-note,
html[data-theme="dark"] .footer-note,
html[data-theme="dark"] .summary-line,
html[data-theme="dark"] .subtle,
html[data-theme="dark"] .section-hint,
html[data-theme="dark"] .match-hint,
html[data-theme="dark"] .panel-head p,
html[data-theme="dark"] .tag,
html[data-theme="dark"] .meta-chip,
html[data-theme="dark"] .pill,
html[data-theme="dark"] .card-copy span,
html[data-theme="dark"] .match-effect,
html[data-theme="dark"] .match-line,
html[data-theme="dark"] .summary-title p,
html[data-theme="dark"] .field span,
html[data-theme="dark"] .inline-help,
html[data-theme="dark"] .rule-note,
html[data-theme="dark"] .detail-label,
html[data-theme="dark"] .rule-field label,
html[data-theme="dark"] .field small,
html[data-theme="dark"] .raw-details summary {
  color: var(--muted);
}

html[data-theme="dark"] .brand h1,
html[data-theme="dark"] .panel-head h2,
html[data-theme="dark"] .summary-title h3,
html[data-theme="dark"] .card-copy strong,
html[data-theme="dark"] .field label,
html[data-theme="dark"] .detail-label,
html[data-theme="dark"] .mini-button,
html[data-theme="dark"] .mode-button.is-active {
  color: var(--ink);
}

html[data-theme="dark"] .panel,
html[data-theme="dark"] .browser-card,
html[data-theme="dark"] .tech-card,
html[data-theme="dark"] .summary-card,
html[data-theme="dark"] .linked-card,
html[data-theme="dark"] .details-card,
html[data-theme="dark"] .match-card,
html[data-theme="dark"] .muted-box {
  background: linear-gradient(180deg, var(--surface), #131917);
}

html[data-theme="dark"] button,
html[data-theme="dark"] .file-button,
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: linear-gradient(180deg, #212923, #181f1b);
  border-color: #3a4943;
  color: var(--ink);
}

html[data-theme="dark"] select option {
  background: var(--surface);
  color: var(--ink);
}

html[data-theme="dark"] .pill,
html[data-theme="dark"] .tag,
html[data-theme="dark"] .meta-chip {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
  color: var(--muted);
}

html[data-theme="dark"] .browser-card img,
html[data-theme="dark"] .tech-card img,
html[data-theme="dark"] .summary-head img,
html[data-theme="dark"] .civ-unique-section .civ-icon,
html[data-theme="dark"] .linked-card img {
  background: #101614;
  border-color: var(--line);
}

html[data-theme="dark"] .browser-card.is-active,
html[data-theme="dark"] .tech-card.is-active {
  background: linear-gradient(180deg, #203129, #1a2721);
  border-color: var(--green);
}

html[data-theme="dark"] .mode-button.is-active {
  background: linear-gradient(180deg, #203129, #1a2721);
  border-color: var(--green);
}

html[data-theme="dark"] .tag.emphasis {
  background: #332b1b;
  border-color: #776038;
  color: #e5d29c;
}

html[data-theme="dark"] .checklist {
  background: #151c19;
  border-color: var(--line);
}

html[data-theme="dark"] .check-option.is-checked {
  background: #1e322c;
  border-color: #355145;
}

html[data-theme="dark"] .raw-details summary {
  color: var(--green);
}

@media (max-width: 1100px) {
  .editor-shell {
    grid-template-columns: 1fr;
  }

  .nav-panel {
    position: static;
    max-height: none;
  }

  .info-panel {
    min-height: 0;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}
