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

:root {
  --bg: #0a0908;
  --bg-light: #141210;
  --lived: #c9a84c;
  --lived-dim: #8a7355;
  --current: #e8c547;
  --future: #1e1c1a;
  --text: #a09888;
  --text-dim: #5a5348;
  --text-bright: #d4c8b0;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Cormorant Garamond', Georgia, serif;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
}

.layout {
  display: flex;
  height: 100vh;
  width: 100vw;
}

.grid-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.grid-scroll {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1.5rem 0.5rem;
  min-height: 0;
  overflow-y: auto;
}

.grid-panel.scrollable .grid-scroll {
  justify-content: flex-start;
}

.grid-footer {
  flex-shrink: 0;
  background: var(--bg);
  border-top: 1px solid #1e1c1a;
  padding: 0.6rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.grid-empty {
  font-size: 1.4rem;
  font-style: italic;
  color: var(--text-dim);
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(52, 1fr); /* overridden by JS when view mode changes */
}

.grid-container:empty {
  display: none;
}

.week {
  border-radius: 1px;
  background: var(--future);
  cursor: default;
}

.week.lived {
  background: var(--lived-dim);
}

.week.current {
  background: var(--current);
  animation: pulse 2s ease-in-out infinite;
  box-shadow: 0 0 6px var(--current);
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px var(--current); }
  50% { opacity: 0.6; box-shadow: 0 0 10px var(--current); }
}

.stats-bar {
  margin-top: 1.2rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  text-align: center;
}

.stats-bar:empty {
  display: none;
}

.input-panel {
  width: 340px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: 1px solid #1e1c1a;
  padding: 2rem;
}

.input-container {
  width: 100%;
}

.title {
  font-size: 2.4rem;
  font-weight: 400;
  color: var(--text-bright);
  letter-spacing: 0.08em;
  margin-bottom: 0.25rem;
}

.subtitle {
  font-size: 1.05rem;
  font-style: italic;
  color: var(--text-dim);
  margin-bottom: 2.5rem;
}

#life-form {
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
}

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

.field label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
}

.field input,
.field select {
  background: var(--bg-light);
  border: 1px solid #2a2724;
  color: var(--text-bright);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.05rem;
  padding: 0.6rem 0.7rem;
  border-radius: 2px;
  outline: none;
  transition: border-color 0.2s;
}

.field input:focus,
.field select:focus {
  border-color: var(--lived-dim);
}

.field select option {
  background: var(--bg);
  color: var(--text);
}

.cta {
  margin-top: 0.8rem;
  background: transparent;
  border: 1px solid var(--lived-dim);
  color: var(--lived);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.1rem;
  padding: 0.7rem;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: background 0.2s, color 0.2s;
  border-radius: 2px;
}

.cta:hover {
  background: var(--lived);
  color: var(--bg);
}

.view-toggle {
  display: none;
  gap: 0;
  margin-top: 0.8rem;
  border: 1px solid #2a2724;
  border-radius: 2px;
  overflow: hidden;
  width: fit-content;
}

.view-toggle.visible {
  display: flex;
}

.view-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.5rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.view-btn + .view-btn {
  border-left: 1px solid #2a2724;
}

.view-btn.active {
  background: var(--lived-dim);
  color: var(--bg);
}

.context-info {
  margin-top: 1.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-dim);
}

.context-info:empty {
  display: none;
}

.tooltip {
  position: fixed;
  background: var(--bg-light);
  border: 1px solid #2a2724;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  padding: 0.35rem 0.6rem;
  border-radius: 2px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 100;
  white-space: nowrap;
}

.tooltip.visible {
  opacity: 1;
}

.tabs {
  display: none;
}

@media (max-width: 768px) {
  html, body {
    overflow: hidden;
  }

  .tabs {
    display: flex;
    border-bottom: 1px solid #1e1c1a;
    flex-shrink: 0;
  }

  .tab {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-dim);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.8rem;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    border-bottom: 2px solid transparent;
  }

  .tab.active {
    color: var(--text-bright);
    border-bottom-color: var(--lived-dim);
  }

  .layout {
    flex-direction: column;
    height: calc(100vh - 41px);
    width: 100vw;
  }

  .input-panel {
    width: 100%;
    border-left: none;
    padding: 1.5rem;
    overflow-y: auto;
  }

  .input-panel[hidden] {
    display: none;
  }

  .input-container {
    max-width: 400px;
  }

  .title {
    font-size: 2rem;
  }

  .subtitle {
    margin-bottom: 1.5rem;
  }

  .grid-panel {
    padding: 1rem;
    min-height: 0;
    flex: 1;
    overflow-y: auto;
    justify-content: flex-start;
  }

  .grid-panel[hidden] {
    display: none;
  }

  .stats-bar {
    font-size: 0.7rem;
  }
}
