:root {
  --bg: #1a1a2e;
  --bg-2: #232347;
  --fg: #f1f1f5;
  --muted: #a8a8c4;
  --accent: #ffd166;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top, var(--bg-2), var(--bg));
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.app-header {
  text-align: center;
  padding: 1.5rem 1rem 0.5rem;
}
.app-header h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: 0.02em;
}
.tagline {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.app-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 1.25rem;
  padding: 1rem;
  max-width: 1100px;
  margin: 0 auto;
}

@media (max-width: 760px) {
  .app-main {
    grid-template-columns: 1fr;
  }
}

.wheel-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.5rem;
}

#wheel {
  width: 100%;
  max-width: 520px;
  height: auto;
  cursor: pointer;
  filter: drop-shadow(0 6px 24px rgba(0,0,0,0.4));
}

.petal {
  stroke: rgba(0,0,0,0.35);
  stroke-width: 1.5;
  transition: transform 0.15s ease, filter 0.2s ease;
  transform-origin: 0 0;
}
.petal:hover { filter: brightness(1.15); }
.petal.selected { filter: brightness(1.25) drop-shadow(0 0 8px rgba(255,255,255,0.4)); }

.petal-label {
  fill: #fff;
  font-size: 14px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.center-disc {
  fill: var(--bg-2);
  stroke: rgba(255,255,255,0.15);
  stroke-width: 2;
}
.center-label {
  fill: var(--muted);
  font-size: 12px;
  text-anchor: middle;
  pointer-events: none;
}

.detail-panel {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.25rem;
  backdrop-filter: blur(8px);
  align-self: start;
}

.empty-state h2 {
  margin-top: 0;
}
.empty-state p {
  color: var(--muted);
  line-height: 1.5;
}

.emotion-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.swatch {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15);
}
.emotion-header h2 {
  margin: 0;
  font-size: 1.4rem;
}
.emotion-key {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.detail-panel h3 {
  margin: 1rem 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.ring-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}
.ring-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0.75rem;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
}
.ring-list li:hover { border-color: rgba(255,255,255,0.15); }
.ring-list li.active { border-color: var(--accent); }
.ring-list .level {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.dyad-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.dyad-list li button {
  background: rgba(255,255,255,0.05);
  color: var(--fg);
  border: 1px solid var(--card-border);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
}
.dyad-list li button:hover { background: rgba(255,255,255,0.1); }

.opposite-btn {
  width: 100%;
  background: rgba(255,255,255,0.05);
  color: var(--fg);
  border: 1px solid var(--card-border);
  padding: 0.7rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.95rem;
}
.opposite-btn:hover { background: rgba(255,255,255,0.1); }

.notes textarea {
  width: 100%;
  min-height: 80px;
  background: rgba(0,0,0,0.25);
  color: var(--fg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 0.6rem;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
}
.notes-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
#save-note {
  background: var(--accent);
  color: #1a1a2e;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
#save-note:hover { filter: brightness(1.05); }
.saved-flag {
  color: var(--accent);
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.3s;
}
.saved-flag.show { opacity: 1; }

.saved-notes {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}
.saved-notes li {
  background: rgba(255,255,255,0.04);
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: start;
}
.saved-notes .meta { color: var(--muted); font-size: 0.75rem; }
.saved-notes button {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
}
.saved-notes button:hover { color: #ff6b6b; }

.install-btn {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: var(--accent);
  color: #1a1a2e;
  border: none;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}