@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=Noto+Sans+SC:wght@400;500;700&family=Outfit:wght@400;500;600;700&display=swap");

:root {
  --bg: #f5f4ef;
  --panel: #ffffff;
  --panel-soft: #fafbf9;
  --line: #d8dfdc;
  --line-strong: #bcc8c3;
  --text: #20343a;
  --text-soft: #5e747a;
  --primary: #197c84;
  --primary-soft: #e7f5f4;
  --accent: #b1772a;
  --danger: #be4b3a;
  --radius: 14px;
  --shadow: 0 12px 32px rgba(26, 50, 58, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Outfit", "Noto Sans SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 4% 0%, #d9efee 0, transparent 26%),
    radial-gradient(circle at 97% 6%, #f0dfc3 0, transparent 28%),
    linear-gradient(180deg, var(--bg), #f2f1e8);
  padding: 20px 16px 28px;
}

.page {
  max-width: 1320px;
  margin: 0 auto;
}

.hero {
  background: linear-gradient(135deg, #ffffff, #fdfbf5);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-tools {
  display: grid;
  gap: 8px;
}

.hero h1 {
  margin: 0;
  font-family: "Fraunces", "Noto Sans SC", serif;
  font-size: clamp(30px, 4.8vw, 44px);
}

.ui-lang-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #43666f;
  font-size: 13px;
  font-weight: 600;
}

.ui-lang-box select {
  min-width: 120px;
  height: 34px;
  border-radius: 8px;
}

.hero p {
  margin: 8px 0 0;
  color: var(--text-soft);
}

.stats {
  margin-top: 12px;
  border: 1px dashed #c6d7d5;
  border-radius: 10px;
  background: #f8fcfc;
  padding: 8px 10px;
  color: #376e72;
  font-size: 14px;
}

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

.tab {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #ffffff;
  color: var(--text-soft);
  font-weight: 700;
  padding: 8px 14px;
  cursor: pointer;
}

.tab.active {
  border-color: #9fd3d2;
  background: var(--primary-soft);
  color: #176d72;
}

.tab.disabled {
  opacity: 0.5;
  filter: grayscale(0.3);
  cursor: not-allowed;
}

.pages {
  margin-top: 12px;
}

.app-footer {
  margin-top: 14px;
  padding: 10px 2px 4px;
  text-align: center;
  color: #61757a;
  font-size: 12px;
}

.app-footer a {
  color: #2a7075;
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

.page-panel {
  display: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
}

.page-panel.active {
  display: block;
  animation: fadeIn 0.28s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 48%) minmax(380px, 1fr);
  gap: 12px;
}

.pane {
  min-width: 0;
}

.search-shell,
.result-shell,
.detail-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.search-shell {
  padding: 10px;
}

.search-shell h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #34545c;
}

.result-shell {
  margin-top: 10px;
  padding: 10px;
  background: var(--panel-soft);
}

.shell-title {
  font-size: 13px;
  font-weight: 700;
  color: #4a686f;
  margin-bottom: 8px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 8px;
}

.item-controls {
  display: block;
}

.monster-controls {
  display: block;
}

.item-row {
  display: grid;
  gap: 8px;
}

.item-row-main {
  grid-template-columns: minmax(0, 1fr) auto;
  margin-bottom: 8px;
}

.item-row-filters {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

input,
select,
button {
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  font-family: inherit;
  font-size: 14px;
}

input,
select {
  padding: 0 10px;
  background: #ffffff;
  color: var(--text);
}

button {
  cursor: pointer;
  padding: 0 14px;
  font-weight: 700;
  background: linear-gradient(120deg, #177f86, #2a7f9f);
  border-color: #177f86;
  color: #ffffff;
}

button:hover {
  filter: brightness(1.04);
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid #9fd7d5;
  outline-offset: 1px;
}

.list {
  display: grid;
  gap: 8px;
  max-height: 52vh;
  overflow: auto;
  padding-right: 2px;
}

.detail-list {
  max-height: 74vh;
}

.item {
  border: 1px solid #d8dedb;
  border-radius: 11px;
  background: #fff;
  padding: 10px 11px;
  font-size: 14px;
  line-height: 1.5;
}

.item .meta {
  color: #4e7074;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.item .line {
  color: #2d434a;
  word-break: break-word;
}

.item .actions {
  margin-top: 7px;
}

.link-btn {
  border: 1px solid #b5cecc;
  border-radius: 8px;
  background: #f0fbfa;
  color: #2c7678;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  cursor: pointer;
}

.link-btn:hover {
  filter: brightness(0.98);
}

.pager {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pager .info {
  color: #5f7377;
  font-size: 13px;
}

.pager .jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #4f6870;
  font-size: 13px;
}

.pager .page-input {
  width: 70px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid #bdd0cc;
  padding: 0 8px;
}

.pager button {
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 13px;
}

.pager button.secondary {
  background: #ffffff;
  color: #2c5960;
  border-color: #bdd0cc;
}

.pager button:disabled {
  opacity: 0.55;
  cursor: default;
}

.detail-box {
  padding: 10px;
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.detail-box h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #30525a;
}

.detail-head h3 {
  margin: 0;
}

.detail-head .link-btn {
  height: 32px;
}

.sticky {
  position: sticky;
  top: 10px;
}

.subtle {
  color: var(--text-soft);
  font-size: 12px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.badge {
  display: inline-block;
  border: 1px solid #c7d8d3;
  border-radius: 999px;
  padding: 1px 8px;
  background: #f2faf9;
  font-size: 12px;
  color: #2f6b70;
  margin-right: 6px;
}

.sub-preview {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #d8e2de;
  border-radius: 8px;
  background: #f7fbfa;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  margin-top: 6px;
}

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

.metric-table th,
.metric-table td {
  border: 1px solid #d9e1de;
  padding: 4px 6px;
  text-align: right;
}

.metric-table th:first-child,
.metric-table td:first-child {
  text-align: left;
}

.metric-table thead th {
  background: #f0f6f4;
  color: #345960;
}

.warn {
  color: var(--danger);
  font-weight: 600;
}

.game-unbreak {
  white-space: nowrap;
}

.game-color {
  color: var(--accent);
}

.game-ruby rt {
  font-size: 0.7em;
  color: #527177;
}

.term-link {
  display: inline;
  border: 0;
  padding: 0;
  margin: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  cursor: pointer;
}

.term-link:hover {
  color: #1d7a80;
}

.term-popover {
  position: fixed;
  z-index: 2000;
  width: min(520px, calc(100vw - 24px));
  max-height: min(62vh, 560px);
  overflow: auto;
  border: 1px solid #c9d7d2;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 20px 42px rgba(20, 44, 51, 0.2);
  padding: 10px;
}

.term-popover.hidden {
  display: none;
}

.term-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.term-popover-close {
  height: 30px;
  border-radius: 8px;
  border: 1px solid #bfd0cc;
  background: #ffffff;
  color: #2f6368;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
}

.term-popover-body {
  display: grid;
  gap: 8px;
}

.term-fallback {
  margin: 0 2px 4px;
}

code {
  display: inline-block;
  padding: 1px 4px;
  border-radius: 6px;
  border: 1px solid #d5dfdb;
  background: #eef3f1;
  font-size: 12px;
}

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

  .sticky {
    position: static;
  }

  .detail-list {
    max-height: 54vh;
  }
}

@media (max-width: 980px) {
  .controls,
  .item-row-filters {
    grid-template-columns: 1fr 1fr;
  }

  .controls button,
  .item-row-filters button {
    grid-column: span 2;
  }

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

@media (max-width: 640px) {
  body {
    padding: 12px 10px 20px;
  }

  .hero,
  .page-panel {
    padding: 12px;
  }

  .hero-top {
    align-items: stretch;
  }

  .ui-lang-box {
    width: 100%;
    justify-content: space-between;
  }

  .controls,
  .item-row-filters {
    grid-template-columns: 1fr;
  }

  .controls button,
  .item-row-filters button {
    grid-column: auto;
  }

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

  .list,
  .detail-list {
    max-height: 42vh;
  }

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