/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d0d;
  --surface: #111;
  --surface2: #1a1a1a;
  --surface3: #222;
  --border: #2a2a2a;
  --border-bright: #444;
  --text: #d4d4d4;
  --text2: #777;
  --text-dim: #555;
  --accent: #e0e0e0;
  --accent-bg: rgba(255,255,255,0.04);
  --green: #a3be8c;
  --yellow: #d08770;
  --red: #bf616a;
}

html { font-size: 14px; }
body {
  font-family: 'JetBrains Mono', 'Menlo', 'Consolas', monospace;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Terminal Container ── */
.term {
  width: 100%; max-width: 680px; margin: 2rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

/* ── Title Bar ── */
.titlebar {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: #161616;
  border-bottom: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--text2);
  user-select: none;
}
.titlebar-dots { color: var(--text-dim); letter-spacing: 3px; }
.titlebar-text { flex: 1; text-align: center; }
.titlebar-right { color: var(--text-dim); }

/* ── Body ── */
.term-body { padding: 1.25rem; display: flex; flex-direction: column; gap: 1.25rem; }

.section { display: flex; flex-direction: column; gap: 0.75rem; }
.section-title {
  font-size: 0.7rem; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--text-dim);
  border-bottom: 1px solid var(--border); padding-bottom: 0.3rem;
}

.prompt-line { display: flex; align-items: center; gap: 0.5rem; font-size: 0.95rem; }
.prompt { color: var(--green); font-weight: 700; }
.cmd { color: var(--text); }
.cursor {
  display: inline-block; width: 0.55em; height: 1.1em;
  background: var(--accent); animation: blink 1s step-end infinite;
  margin-left: 2px;
}
@keyframes blink { 50% { opacity: 0; } }

.muted { font-size: 0.8rem; color: var(--text2); line-height: 1.5; }

/* ── Config ── */
.config { background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; padding: 0.75rem; }
.config .field { display: flex; flex-direction: column; gap: 0.3rem; }
.label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text2); }

.input-wrap {
  display: flex; align-items: center;
  background: var(--bg); border: 1px solid var(--border); border-radius: 3px;
  padding: 0 0.5rem;
}
.input-wrap:focus-within { border-color: var(--accent); }
.input-prefix { color: var(--text-dim); font-size: 0.75rem; margin-right: 0.25rem; }
.input-wrap input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-family: 'JetBrains Mono', monospace; font-size: 0.95rem;
  padding: 0.55rem 0; letter-spacing: 0.03em;
}
.input-wrap input::placeholder { color: var(--text-dim); font-size: 0.8rem; }
.char-count { font-size: 0.65rem; color: var(--text-dim); font-family: 'JetBrains Mono', monospace; min-width: 2.8rem; text-align: right; }

.hint { font-size: 0.65rem; color: var(--text-dim); line-height: 1.4; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }

.num-wrap { display: flex; align-items: center; background: var(--bg); border: 1px solid var(--border); border-radius: 3px; overflow: hidden; }
.num-wrap input {
  width: 2.8rem; text-align: center; background: none; border: none; outline: none;
  color: var(--text); font-family: 'JetBrains Mono', monospace; font-size: 0.9rem;
  padding: 0.5rem 0; -moz-appearance: textfield;
}
.num-wrap input::-webkit-inner-spin-button { display: none; }
.num-btn {
  background: none; border: none; color: var(--text2); cursor: pointer;
  font-size: 0.9rem; padding: 0.5rem 0.6rem; transition: color 0.15s;
}
.num-btn:hover { color: var(--accent); }

select {
  width: 100%; padding: 0.5rem 0.5rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 3px;
  color: var(--text); font-family: 'JetBrains Mono', monospace; font-size: 0.8rem;
  cursor: pointer; outline: none;
}
select:focus { border-color: var(--accent); }

/* ── Buttons ── */
.btn {
  width: 100%; padding: 0.6rem; border: 1px solid var(--border);
  background: var(--surface3); color: var(--text);
  font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; font-weight: 500;
  cursor: pointer; transition: all 0.15s; border-radius: 3px;
  letter-spacing: 0.05em;
}
.btn:hover { background: var(--accent-bg); border-color: var(--border-bright); color: var(--accent); }
.btn:active { background: var(--surface); }
.btn-stop { border-color: var(--red); color: var(--red); }
.btn-stop:hover { background: rgba(191, 97, 106, 0.1); }

.btn-sm { width: auto; padding: 0.4rem 0.75rem; font-size: 0.7rem; }
.hidden { display: none !important; }

/* ── Stats Grid ── */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
.stat {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 3px;
  padding: 0.5rem; text-align: center;
}
.stat-label { display: block; font-size: 0.55rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 0.2rem; }
.stat-val { font-family: 'JetBrains Mono', monospace; font-size: 1rem; font-weight: 700; color: var(--text); }
.stat-unit { font-size: 0.6rem; color: var(--text-dim); }

/* ── Results ── */
.result-card {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 3px;
  padding: 0.6rem 0.75rem; margin-bottom: 0.35rem;
}
.result-card .r-addr { font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; word-break: break-all; color: var(--green); margin-bottom: 0.35rem; }
.result-card .r-addr strong { color: var(--accent); }
.result-card .r-meta { font-size: 0.6rem; color: var(--text-dim); margin-bottom: 0.35rem; }
.result-card .r-actions { display: flex; gap: 0.3rem; }
.result-card .r-actions button {
  padding: 0.25rem 0.5rem; border: 1px solid var(--border); border-radius: 2px;
  background: var(--bg); color: var(--text2); font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem; cursor: pointer; transition: all 0.15s;
}
.result-card .r-actions button:hover { border-color: var(--border-bright); color: var(--accent); }
.result-card .r-actions button.copied { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }

.btn-bar { display: flex; gap: 0.4rem; margin-top: 0.25rem; }

/* ── Q&A ── */
.qna { margin-top: 0.5rem; }
.qna details { border-bottom: 1px solid var(--border); }
.qna details:last-child { border-bottom: none; }
.qna summary {
  padding: 0.55rem 0; font-size: 0.8rem; color: var(--text);
  cursor: pointer; user-select: none; list-style: none;
  display: flex; align-items: center; gap: 0.4rem;
}
.qna summary::-webkit-details-marker { display: none; }
.qna summary::before {
  content: '+'; display: inline-block; width: 1rem; text-align: center;
  color: var(--text-dim); font-size: 0.8rem; transition: transform 0.15s;
}
.qna details[open] summary::before { content: '−'; }
.qna details[open] summary { color: var(--accent); }

.details-body {
  padding: 0 0 0.75rem 1.4rem; font-size: 0.75rem; color: var(--text2); line-height: 1.6;
}
.details-body p { margin-bottom: 0.5rem; }
.details-body p:last-child { margin-bottom: 0; }
.details-body ol, .details-body ul { margin-left: 1rem; margin-bottom: 0.5rem; }
.details-body li { margin-bottom: 0.2rem; }
.details-body strong { color: var(--text); }
.details-body code {
  background: var(--surface2); padding: 0.1rem 0.3rem; border-radius: 2px;
  font-size: 0.7rem; color: var(--yellow);
}
.details-body table { width: 100%; border-collapse: collapse; margin: 0.5rem 0; font-size: 0.7rem; }
.details-body th, .details-body td { padding: 0.3rem 0.5rem; text-align: left; border: 1px solid var(--border); }
.details-body th { background: var(--surface2); color: var(--text2); font-weight: 500; }
.details-body th:first-child { width: 40%; }
.details-body td { color: var(--text); }

/* ── Footer Bar ── */
.footer-bar {
  display: flex; justify-content: space-between;
  padding: 0.4rem 0.75rem; font-size: 0.55rem; color: var(--text-dim);
  border-top: 1px solid var(--border); background: #111;
}

/* ── Responsive ── */
@media (max-width: 500px) {
  .term { margin: 1rem 0.5rem; }
  .term-body { padding: 0.75rem; gap: 1rem; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .field-row { grid-template-columns: 1fr; }
  .titlebar-text { font-size: 0.6rem; }
}
