:root {
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-input: #010409;
  --border: #30363d;
  --border-strong: #6e7681;
  --fg: #e6edf3;
  --fg-muted: #7d8590;
  --accent: #2f81f7;
  --accent-hover: #4493f8;
  --error: #f85149;
  --success: #3fb950;
  --grid: #21262d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Yu Gothic", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

header {
  margin-bottom: 24px;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h1 {
  font-size: 28px;
  margin: 0;
  letter-spacing: -0.02em;
}

#subtitle {
  margin: 8px 0 0;
  color: var(--fg-muted);
}

.lang-switch select {
  background: var(--bg-input);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 14px;
}

main {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.input-section, .chart-section {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

label, summary {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
}

textarea, input[type="text"], input[type="password"] {
  width: 100%;
  background: var(--bg-input);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, monospace;
  font-size: 13px;
  resize: vertical;
}

textarea:focus, input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.25);
}

.token-details {
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.token-details summary {
  cursor: pointer;
  list-style: revert;
}

.token-details[open] summary {
  margin-bottom: 8px;
}

.hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--fg-muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

button {
  background: var(--bg-input);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 16px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

button:hover:not(:disabled) {
  border-color: var(--border-strong);
}

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

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.status {
  margin-top: 12px;
  font-size: 13px;
  color: var(--fg-muted);
  min-height: 1.5em;
}

.status[data-kind="error"] {
  color: var(--error);
}

.chart {
  width: 100%;
  min-height: 420px;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-empty {
  height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  font-size: 14px;
}

.chart .grid {
  stroke: var(--grid);
  stroke-width: 1;
}

.chart .tick {
  stroke: var(--border-strong);
  stroke-width: 1;
}

.chart .axis-label {
  fill: var(--fg-muted);
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, monospace;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  margin-top: 16px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, monospace;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.legend-total {
  color: var(--fg-muted);
}

.legend-note {
  color: var(--error);
  font-size: 11px;
}

footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--fg-muted);
  text-align: center;
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

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

@media (max-width: 640px) {
  body { padding: 16px 12px 32px; }
  h1 { font-size: 22px; }
  .input-section, .chart-section { padding: 14px; }
  .actions { gap: 6px; }
  button { padding: 8px 12px; font-size: 13px; }
}
