*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --green: #3fb950;
  --green-dim: #238636;
  --blue: #58a6ff;
  --yellow: #d29922;
  --red: #f85149;
  --muted: #8b949e;
  --text: #e6edf3;
  --cursor-color: #3fb950;
  --font: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ─── Header ─── */
header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 18px 0 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.05em;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ─── Console wrap ─── */
#console-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px 0 4px;
}

/* ─── Output area ─── */
#output {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 8px;
  scroll-behavior: smooth;
}

#output::-webkit-scrollbar {
  width: 6px;
}
#output::-webkit-scrollbar-track {
  background: transparent;
}
#output::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.entry {
  padding: 2px 0;
  animation: fadeIn 0.1s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}

.entry-input {
  color: var(--text);
}

.entry-input .entry-prompt {
  color: var(--green);
  margin-right: 6px;
  user-select: none;
}

.entry-result {
  color: var(--blue);
  padding-left: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.entry-result.is-error {
  color: var(--red);
}

.entry-result.is-info {
  color: var(--muted);
}

.entry-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 6px 0;
}

/* ─── Input row ─── */
#input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0 6px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

.prompt {
  color: var(--green);
  user-select: none;
  flex-shrink: 0;
}

#input-container {
  flex: 1;
  position: relative;
  cursor: text;
  min-height: 1.5em;
  display: flex;
  align-items: center;
  overflow: hidden;
}

#hidden-input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  cursor: text;
  caret-color: transparent;
  background: transparent;
  border: none;
  outline: none;
  color: transparent;
  font-family: inherit;
  font-size: inherit;
}

#input-before,
#input-after {
  white-space: pre;
  color: var(--text);
}

#cursor {
  display: inline-block;
  width: 2px;
  height: 1.15em;
  background: var(--cursor-color);
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
  flex-shrink: 0;
}

#cursor.over-char {
  width: 0.6em;
  opacity: 0.5;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

#live-result {
  color: var(--muted);
  font-size: 0.9em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 40%;
  flex-shrink: 0;
  transition: color 0.15s;
}

#live-result.is-value {
  color: var(--blue);
}

#live-result.is-error {
  color: var(--red);
}

/* ─── Hint bar ─── */
#hint-bar {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  padding: 6px 0 10px;
  font-size: 0.72rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#hint-bar kbd {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 4px;
  font-family: inherit;
  font-size: 0.95em;
  line-height: 1.4;
  color: var(--text);
}

#hint-bar code {
  color: var(--yellow);
  font-family: inherit;
}

/* ─── Responsive ─── */
@media (max-width: 600px) {
  html, body { font-size: 13px; }
  #live-result { display: none; }
  #hint-bar { gap: 10px; }
}
