@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.css');

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #1c1c1c;
  --border: #262626;
  --border-strong: #3a3a3a;
  --text: #ededed;
  --text-muted: #888;
  --text-faint: #5a5a5a;
  --accent: #ededed;
  --accent-dim: #262626;
  --S: #ef4444;
  --A: #f59e0b;
  --B: #10b981;
  --C: #6b7280;
  --D: #4b5563;
  --up: #ef4444;
  --down: #10b981;
  --radius: 6px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 16px; line-height: 1.55;
  font-feature-settings: "tnum" 1;
  padding: 48px 24px;
}

.mono {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-feature-settings: "tnum" 1;
}

.container {
  max-width: 1100px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr 360px; gap: 32px;
}
@media (max-width: 880px) {
  .container { grid-template-columns: 1fr; gap: 24px; }
}

h1 { display: none; }
.subtitle { display: none; }
.rho-info { display: none; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 12px;
}

.card h2 {
  font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 18px;
}

.row {
  display: flex; align-items: center; gap: 16px;
  padding: 7px 0;
}
.row label {
  flex: 0 0 150px;
  font-size: 15px;
  color: var(--text);
}
.row input[type="range"] {
  flex: 1;
  accent-color: var(--text);
  height: 4px;
}
.row input[type="number"] {
  flex: 0 0 90px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 4px;
  text-align: right;
  font-size: 14px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  outline: none;
}
.row input[type="number"]:focus {
  border-color: var(--border-strong);
}

.cat-toggle {
  display: flex; gap: 4px;
  margin-bottom: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: var(--radius);
}
.cat-toggle button {
  flex: 1; padding: 10px 12px;
  background: transparent; border: none;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  transition: all 0.12s;
}
.cat-toggle button.active {
  background: var(--surface-2);
  color: var(--text);
}

.chart-card {
  padding: 22px 22px 18px;
}
.chart-card h2 {
  margin-bottom: 18px;
}
#chart {
  width: 100%;
  min-height: 280px;
}
#chart svg, .mini-chart svg { display: block; overflow: visible; }
.mini-chart {
  margin-top: 12px;
  width: 100%;
}
.title-result {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
  margin-left: 4px;
}
.title-result .grade-tag { font-weight: 700; margin: 0 4px; }
.title-result .grade-S { color: var(--S); }
.title-result .grade-A { color: var(--A); }
.title-result .grade-B { color: var(--B); }
.title-result .grade-C { color: var(--C); }
.title-result .grade-D { color: var(--D); }

.compare {
  display: grid; grid-template-columns: 1fr auto 1fr;
  gap: 8px; align-items: stretch;
  margin-bottom: 16px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
}
.panel.next {
  border-color: var(--text);
}
.panel-title {
  font-size: 10px; color: var(--text-faint);
  letter-spacing: 0.1em; text-transform: uppercase;
  margin-bottom: 14px;
}
.grade {
  font-size: 44px; font-weight: 700;
  line-height: 1; letter-spacing: -0.04em;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.grade.S { color: var(--S); }
.grade.A { color: var(--A); }
.grade.B { color: var(--B); }
.grade.C { color: var(--C); }
.grade.D { color: var(--D); }

.label {
  font-size: 12px; color: var(--text-muted);
  margin-bottom: 14px;
  min-height: 16px;
}
.num {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 17px; color: var(--text);
  font-feature-settings: "tnum" 1;
}
.rank-text {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 4px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}

.arrow {
  align-self: center;
  display: flex; flex-direction: column;
  align-items: center;
  color: var(--text-faint);
}
.arrow .arrow-icon {
  font-size: 14px;
}
.arrow .delta {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 12px; margin-top: 6px;
  font-weight: 600;
}
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.same { color: var(--text-faint); }

.info {
  font-size: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 18px 20px;
  border-radius: var(--radius);
  line-height: 1.9;
  color: var(--text-muted);
}
.info strong { color: var(--text); font-weight: 500; }
.info code {
  background: var(--surface-2);
  padding: 2px 7px;
  border-radius: 3px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 12px;
  color: var(--text);
  margin-right: 4px;
}
.info hr {
  border: none; border-top: 1px solid var(--border);
  margin: 12px 0;
}
.info .grade-S { color: var(--S); }
.info .grade-A { color: var(--A); }
.info .grade-B { color: var(--B); }

details {
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
}
details summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  list-style: none;
  outline: none;
}
details summary::-webkit-details-marker { display: none; }
details summary::after {
  content: "+";
  float: right;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  color: var(--text-faint);
}
details[open] summary::after { content: "−"; }
.feat-imp {
  margin-top: 10px;
  font-size: 11px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  color: var(--text-muted);
}
.feat-imp > div {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}
.feat-imp .name { width: 130px; }
.feat-imp .val { width: 50px; text-align: right; }
.feat-imp .bar {
  flex: 1;
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}
.feat-imp .bar::after {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--text);
  width: var(--w, 0%);
}

.summary-line {
  font-size: 14px;
  color: var(--text-muted);
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 12px 0;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  line-height: 1.8;
}
.summary-line b {
  color: var(--text);
  font-weight: 600;
}

.card-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.6;
}
.row.bound {
  justify-content: space-between;
}
.row.bound input[type="number"] {
  flex: 0 0 120px;
}
#optimize {
  margin-top: 12px;
  width: 100%;
  padding: 13px;
  background: var(--text);
  border: none;
  color: var(--bg);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.12s;
}
#optimize:hover { background: #ddd; }
#optimize:disabled {
  background: var(--border-strong);
  color: var(--text-muted);
  cursor: not-allowed;
}

.opt-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.opt-title {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
  color: var(--text-muted);
}
.opt-body {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 14px;
  color: var(--text);
  line-height: 1.9;
}
.opt-body .meta {
  color: var(--text-muted); font-size: 10px; display: block; margin-top: 4px;
}
.opt-body b {
  font-weight: 600;
}
.opt-body .grade-tag {
  font-weight: 700;
  display: inline-block;
}
.opt-body .grade-S { color: var(--S); }
.opt-body .grade-A { color: var(--A); }
.opt-body .grade-B { color: var(--B); }
button.apply {
  margin-top: 10px;
  padding: 7px 12px;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px;
}
button.apply:hover { background: var(--surface-2); }

.loader {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 999; gap: 16px;
  color: var(--text-muted);
  font-size: 12px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}
.loader.hidden {
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
