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

body {
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;
  background: #0d1117;
  color: #c9d1d9;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Header ─── */

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

header h1 {
  font-size: 1.25rem;
  color: #e6edf3;
  font-weight: 600;
  letter-spacing: -0.02em;
}

header h1 a {
  color: inherit;
  text-decoration: none;
}

header h1 a:hover {
  color: #58a6ff;
}

.subtitle {
  color: #484f58;
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

/* ─── Search ─── */

.search-container {
  display: flex;
  justify-content: center;
  gap: 0;
  margin: 1.5rem auto 2rem;
  max-width: 480px;
  padding: 0 1rem;
}

#search-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  background: #161b22;
  border: 1px solid #30363d;
  border-right: none;
  border-radius: 6px 0 0 6px;
  color: #e6edf3;
  font-family: inherit;
}

#search-input::placeholder {
  color: #484f58;
}

#search-input:focus {
  outline: none;
  border-color: #58a6ff;
  box-shadow: 0 0 0 1px #58a6ff;
}

#search-input:focus + #search-btn {
  border-color: #58a6ff;
}

#search-btn {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 0 6px 6px 0;
  color: #8b949e;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

#search-btn:hover {
  background: #30363d;
  color: #e6edf3;
}

/* ─── Layout ─── */

main {
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  padding: 0 1rem;
  flex: 1;
}

.error {
  background: #3d1f28;
  border: 1px solid #f85149;
  color: #f85149;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.8rem;
}

.loading {
  text-align: center;
  color: #484f58;
  padding: 3rem 0;
  font-size: 0.8rem;
}

/* ─── Profile ─── */

#profile-summary {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.profile-header {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.profile-pfp {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.profile-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #e6edf3;
}

.profile-username {
  color: #8b949e;
  font-size: 0.8rem;
}

.profile-fid {
  color: #484f58;
  font-size: 0.75rem;
}

.profile-bio {
  color: #8b949e;
  font-size: 0.8rem;
  margin-top: 0.35rem;
  line-height: 1.4;
}

.profile-verifications {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.verification-addr {
  font-size: 0.7rem;
  color: #58a6ff;
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
}

/* ─── Type Navigation ─── */

#type-nav {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid #21262d;
}

#type-nav button {
  padding: 0.4rem 0.65rem;
  font-size: 0.75rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #8b949e;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s;
}

#type-nav button:hover {
  color: #e6edf3;
}

#type-nav button.active {
  color: #e6edf3;
  border-bottom-color: #58a6ff;
}

.tab-count {
  font-size: 0.65rem;
  background: #21262d;
  color: #484f58;
  padding: 0.05rem 0.35rem;
  border-radius: 10px;
  margin-left: 0.2rem;
}

#type-nav button.active .tab-count {
  background: #388bfd26;
  color: #58a6ff;
}

/* ─── Message List ─── */

#message-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* ─── Shared item styles ─── */

.cast-item,
.reaction-item,
.link-item,
.verification-item,
.userdata-item {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 4px;
  overflow: hidden;
  transition: border-color 0.15s;
}

.cast-item.expanded,
.reaction-item.expanded,
.link-item.expanded,
.verification-item.expanded,
.userdata-item.expanded {
  border-color: #30363d;
}

.cast-summary,
.reaction-summary,
.link-summary,
.verification-summary,
.userdata-summary {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
}

.cast-summary:hover,
.reaction-summary:hover,
.link-summary:hover,
.verification-summary:hover,
.userdata-summary:hover {
  background: #1c2128;
}

/* ─── Timestamp ─── */

.cast-time,
.reaction-time,
.link-time,
.verification-time,
.userdata-time {
  font-size: 0.7rem;
  color: #484f58;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── Cast ─── */

.cast-preview {
  font-size: 0.8rem;
  color: #c9d1d9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cast-detail,
.reaction-detail,
.link-detail,
.verification-detail,
.userdata-detail {
  border-top: 1px solid #21262d;
}

.cast-detail .json-view,
.reaction-detail .json-view,
.link-detail .json-view,
.verification-detail .json-view,
.userdata-detail .json-view {
  border: none;
  border-radius: 0;
}

/* ─── Reaction ─── */

.reaction-type {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.reaction-like {
  background: #3d1f28;
  color: #f85149;
}

.reaction-recast {
  background: #1b3a2d;
  color: #3fb950;
}

.reaction-target {
  font-size: 0.8rem;
  color: #8b949e;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Link ─── */

.link-type {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
  background: #1f2a3d;
  color: #58a6ff;
}

.link-target {
  font-size: 0.8rem;
  color: #8b949e;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Verification ─── */

.verification-status {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.verification-active {
  background: #1b3a2d;
  color: #3fb950;
}

.verification-removed {
  background: #3d1f28;
  color: #f85149;
}

.verification-protocol {
  font-size: 0.7rem;
  color: #484f58;
  white-space: nowrap;
  flex-shrink: 0;
}

.verification-address {
  font-size: 0.8rem;
  color: #58a6ff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── UserData ─── */

.userdata-type {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
  background: #2d1f3d;
  color: #d2a8ff;
}

.userdata-value {
  font-size: 0.8rem;
  color: #8b949e;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── JSON View ─── */

.json-view {
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.75rem;
  line-height: 1.5;
}

.json-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 0.3rem 0.5rem 0;
}

.json-toggle {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 3px;
  color: #484f58;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s;
}

.json-toggle:hover {
  color: #8b949e;
  background: #21262d;
}

.json-content {
  margin: 0;
  padding: 0.4rem 0.75rem 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.json-raw {
  white-space: pre-wrap;
  word-break: break-all;
}

.json-key {
  color: #79c0ff;
}

.json-string {
  color: #a5d6ff;
}

.json-number {
  color: #56d364;
}

.json-boolean {
  color: #ff7b72;
}

.json-null {
  color: #484f58;
  font-style: italic;
}

.json-bracket {
  color: #8b949e;
}

.json-colon {
  color: #8b949e;
}

/* ─── Storage ─── */

.storage-units {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 4px;
  padding: 0.6rem 0.75rem;
  font-size: 0.8rem;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.storage-units-label {
  color: #484f58;
}

.storage-units-value {
  color: #e6edf3;
  font-weight: 600;
  font-size: 0.9rem;
}

.storage-units-detail {
  color: #484f58;
  font-size: 0.7rem;
}

.storage-item {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 4px;
  padding: 0.6rem 0.75rem;
}

.storage-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.35rem;
}

.storage-type {
  font-size: 0.8rem;
  font-weight: 600;
  color: #e6edf3;
}

.storage-count {
  font-size: 0.75rem;
  color: #484f58;
}

.storage-bar-bg {
  height: 4px;
  background: #21262d;
  border-radius: 2px;
  overflow: hidden;
}

.storage-bar-fill {
  height: 100%;
  background: #58a6ff;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.storage-bar-warn {
  background: #d29922;
}

.storage-bar-critical {
  background: #f85149;
}

.storage-pct {
  font-size: 0.65rem;
  color: #484f58;
  margin-top: 0.15rem;
  text-align: right;
}

.storage-tiers {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 4px;
  padding: 0.6rem 0.75rem;
}

.storage-tiers-label {
  font-size: 0.7rem;
  color: #484f58;
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.storage-tier {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.8rem;
}

.storage-tier-type {
  font-weight: 600;
  color: #d2a8ff;
}

.storage-tier-expires {
  color: #484f58;
  font-size: 0.7rem;
}

.storage-raw-toggle {
  display: flex;
  justify-content: center;
  padding: 0.25rem 0;
}

/* ─── Pagination ─── */

.pagination-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  margin-top: 0.25rem;
}

.pagination-btn {
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 4px;
  color: #8b949e;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.pagination-btn:hover:not(:disabled) {
  background: #21262d;
  color: #e6edf3;
}

.pagination-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.pagination-label {
  font-size: 0.7rem;
  color: #484f58;
}

/* ─── Footer ─── */

footer {
  text-align: center;
  padding: 2rem 1rem 1.5rem;
  margin-top: 2rem;
  border-top: 1px solid #21262d;
}

footer p {
  font-size: 0.7rem;
  color: #30363d;
}

footer a {
  color: #484f58;
  text-decoration: none;
}

footer a:hover {
  color: #8b949e;
}

/* ─── Responsive ─── */

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

  .search-container {
    margin: 1rem auto 1.5rem;
  }

  #type-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .cast-summary,
  .reaction-summary,
  .link-summary,
  .verification-summary,
  .userdata-summary {
    padding: 0.4rem 0.5rem;
    gap: 0.4rem;
  }
}
