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

:root {
  --color-bg: #fafaf8;
  --color-text: #111;
  --color-muted: #888;
  --color-border: #ccc;
  --font-system: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', Menlo, Consolas, monospace;
}

body {
  font-family: var(--font-system);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────── */

header {
  padding: 2.5rem 2rem 1rem;
  text-align: center;
}

.title-block {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.title-icon {
  width: 48px;
  height: 48px;
  border-radius: 4px;
}

h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.15rem;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--color-muted);
  letter-spacing: 0.02em;
}

/* ── Form ───────────────────────────────────────────── */

#search-form {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  align-items: flex-end;
  flex-wrap: wrap;
  max-width: 640px;
  margin: 0 auto;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-field label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

#search-form input {
  font-family: var(--font-system);
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--color-text);
  outline: none;
  transition: border-color 0.15s;
}

#search-form input:focus {
  border-color: var(--color-text);
}

#search-form input::placeholder {
  color: #aaa;
}

#username-input {
  width: 200px;
}

#submit-button {
  font-family: var(--font-system);
  font-size: 0.875rem;
  padding: 0.5rem 1.5rem;
  background: var(--color-text);
  color: var(--color-bg);
  border: 1px solid var(--color-text);
  cursor: pointer;
  font-weight: 500;
  letter-spacing: 0.04em;
  transition: background 0.15s;
  height: 36px;
}

#submit-button:hover {
  background: #333;
}

#submit-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Suggestions ────────────────────────────────────── */

#suggestions {
  display: flex;
  gap: 0.25rem;
  justify-content: center;
  align-items: center;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.suggestions-label {
  font-size: 0.65rem;
  color: #bbb;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 0.25rem;
}

.suggestion {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  background: none;
  border: 1px solid #ddd;
  color: var(--color-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.suggestion:hover {
  border-color: var(--color-text);
  color: var(--color-text);
}

/* ── Status ─────────────────────────────────────────── */

.status {
  font-size: 0.75rem;
  color: var(--color-muted);
  margin-top: 0.75rem;
  min-height: 1.2rem;
  text-align: center;
  font-family: var(--font-mono);
}

.status.error {
  color: #ae2012;
}

/* ── Content Layout ─────────────────────────────────── */

#content {
  flex: 1;
  display: flex;
  flex-direction: row;
}

/* ── Chart ──────────────────────────────────────────── */

main {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 1rem 2rem;
  min-height: 300px;
  transition: flex 0.2s;
}

#chart {
  width: 66%;
  max-width: 1000px;
  transition: opacity 0.2s;
}

#chart.loading {
  opacity: 0.3;
  pointer-events: none;
}

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

#chart .bubble {
  cursor: pointer;
}

#chart .bubble-label {
  pointer-events: none;
  font-weight: 500;
}

#chart .empty {
  text-align: center;
  color: var(--color-muted);
  font-size: 0.875rem;
  padding-top: 4rem;
}

/* ── Tooltip ────────────────────────────────────────── */

#tooltip {
  display: none;
  position: absolute;
  background: var(--color-text);
  color: var(--color-bg);
  padding: 0.3rem 0.6rem;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
  letter-spacing: 0.02em;
}

/* ── Commit Panel ───────────────────────────────────── */

#commit-panel {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  height: 100vh;
  background: #fff;
  border-left: 1px solid #e0e0e0;
  flex-direction: column;
  overflow: hidden;
  z-index: 20;
}

#commit-panel.open {
  display: flex;
}

body.panel-open {
  margin-right: 400px;
}

#commit-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e0e0e0;
}

#commit-panel-title {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#commit-panel-close {
  font-family: var(--font-system);
  font-size: 0.7rem;
  padding: 0.25rem 0.75rem;
  background: none;
  border: 1px solid var(--color-border);
  cursor: pointer;
  color: var(--color-muted);
  letter-spacing: 0.02em;
  transition: border-color 0.15s, color 0.15s;
}

#commit-panel-close:hover {
  border-color: var(--color-text);
  color: var(--color-text);
}

#commit-panel-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1.25rem;
}

.commit-item {
  padding: 0.6rem 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.75rem;
  line-height: 1.5;
  color: #444;
}

.commit-item:last-child {
  border-bottom: none;
}

.commit-item mark {
  background: #fef3c7;
  color: #111;
  padding: 0 0.15rem;
  border-radius: 1px;
}

.commit-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.25rem;
}

.commit-repo {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: #aaa;
  text-decoration: none;
  transition: color 0.15s;
}

a.commit-repo:hover {
  color: var(--color-text);
}

.commit-link {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: #aaa;
  text-decoration: none;
  transition: color 0.15s;
}

.commit-link:hover {
  color: var(--color-text);
}

/* ── Footer ─────────────────────────────────────────── */

footer {
  padding: 2rem 2rem 1.5rem;
  text-align: center;
}

.stop-words-label {
  font-size: 0.6rem;
  color: #bbb;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.35rem;
}

#stop-words {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: #ccc;
  line-height: 1.7;
  max-width: 700px;
  margin: 0 auto;
}

.credit {
  margin-top: 1.5rem;
  font-size: 0.6rem;
  color: #bbb;
  letter-spacing: 0.04em;
}

.credit a {
  color: #999;
  text-decoration: none;
}

.credit a:hover {
  color: var(--color-text);
}

/* ── Responsive ─────────────────────────────────────── */

@media (max-width: 900px) {
  #chart {
    width: 80%;
  }
}

@media (max-width: 600px) {
  header {
    padding: 1.5rem 1rem 0.75rem;
  }

  #search-form {
    flex-direction: column;
    align-items: stretch;
  }

  #search-form input {
    width: 100%;
  }

  main {
    padding: 0.5rem 1rem;
  }

  #chart {
    width: 100%;
  }

  #commit-panel {
    width: 100vw;
  }

  body.panel-open {
    margin-right: 0;
  }
}
