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

:root {
  --accent: #0d9488;
  --accent-soft: rgba(13, 148, 136, 0.08);
  --accent-line: rgba(13, 148, 136, 0.2);
  --line-color: #cbd5e1;
  --line-soft: rgba(203, 213, 225, 0.5);
  --dot-color: #94a3b8;
  --text: #334155;
  --bg: #ffffff;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100vh;
  height: 100dvh;
  padding: 8px;
}

#top-bar {
  width: 100%;
  max-width: 600px;
  text-align: center;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 0;
  position: relative;
}

#emoji-strip {
  font-size: 26px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

#config-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s;
  z-index: 10;
  padding: 4px;
  line-height: 1;
}

#config-btn:hover {
  opacity: 1;
}

#text-input {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  max-width: 400px;
  padding: 12px 16px;
  font-size: 20px;
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  border: 2px solid var(--accent);
  border-radius: 12px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  z-index: 50;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

#text-input.hidden {
  display: none;
}

#text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(13, 148, 136, 0.2);
}

.preview-text {
  font-size: 16px;
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  color: var(--accent);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90vw;
}

.emoji-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--accent-soft);
  border-radius: 12px;
  animation: pop 0.2s ease-out;
}

@keyframes pop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

#figure-container {
  flex: 1;
  width: 100%;
  max-width: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

#radial-menu {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.ring-line {
  stroke: var(--line-soft);
  stroke-width: 2.5;
  stroke-linecap: round;
}

.branch-line {
  stroke: var(--line-color);
  stroke-width: 3;
  stroke-linecap: round;
}

.center-dot {
  fill: none;
  stroke: var(--dot-color);
  stroke-width: 3;
  transition: all 0.2s;
}

.center-dot.active-glow {
  stroke: var(--accent);
  stroke-width: 3.5;
}

.center-text {
  fill: var(--dot-color);
  font-size: 18px;
  pointer-events: none;
  dominant-baseline: central;
  text-anchor: middle;
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
}

.branch-group {
  transition: opacity 0.2s ease;
}

.branch-group.dimmed {
  opacity: 0.12;
}

.node-dot {
  fill: none;
  stroke: var(--dot-color);
  stroke-width: 2.5;
  transition: all 0.15s ease;
}

.node-dot.highlight {
  stroke: var(--accent);
  stroke-width: 3.5;
}

#overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.95);
  opacity: 0;
  transition: opacity 0.3s ease;
  cursor: pointer;
}

#overlay:not(.hidden) {
  opacity: 1;
}

#overlay.hidden {
  pointer-events: none;
}

#overlay-content {
  padding: 40px;
  text-align: center;
  max-width: 90vw;
  border-radius: 16px;
  background: var(--bg);
  border: 1px solid var(--accent-line);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

#overlay-text {
  font-size: clamp(28px, 6vw, 64px);
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  line-height: 1.4;
  color: var(--accent);
  word-break: break-word;
  white-space: pre-wrap;
  font-weight: 700;
}

#config-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.95);
  opacity: 0;
  transition: opacity 0.3s ease;
}

#config-modal:not(.hidden) {
  opacity: 1;
}

#config-modal.hidden {
  pointer-events: none;
}

#config-modal-content {
  background: var(--bg);
  border: 1px solid var(--accent-line);
  border-radius: 16px;
  padding: 32px;
  max-width: 420px;
  width: 90vw;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

#config-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#config-modal-content h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
}

#config-modal-content label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-light);
}

#config-url {
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  border: 2px solid var(--accent-line);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.15s;
  width: 100%;
}

#config-url:focus {
  border-color: var(--accent);
}

.btn-accent {
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  font-weight: 700;
  font-size: 14px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-accent:hover {
  background: #0f766e;
}

.btn-secondary {
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  font-weight: 700;
  font-size: 13px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 2px solid var(--accent-line);
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s;
}

.btn-secondary:hover {
  background: rgba(13, 148, 136, 0.15);
}

.btn-ghost {
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 700;
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px;
  transition: color 0.15s;
}

.btn-ghost:hover {
  color: var(--text);
}

.config-divider {
  height: 1px;
  background: var(--accent-line);
  margin: 4px 0;
}

#editor-link {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  padding: 8px 0;
  transition: opacity 0.15s;
}

#editor-link:hover {
  opacity: 0.7;
}

@media (max-width: 480px) {
  #app { padding: 4px; }
  #emoji-strip { font-size: 20px; min-height: 32px; }
  .emoji-item { width: 32px; height: 32px; border-radius: 10px; }
  .preview-text { font-size: 13px; }
  #config-modal-content { padding: 24px; }
}
