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

:root {
  --white: #ffffff;
  --bg: #ffffff;
  --bg-secondary: #f8f9fa;
  --subtle: #f0f0f3;
  --border: #e5e5e5;
  --text: #1a1a1a;
  --text-secondary: #666666;
  --link: #2563eb;
  --radius: 16px;
  --radius-sm: 10px;
}

[data-theme="dark"] {
  --white: #25262b;
  --bg: #1a1b1e;
  --bg-secondary: #25262b;
  --subtle: #2c2d32;
  --border: #3f3f46;
  --text: #e4e4e7;
  --text-secondary: #a1a1aa;
  --link: #60a5fa;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.2s, color 0.2s;
}

/* Top navigation */
.top-nav {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 100;
}

.menu-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--white);
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: transform 0.2s, box-shadow 0.2s;
}

.menu-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.menu-dropdown {
  position: absolute;
  top: 52px;
  left: 0;
  background: var(--white);
  border-radius: 12px;
  padding: 8px;
  min-width: 160px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s;
}

.menu-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.menu-link {
  display: block;
  padding: 12px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.15s;
}

.menu-link:hover {
  background: var(--subtle);
  color: var(--text);
}

.menu-link.active {
  color: var(--text);
  background: var(--bg);
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 60px 24px;
}

/* Header & Title */
header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 48px;
}

.title {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 0 0 4px 0;
  color: var(--text);
}

.subtitle {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  margin: 0 0 32px 0;
  letter-spacing: 0.02em;
}

/* Hero tile with mosaic gradient */
.hero-tile {
  width: 140px;
  height: 140px;
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
  box-shadow: 
    0 8px 32px rgba(0,0,0,0.15),
    0 2px 4px rgba(0,0,0,0.08);
  position: relative;
  overflow: hidden;
}

/* Mosaic overlay effect */
.hero-tile::before {
  content: '';
  position: absolute;
  inset: 0;
  background: 
    linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%),
    linear-gradient(315deg, rgba(0,0,0,0.1) 0%, transparent 50%);
  border-radius: inherit;
}

/* Grid pattern overlay for mosaic effect */
.hero-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(255,255,255,0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.1) 1px, transparent 1px);
  background-size: 20px 20px;
  border-radius: inherit;
  opacity: 0.5;
}

.hero-number {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 48px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  position: relative;
  z-index: 1;
}

.hero-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.9;
  margin-top: 6px;
  position: relative;
  z-index: 1;
}

.mosaic-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-secondary);
  margin: 12px 0 0 0;
  opacity: 0.5;
  font-weight: 400;
  letter-spacing: 0.02em;
}

/* Welcome */
.welcome {
  text-align: center;
  margin-bottom: 40px;
}

.welcome-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 17px;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.visitor-num {
  color: var(--text);
  font-weight: 600;
}

/* Entry form */
.entry-form {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 48px;
}

.color-picker-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.heatmap-picker {
  flex: 1;
  height: 48px;
  border-radius: var(--radius-sm);
  position: relative;
  cursor: crosshair;
  overflow: hidden;
  border: 1px solid var(--border);
}

.heatmap-gradient {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg,
    #ff6b6b 0%,
    #ffa726 15%,
    #ffee58 30%,
    #66bb6a 45%,
    #42a5f5 60%,
    #7e57c2 75%,
    #ec407a 90%,
    #ff6b6b 100%
  );
}

.picker-cursor {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  left: 50%;
}

.color-preview {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}

.input-row {
  position: relative;
  margin-bottom: 12px;
}

.name-row input {
  font-weight: 500;
}

#nameInput,
#messageInput {
  width: 100%;
  padding: 14px 70px 14px 18px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#nameInput:focus,
#messageInput:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}

#nameInput::placeholder,
#messageInput::placeholder {
  color: var(--text-secondary);
}

.char-count {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

#submitBtn {
  width: 100%;
  padding: 14px 24px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 500;
  background: var(--text);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

#submitBtn:hover {
  opacity: 0.85;
}

#submitBtn:active {
  transform: scale(0.98);
}

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

/* Guestbook entries */
.guestbook {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.entry {
  flex: 1 1 auto;
  min-width: 140px;
  max-width: 280px;
  padding: 18px;
  border-radius: var(--radius-sm);
  color: white;
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: transform 0.2s, box-shadow 0.2s;
}

.entry:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.entry-name {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.85;
  margin-bottom: 6px;
}

.entry-message {
  margin: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  word-break: break-word;
}

.empty-state {
  text-align: center;
  padding: 80px 20px;
}

.empty-state p {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  color: var(--text-secondary);
  margin: 0;
}

/* New entry animation */
@keyframes entryAppear {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.entry.new {
  animation: entryAppear 0.4s ease-out;
}

/* Blog navigation */
.blog-nav {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  margin-top: 60px;
  border-top: 1px solid var(--border);
}

.nav-link {
  padding: 10px 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 20px;
  transition: all 0.2s;
}

.nav-link:hover {
  color: var(--text);
  background: var(--subtle);
}

.nav-link.active {
  color: var(--text);
  background: var(--white);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Footer */
.footer {
  text-align: center;
  padding: 12px;
  border-top: 1px solid var(--border);
}

.footer-content {
  max-width: 680px;
  margin: 0 auto;
}

.footer p {
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px;
  color: var(--text-secondary);
  line-height: 1.2;
  margin: 0;
  opacity: 0.8;
  white-space: nowrap;
}

.footer strong {
  font-weight: 500;
}

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

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

.footer .exe-link {
  display: inline-block;
  padding: 1px 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.footer .exe-link:hover {
  color: var(--text);
  border-color: var(--text-secondary);
  background: var(--subtle);
}

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 40px 16px;
  }
  
  .title {
    font-size: 28px;
  }
  
  .hero-tile {
    width: 120px;
    height: 120px;
    border-radius: 24px;
  }
  
  .hero-number {
    font-size: 40px;
  }
  
  .hero-label {
    font-size: 9px;
  }
  
  .welcome-text {
    font-size: 15px;
  }
  
  .entry-form {
    padding: 16px;
  }
  
  .heatmap-picker {
    height: 40px;
  }
  
  .color-preview {
    width: 40px;
    height: 40px;
  }
  
  .entry {
    min-width: 100%;
  }
  
  .blog-nav {
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .nav-link {
    padding: 8px 16px;
    font-size: 12px;
  }
}
