:root {
    --bg-dark: #293241;
    --panel-bg: #3D4857;
    --text-light: #F0F0F0;
    --text-muted: #98A3B2;
    --accent-color: #E76F51;
    --accent-hover: #F4A261;
    --node-color: #1ABC9C;
    --link-color: #98A3B2;
    --highlight-outgoing: var(--accent-color); /* Orange for outgoing */
    --highlight-incoming: var(--accent-color); /* Orange for incoming */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    line-height: 1.6;
    margin: 0;
    padding: 20px;
    background-color: var(--bg-dark);
    color: var(--text-light);
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

header .heading-inline {
  display: flex;
  align-items: baseline;
  justify-content: center; /* center both h2 and note together */
  gap: 0.75rem;
  flex-wrap: wrap; /* ensures it wraps nicely on small screens */
}

header .heading-note {
  color: var(--text-muted);
  font-size: 1.1rem;
}

header h1 {
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

.main-container {
    display: flex;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.panel {
    background-color: var(--panel-bg);
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#controls-panel {
    flex: 1;
    min-width: 300px;
    max-width: 450px;
    display: flex;
    flex-direction: column;
}

#graph-panel {
    flex: 2;
    display: flex;
    flex-direction: column;
}

h2 {
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent-color);
    color: var(--text-light);
}

label {
    display: block;
    margin-bottom: 10px;
    color: var(--text-muted);
}

textarea {
    display: block;
    width: 100%;
    margin-bottom: 20px;
    padding: 12px;
    border: 1px solid #5a687a;
    border-radius: 4px;
    font-size: 1rem;
    resize: vertical;
    box-sizing: border-box;
    background-color: #293241;
    color: var(--text-light);
}

textarea::placeholder {
    color: #7a8698;
}

button {
    display: block;
    width: 100%;
    padding: 12px 15px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

button:hover {
    background-color: var(--accent-hover);
}

#graphActions {
    display: flex;
    gap: 15px;
    margin-top: 15px;
}

#graphActions button {
    background-color: #5a687a;
}
#graphActions button:hover {
    background-color: #7a8698;
}


#graphContainer {
    flex-grow: 1;
    position: relative;
    border: 1px solid #5a687a;
    background-color: #fff;
    border-radius: 4px;
    overflow: hidden;
    min-height: 400px;
    aspect-ratio: 16 / 9;
}

#placeholderText {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #aaa;
    font-size: 1.2rem;
}

#sentenceGraphSvg {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
}

#sentenceGraphSvg:active {
     cursor: grabbing;
}

/* START: Added Color Picker Styles */
#color-selector-container {
    margin-bottom: 20px;
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

#nodeColorPicker {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 44px;
    height: 44px;
    background-color: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    border: 1px solid #5a687a;
    border-radius: 4px;
    box-sizing: border-box;
}
#nodeColorPicker::-webkit-color-swatch {
    border-radius: 3px;
    border: none;
}
#nodeColorPicker::-moz-color-swatch {
    border-radius: 3px;
    border: none;
}

#nodeColorHex {
    flex-grow: 1;
    padding: 8px 12px;
    border: 1px solid #5a687a;
    border-radius: 4px;
    font-size: 1rem;
    font-family: monospace;
    background-color: var(--bg-dark);
    color: var(--text-light);
    height: 44px; /* Match height */
    box-sizing: border-box;
}

/* Updated node styles - both fill and stroke use the same color */
.node circle {
    /* Default color, will be overridden by JS to use the same color for fill and stroke */
    fill: var(--node-color);
    stroke: var(--node-color);
    stroke-width: 2px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.node.highlighted circle {
    /* When highlighted, keep the same color but make stroke slightly thicker */
    stroke-width: 3px;
    filter: brightness(1.1);
}

.node.faded circle {
    opacity: 0.3;
}

.node:hover circle {
    filter: brightness(1.05);
}


#text-color-selector-container {
    margin-bottom: 20px;
}

.text-color-toggle-wrapper {
    display: flex;
    gap: 15px;
    margin-top: 8px;
}

.toggle-option {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.toggle-option input[type="radio"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--accent-color);
}

.toggle-option:hover {
    color: var(--text-light);
}

.toggle-option input[type="radio"]:checked + .toggle-label {
    color: var(--text-light);
    font-weight: 500;
}

.toggle-option .bi-eye-slash {
    font-size: 14px;
    margin-right: 4px;
}

/* Scrambled Words Feature */
.hidden {
    display: none !important;
}

#scrambledWordsContainer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #5a687a;
}

#scrambledWordsContainer h3 {
    margin-top: 0;
}

#scrambledWordsOutput {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

#scrambledWordsOutput span {
    background-color: #4a5768;
    padding: 5px 12px;
    border-radius: 15px;
    font-family: monospace;
}

/* SVG Styles */
.node {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.node text {
    font-size: 14px;
    font-weight: bold;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
    fill: #fff;
}

.link {
    stroke: var(--link-color);
    stroke-opacity: 0.7;
    stroke-width: 2.5px;
    fill: none;
    transition: stroke-opacity 0.2s ease, stroke-width 0.2s ease;
    /* Removed stroke color transition to prevent color changes */
}

marker#arrowhead path {
    fill: var(--link-color);
}

/* Highlighting & Fading */
.faded {
    opacity: 0.15;
}

/* Updated highlighting styles - removed color changes for links and arrows */
.node.highlighted-source circle {
    /* Keep the node's original color, just make it brighter and thicker stroke */
    filter: brightness(1.2) !important;
    stroke-width: 3px;
}

.link.highlighted-outgoing {
    /* Keep original link color, just make it more visible */
    stroke-opacity: 1 !important;
    stroke-width: 4px;
    /* Removed stroke color override */
}

/* Removed marker color override for outgoing arrows */
marker.highlighted-outgoing-arrowhead path {
    /* Keep original arrow color */
}

.node.highlighted-target circle {
    /* Keep the node's original color, just make it brighter and thicker stroke */
    filter: brightness(1.2) !important;
    stroke-width: 3px;
}

.link.highlighted-incoming {
    /* Keep original link color, just make it more visible */
    stroke-opacity: 1 !important;
    stroke-width: 4px;
    /* Removed stroke color override */
}

/* Removed marker color override for incoming arrows */
marker.highlighted-incoming-arrowhead path {
    /* Keep original arrow color */
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .main-container {
        flex-direction: column;
    }
    #controls-panel {
        max-width: 100%;
    }
    #graphContainer {
        min-height: 350px;
    }
}