:root {
    --bg-color: #111115;
    --text-color: #ffffff;
    --card-bg: rgba(30, 30, 35, 0.7);
    --accent-color: #6200ea;
    --accent-hover: #7c43bd;
    --danger-color: #cf6679;
    --border-radius: 16px;
    --padding: 20px;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    background-image: radial-gradient(circle at 20% 20%, #2a2a35 0%, #111115 100%);
    min-height: 100vh;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    padding-top: 50px;
}

.app-header {
    text-align: center;
    margin-bottom: 40px;
}

.app-header h1 {
    margin: 0;
    font-weight: 700;
    font-size: 2.5rem;
    background: linear-gradient(90deg, #fff, #aaa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-header p {
    color: #00ff9d;
    font-size: 1.1rem;
    margin-top: 10px;
}

.grid-layout {
    display: grid;
    /* Allows 3 cards to fit perfectly on desktop, wraps on mobile */
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    padding: var(--padding);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.highlight-card {
    border: 1px solid rgba(255, 100, 100, 0.3) !important;
    background: linear-gradient(135deg, rgba(30, 30, 35, 0.9) 0%, rgba(45, 30, 30, 0.9) 100%) !important;
}

.status-card {
    margin-bottom: 20px;
    font-family: 'Courier New', monospace;
    color: #00bfa5;
    font-size: 0.9rem;
    border-left: 4px solid #00bfa5;
}

h2 {
    margin-top: 0;
    font-size: 1.2rem;
    color: #ccc;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

.input-group,
.generator-controls {
    margin-bottom: 20px;
}

.divider {
    text-align: center;
    position: relative;
    margin: 25px 0;
}

.divider::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    z-index: 1;
}

.divider span {
    background: var(--bg-color);
    padding: 0 15px;
    color: #777;
    font-size: 0.85rem;
    position: relative;
    z-index: 2;
    border-radius: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.9rem;
}

input[type="file"] {
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
    width: 100%;
    box-sizing: border-box;
    color: #fff;
}

input[type="file"]::file-selector-button {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 10px;
}

select {
    width: 100%;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
}

.small-text {
    font-size: 0.8rem;
    color: #888;
    margin-top: 5px;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 10px;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.primary {
    background-color: var(--accent-color);
    color: white;
}

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

.secondary {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.secondary:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.danger {
    background-color: var(--danger-color);
    color: #fff;
}

.small-btn {
    padding: 8px;
    font-size: 0.85rem;
    margin-top: 0;
}

.small-select {
    padding: 8px;
    font-size: 0.85rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    cursor: pointer;
    width: auto;
}

.small-select:hover {
    background: rgba(255, 255, 255, 0.2);
}

.accent {
    background: #00bfa5;
    color: #111;
}

.accent:hover {
    background: #00e5c5;
}

/* Chord Editor Additions */
.chord-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chord-suggestions .btn {
    width: auto;
    flex: 1;
    min-width: 80px;
}

/* Tuning Assistant UI */
.tuning-assistant {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.hidden {
    display: none !important;
}

.compare-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.octave-control {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.btn-round {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-round:hover {
    background: rgba(255, 255, 255, 0.3);
}

.piano-keys {
    display: flex;
    gap: 2px;
    height: 60px;
    margin-bottom: 5px;
}

.key {
    flex: 1;
    border-radius: 0 0 4px 4px;
    cursor: pointer;
    position: relative;
    border: 1px solid #000;
}

.white-key {
    background: #ddd;
    height: 100%;
    z-index: 1;
}

.white-key:hover {
    background: #fff;
}

.white-key.active {
    background: var(--accent-color);
}

.black-key {
    background: #333;
    height: 60%;
    margin-left: -6px;
    margin-right: -6px;
    z-index: 2;
    width: 80%;
    flex: 0.6;
}

.black-key:hover {
    background: #555;
}

.black-key.active {
    background: var(--accent-color);
}


/* Visualizer Canvas & Controls */
.visualizer-card {
    display: flex;
    flex-direction: column;
}

.visualizer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.visualizer-header h2 {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.playback-controls-permanent {
    display: flex;
    gap: 10px;
    align-items: center;
}

.playback-controls-permanent .btn-round {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.playback-controls-permanent .btn-round:hover {
    background: rgba(255, 255, 255, 0.2);
}

.playback-controls-permanent .btn-round.large {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
}

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

.octave-adjust {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #ccc;
}

.btn-round.small {
    width: 24px;
    height: 24px;
    font-size: 0.9rem;
}

.canvas-container {
    display: flex;
    width: 100%;
    height: 900px;
    gap: 0;
    position: relative;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    overflow: hidden;
}

#keysCanvas {
    width: 60px;
    height: 100%;
    background: #222;
    border-right: 1px solid #444;
    display: block;
}

.canvas-wrapper {
    flex-grow: 1;
    height: 100%;
    position: relative;
    background: transparent;
}

/* Editor Toolbar */
.editor-toolbar {
    margin-bottom: 15px;
    display: flex;
    justify-content: flex-start;
}

.tool-group {
    display: flex;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    padding: 4px;
    gap: 4px;
}

.tool-group input[type="radio"] {
    display: none;
}

.tool-btn {
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #ccc;
    font-weight: 600;
    transition: all 0.2s;
}

.tool-group input[type="radio"]:checked + .tool-btn {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 2px 8px rgba(98, 0, 234, 0.4);
}

.tool-btn:hover:not(:checked) {
    background: rgba(255, 255, 255, 0.1);
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.play-head {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 2px;
    background-color: var(--accent-color);
    box-shadow: 0 0 8px var(--accent-color);
    z-index: 10;
    pointer-events: none;
    display: none;
}

.overlay-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(4px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 20;
    color: white;
}

.overlay-play-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%) scale(1.1);
}

.overlay-play-btn.hidden {
    opacity: 0;
    pointer-events: none;
}

#file-info {
    margin-top: 10px;
    font-size: 0.85rem;
    color: #aaa;
    text-align: right;
}