:root {
  --primary: #9e85e2;         /* Purple */
  --primary-dark: #623ec6;    /* Deeper purple */
  --accent: #ff7e59;          /* Warm orange accent from palette */
  --ink: #3f1293;             /* Deep purple text */
  --muted-bg: #f5f3fa;        /* Soft purple-tinted bg */
  --muted-line: #e6e1f4;      /* Subtle line */
  --node-fill-min: #ffffff;   /* very light pink */
  --node-fill-max: #ffc39c;   /* purple-pink */
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  overflow-y: auto;
  -webkit-text-size-adjust: 100%;
  font-family: "STIX Two Text", serif;
  font-weight: 400;
  font-style: normal;
}

/* Centered page wrapper */
.page {
  max-width: 680px;
  margin: clamp(16px, 4vh, 32px) auto;
  padding: 0 24px;
}

/* Only lock scrolling while the force-graph is on screen */
body.graph-mode {
  overflow: hidden;
}

/* Title bar styles */
.title-left {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: calc(10px + env(safe-area-inset-left));
  z-index: 10;
  margin: 0;
  font-family: 'Reenie Beanie', cursive;
  font-size: 2rem;
  color: var(--primary-dark);
}

h1 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--primary);
}

.title-controls {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  right: 10px;
  left: auto;
  transform: none;
  z-index: 10;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  width: auto;
  justify-content: flex-end;
}

.title-controls button {
  padding: 0.25rem;
  white-space: nowrap;
  background: transparent;
  border: none;
  border-radius: 6px;
  width: auto;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.2s, transform 0.1s ease;
  color: var(--primary-dark);
}

.title-controls button svg {
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 0 2px rgba(151, 118, 243, 0.45));
}

.title-controls button:hover {
  background: transparent;
  color: var(--primary-dark);
  transform: translateY(-1px);
}

#poem {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100dvh;
  margin: 0;
  padding: 0;
  /* background: #f4f4f9; */
}

.stanza {
  margin-bottom: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 6px;
  transition: background 0.2s;
}

.stanza:hover {
  background-color: #ffe0e0;
}

/* desktop/tablet: flow layout */
.editor-container {
  position: relative;
  left: auto;
  top: auto;
  transform: none;
  width: 100%;
  max-width: 100%;
  z-index: 1;
  margin-top: 96px;
}

.random-circle {
  background: white;
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.random-circle:hover {
  background: var(--primary);
  color: white;
}

#poemEditor {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-height: 150px;
  line-height: 1.25;
  padding: 1rem;
  border: 2px solid var(--primary);
  border-radius: 12px;
  box-shadow: 0 1px 0 var(--muted-line) inset;
  font-family: inherit;
  margin-bottom: 1rem;
  resize: vertical;
}

#poemEditor:focus {
  outline: none;
  border-color: var(--primary);
}

.editor-field {
  position: relative;
  width: 100%;
}

/* random-circle only used when floating inside; safe to keep but unused now */

button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s;
}

button:hover {
  background: var(--primary-dark);
}

.hidden {
  display: none;
}

#poemGraph {
  width: 100%;
  height: 100%;
  /* background: #c8e0ff; */
}

.background {
  cursor: move;
  fill: none;
  pointer-events: all;
}

/* container uses default pointer-events to allow interaction */

.node {
  cursor: text;
}

.text-group {
  pointer-events: all;
}

.node text {
  font-size: 10px;
  font-family: inherit;
  fill: var(--ink);
  pointer-events: all;
  cursor: text;
}

.node circle {
  fill:rgb(255, 255, 255);
  stroke: var(--primary);
  stroke-width: 2px;
  transition: fill 0.2s;
}

.node:hover circle {
  fill: #f9f0ff;
}

.link {
  stroke: var(--accent);
  stroke-opacity: 0.4;
  stroke-width: 2px;
  fill: none;
  stroke-linecap: square;
}

/* Make links thicker near nodes */
.link {
  stroke-width: 3px;
  stroke-dasharray: 0,2,4,6,8;
  stroke-linecap: round;
}

/* Add styles for selected text */
::selection {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--primary-dark);
}

/* Show move cursor when Alt/Option is pressed */
.node:hover {
  cursor: move;
}

/* Update helper text */
#poemGraph::after {
  content: "Hold Alt/Option to drag nodes\nDrag background to pan";
  white-space: pre;
  position: fixed;
  bottom: 20px;
  right: 20px;
  font-size: 12px;
  color: #726a87;
  pointer-events: none;
}

.zoom-button {
  fill: white;
  stroke: var(--primary);
  stroke-width: 2px;
  cursor: pointer;
  opacity: 0.8;
}

.zoom-button:hover {
  opacity: 1;
}

.zoom-icon {
  fill: var(--primary);
  font-size: 20px;
  cursor: pointer;
  pointer-events: none;
}

/* Add styles for the status indicator */
.status-indicator {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: transparent;
  border-radius: 6px;
  font-size: 1.6rem; /* match title size */
  font-family: inherit;
  color: var(--primary);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: 11; /* above background, near title */
}

.status-indicator.active {
  opacity: 1;
}

.status-indicator .selected-text {
  color: var(--primary);
  font-style: italic;
  margin-top: 5px;
}

/* Add styles for text being processed */
.processing {
  color: var(--primary);
  font-style: italic;
}

/* Add styles for the confirmation dialog */
.confirmation-dialog {
  position: fixed;
  padding: 15px 20px;
  background: white;
  border-radius: 8px;
  box-shadow: none; /* remove shadow */
  border: 2px solid var(--muted-line); /* light pink-purple border */
  font-size: 14px;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.confirmation-dialog.active {
  opacity: 1;
  pointer-events: all;
}

.confirmation-dialog .text-preview {
  color: var(--primary);
  font-style: italic;
  margin: 10px 0;
}

.confirmation-buttons {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

.confirmation-buttons button {
  padding: 5px 10px;
  font-size: 12px;
}

.confirmation-buttons .confirm {
  background: var(--primary-dark); /* dark purple */
}

.confirmation-buttons .cancel {
  background: var(--muted-line); /* light purple */
  color: var(--primary-dark);
}

/* Add to your existing styles */
.toggle-button {
  transition: opacity 0.2s;
}

.toggle-button:hover {
  opacity: 0.8;
}

/* Add to your existing styles */
.button-group {
  pointer-events: all;
}

.button-group g:hover {
  opacity: 0.8;
}

.home-button {
  transition: opacity 0.2s;
}

/* Add to your existing styles */
.text-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(244, 244, 249, 0.95);
  z-index: 1000;
  padding: 2rem;
  overflow: auto;
  cursor: pointer; /* Show pointer on overlay background */
}

.overlay-content {
  max-width: 560px;
  margin: 0 auto;
  background: white;
  padding: 1.25rem 1.25rem 1rem;
  border-radius: 10px;
  box-shadow: 0 2px 15px rgba(0,0,0,0.1);
  cursor: default; /* Reset cursor on content */
}

.overlay-content pre {
  white-space: pre-wrap;
  font-family: inherit;
  margin: 0;
  color: #333;
}

.overlay-content button {
  padding: 0.5rem 0.8rem;
  font-size: 0.9rem;
}

.overlay-status {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
  color: #6b4fbb;
  font-style: italic;
  font-size: 0.9em;
}

.print-button {
  transition: opacity 0.2s;
}

.print-button:hover {
  opacity: 0.8;
}

.untangle-button {
  transition: opacity 0.2s;
}

.untangle-button:hover {
  opacity: 0.8;
}

.status-indicator .error {
  color: #d32f2f;
}

.error-details {
  font-size: 0.9em;
  color: #666;
  font-style: italic;
}

.import-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 2rem;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  text-align: center;
  z-index: 1000;
  max-width: 90%;
  width: 400px;
}

.import-options {
  display: flex;
  justify-content: space-between;
  margin-top: 1.5rem;
}

.import-options button {
  flex: 1;
  margin: 0 10px;
  padding: 12px;
  cursor: pointer;
}

#importPoemBtn {
  background: var(--primary);
}

#importPoemBtn:hover {
  background: var(--primary-dark);
}

#importText {
  width: 100%;
  min-height: 150px;
  padding: 1rem;
  border: 2px solid #ccc;
  border-radius: 10px;
  font-family: inherit;
  margin: 1rem 0;
  resize: vertical;
  box-sizing: border-box;
}

.import-dialog h3 {
  margin-top: 0;
  color: var(--primary);
}

/* Control panel styles */
.control-panel {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  padding: 15px 20px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  z-index: 10;
  min-width: 300px;
}

.slider-controls {
  display: flex;
  align-items: center;
  gap: 15px;
}

.slider-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.slider-btn:hover {
  background: var(--primary-dark);
}

.slider-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.slider-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
}

#poemInfo {
  font-size: 14px;
  color: var(--primary);
  font-weight: 500;
}

.poem-slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #e0e0e0;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.poem-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #6b4fbb;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.poem-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #6b4fbb;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  border: none;
}

.poem-slider::-webkit-slider-track {
  background: #e0e0e0;
  border-radius: 3px;
  height: 6px;
}

.poem-slider::-moz-range-track {
  background: #e0e0e0;
  border-radius: 3px;
  height: 6px;
  border: none;
}

/* Size controls */
.size-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.size-label {
  font-size: 12px;
  color: var(--primary);
}

.size-slider {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: #e0e0e0;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.size-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.size-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  border: none;
}

.size-slider::-webkit-slider-track {
  background: #e0e0e0;
  border-radius: 3px;
  height: 6px;
}

.size-slider::-moz-range-track {
  background: #e0e0e0;
  border-radius: 3px;
  height: 6px;
  border: none;
}

.size-display {
  font-size: 12px;
  color: #333;
  width: 40px;
  text-align: right;
}

/* Button group styles */
.button-group {
  display: flex;
  gap: 8px;
  margin-top: 0.75rem;
  justify-content: flex-end;
  margin-right: 0;
  width: 100%;
  flex-wrap: wrap;
}

.button-group button {
  margin: 0;
  padding: 0.45rem 0.8rem;
  flex: 0 0 auto;
  font-size: 0.95rem;
}

#startPoem {
  background: var(--accent);
  width: 100%;
}

#startPoem:hover {
  background: #e66a3a;
}

/* History controls */
.history-controls {
  display: flex;
  gap: 10px;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #eee;
}

.history-btn {
  flex: 1;
  padding: 8px 12px;
  font-size: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.history-btn:hover {
  background: var(--primary-dark);
}

.history-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Responsive design */
@media (max-width: 768px) {
  .title-controls {
    position: fixed;
    top: 10px;
    right: 10px;
    left: auto;
    transform: none;
    width: auto;
    justify-content: flex-end;
  }
  
  .title-controls button {
    width: 40px;
    height: 40px;
    flex: none;
  }
  
  h1 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
  }
  
  .editor-container {
    width: 100%;
    margin-top: 1rem;
  }
}

@media (max-width: 480px) {
  .title-controls {
    position: fixed;
    top: 30px;
    right: 8px;
    left: auto;
    width: auto;
    transform: none;
    justify-content: flex-end;
    gap: 0.25rem;
  }
  
  .title-controls button {
    width: 35px;
    height: 35px;
    font-size: 1rem;
  }
  
  .button-group {
    justify-content: center;
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  .button-group button {
    flex: 1 1 40%;
  }
}

/* New row for the two small buttons */
.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 10px 0 12px;
}

 