:root {
    --fg: #166534;
    --bg: #fefce8;
    --button_fg: #fefce8;
    --button_bg: #166534;
    --button_bg_clicked: #0d4322;
    --border: #c4c4c4;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background-color: var(--bg);
    color: var(--fg);
    font-family: Arial, Helvetica, sans-serif;
}

header {
    padding: 1rem;
    border-bottom: 2px solid var(--border);
    display: flex;
    justify-content: space-between;
}

h1 {
    font-family: 'Oswald', sans-serif;
    font-size: 2rem;
    margin: 0;
    margin-right: 2%;
    display: inline-block;
}

.tagline {
    margin: 0.5rem 0 0 0;
    margin-top: auto;
    font-style: italic;
    color: #666;
    display: inline-block;
    justify-self: left;
    align-self: left;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 120px);
    gap: 1rem;
    padding: 1rem;
}

/* Drawing Section */
.drawing-section {
    flex: 1;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    align-items: center;
}

.layout-select {
    padding: 0.5rem;
    border: 2px solid var(--border);
    border-radius: 4px;
    background: white;
}

.color-palette {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.color-btn {
    padding: 0.5rem 0.75rem;
    border: 2px solid transparent;
    cursor: pointer;
    background: white;
    border-radius: 4px;
}

.color-btn::before {
    content: '●';
    font-size: 16px;
    margin-right: 0.5rem;
}

.color-btn.red::before {
    color: #ff0000;
}

.color-btn.green::before {
    color: #00ff00;
}

.color-btn.blue::before {
    color: #0000ff;
}

.color-btn.yellow::before {
    color: #DAA520;
}

.color-btn.purple::before {
    color: #ff00ff;
}

.color-btn.active {
    border-color: var(--fg);
    background: #f0f0f0;
}

/* POLISHED: Better shape buttons for demo */
.shape-btn {
    padding: 12px 16px;
    font-size: 20px;
    min-width: 50px;
    min-height: 50px;
    border: 3px solid transparent;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shape-btn:hover {
    border-color: var(--fg);
    background: #f5f5f5;
    transform: scale(1.05);
}

.shape-btn.active {
    border-color: var(--fg);
    background: var(--bg);
    box-shadow: 0 2px 8px rgba(22, 101, 52, 0.2);
}

/* Update the shape-toolbar styles in your CSS: */

.shape-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    padding: 12px;
    background: white;
    border: 2px solid var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
    order: 1;
}

/* Desktop: less intrusive styling */
@media (min-width: 768px) {
    .shape-toolbar {
        background: transparent;
        border: 1px solid var(--border);
        padding: 8px;
        border-radius: 4px;
    }
}

/* Mobile: keep the bold styling for better touch targets */
@media (max-width: 767px) {
    .shape-toolbar {
        background: white;
        border: 2px solid var(--border);
        padding: 12px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
}
/* POLISHED: Consistent action buttons */
.action-btn {
    padding: 8px 12px;
    background-color: var(--button_bg);
    color: var(--button_fg);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    min-height: 40px;
    transition: background-color 0.2s;
}

.action-btn:hover {
    background-color: var(--button_bg_clicked);
}

/* Output Section */
.output-section {
    flex: 1;
}

.ascii-display {
    font-family: 'Courier New', monospace;
    font-size: 10px;
    background-color: #f8f8f8;
    border: 2px solid var(--border);
    padding: 1rem;
    white-space: pre;
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.input-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.input-group label {
    font-weight: bold;
    font-size: 0.9rem;
}

.input-group input {
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
}

.text-areas {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.text-areas>div {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.text-areas label {
    font-weight: bold;
    font-size: 0.9rem;
}

.text-areas input {
    padding: 0.5rem;
    border: 2px solid var(--border);
    border-radius: 4px;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.primary-btn {
    padding: 1rem 2rem;
    background-color: var(--button_bg);
    color: var(--button_fg);
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

.primary-btn:hover {
    background-color: var(--button_bg_clicked);
}

/* POLISHED: Better canvas container */
.canvas-container {
    border: 2px solid #c4c4c4;
    border-radius: 8px;
    background: white;
    position: relative;
    display: inline-block;
    margin: 8px 0;
    order: 2;
    flex: 1;
}

#diagramCanvas {
    display: inline-block;
    cursor: crosshair;
    /* Ensure canvas isn't scaled by CSS - JS controls exact size */
    max-width: none;
    width: auto;
    height: auto;
    /* Prevent any margin or padding that could affect positioning */
    margin: 0;
    padding: 0;
    vertical-align: top;
}

/* POLISHED: Text styling for shapes */
.shape-text {
    font-family: Arial, sans-serif;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    color: #333;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.2;
    max-width: 100%;
    padding: 2px;
}

/* For text overlays - positioned absolutely over canvas */
.text-overlay {
    position: absolute;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #666;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    pointer-events: none;
    z-index: 10;
}

.diagram-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.diagram-actions {
    order: 3;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Desktop Layout - Single Column for Full Width Canvas */
@media (min-width: 768px) {
    .app-container {
        flex-direction: column;
        gap: 1.5rem;
        padding: 2rem;
        max-width: 1500px;
        margin: 0 auto;
    }

    .diagram-container {
        width: 100%;
    }

    .canvas-container {
        width: 100%;
        text-align: center;
    }

    .controls {
        justify-content: flex-start;
    }

    canvas {
        max-width: none;
    }
}

/* Large Desktop */
@media (min-width: 1200px) {
    .app-container {
        max-width: 1600px;
        margin: 0 auto;
        padding: 2rem;
    }
}

/* POLISHED: Mobile-friendly shape buttons */
@media (max-width: 768px) {
    .shape-btn {
        padding: 10px 12px;
        font-size: 18px;
        min-width: 45px;
        min-height: 45px;
    }
    
    .shape-toolbar {
        padding: 8px;
        gap: 6px;
    }
}

.github-btn {
    padding: 10px 12px;
    margin-bottom: 5px;
    background: #166534;
    margin-inline-end: 0px;
    color: #fefce8;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
    transition: background 0.2s;
}

.github-btn:hover {
    background: #124a26;
}

.input-group input,
.input-group textarea {
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
}

.input-group textarea {
    resize: vertical;
}