:root {
	--space-xs: 4px;
	--space-sm: 8px;
	--space-md: 12px;
	--space-lg: 18px;
	--primary: rgb(32, 32, 142);
}

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

body {
	font-family: "Inter", sans-serif;
	background-color: #eef6ff;
	color: #333;
	padding: var(--space-md);
}

.container {
	max-width: 1200px;
	margin: 0 auto;
}

/* Header */
.header {
	text-align:center;
	margin-bottom: var(--space-md);
}

.header h2 {
	font-size: 1.5rem;
	font-weight: 700;
	color: #555;
	margin-bottom: var(--space-xs);
}

.header a{
    text-decoration: none;
    color: var(--primary);
    font-style: oblique;
}

.header p {
	font-size: 0.85rem;
	color: #555;
}

/* Layout */
.main-content {
	display: grid;
	grid-template-columns: 1fr 1fr 1fr 1fr;
	grid-auto-rows: minmax(150px, auto);
	gap: var(--space-md);
}

/* Cards */
.card {
	background: white;
	border-radius: 14px;
	padding: var(--space-md);
	box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}

.card h3 {
	font-size: 0.95rem;
	font-weight: 600;
	color: var(--primary);
	margin-bottom: var(--space-sm);
	border-bottom: 1px solid #eee;
	padding-bottom: var(--space-xs);
}

/* Buttons */
.button-group {
    grid-column: 1 / 2;
  grid-row: 1;
	display: flex;
	/* flex-wrap: wrap; */
    padding: 2px;
	gap: var(--space-xs);
	margin-bottom: var(--space-lg);
    background: #f8f9fa;
}

button {
	padding: 6px 6px;
	font-size: 0.7rem;
	font-weight: 500;
    background: #f8f9fa;
    /* border: 0.2px; */
	/* border-color: 0.1px black; */
	border-radius: 6px;
	cursor: pointer;
	font-family: "Inter", sans-serif;
}

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

.btn-secondary {
	background: #f0f0f0;
	color: #333;
}

/* Sa calibration */
.sa-frequency-container {
    grid-column: 2 / 3;
  grid-row: 1;
	background: #f8f9fa;
    border-color:rgb(32, 32, 142);
    /* margin-top: var(--space-xs); */
	padding: var(--space-xs);
	border-radius: 8px;
}

#sa_frequency {
	width: 60px;
	padding: 2px;
	font-size: 0.7rem;
}

#calibrate_sa_button {
	width: 30px;
	background-color: var(--primary);
	background-blend-mode: darken;
	padding: 1px;
	font-size: 0.7rem;
}

#sa_note {
	width: 40px;
	padding: 1px;
	font-size: 0.7rem;
}

.sa-frequency-container label {
	font-size: 0.75rem;
	font-weight: 600;
	margin-right: var(--space-xs);
    margin-bottom: var(--space-md);
}

.card label {
	font-size: 0.75rem;
	font-weight: 600;
	margin-right: var(--space-xs);
}

.sa-frequency-container input {
	width: 90px;
	padding: 5px 6px;
	font-size: 0.7rem;
	border-radius: 5px;
	border: 2px solid #e0e0e0;
}
/* 
.sa-frequency-container select#sa_note {
	padding: 5px 6px;
	font-size: 0.7rem;
	border-radius: 5px;
	border: 2px solid #e0e0e0;
	background: white;
	cursor: pointer;
	min-width: 52px;
} */

#calibration_status {
	margin-top: var(--space-sm);
	font-size: 0.7rem;
	font-weight: 500;
}

/* Pitch Detector */
#detector {
	text-align: center;
	padding: var(--space-md);
	border-radius: 10px;
	min-height: 150px;
	max-height: 150px;
}

#detector.confident {
	background: linear-gradient(135deg, #d6e9ff 0%, #b3d9ff 100%);
}

#detector.vague {
	background: #f5f5f5;
	padding: 0px;
}

.pitch {
	font-size: 0.95rem;
	font-weight: 600;
	margin-bottom: var(--space-xs);
	color: var(--primary);
}

#indian_note {
	font-size: 2rem;
	font-weight: 700;
	color: var(--primary);
	margin-bottom: var(--space-xs);
}

#note {
	font-size: 1.8rem;
	font-weight: 700;
	margin-bottom: var(--space-xs);
}

#detune {
	font-size: 0.85rem;
	font-weight: 500;
}

#detune_amt {
	color: #d63031;
}

#flat, #sharp {
	display: none;
}

.flat #flat,
.sharp #sharp {
	display: inline;
}

/* Graph */
.frequency_graph_card {
    grid-column: 3 / 5; /* Starts at line 3, ends at line 5 */
  grid-row: 1 / 3;    /* Starts at row line 1, ends at row line 3 */
}

.raga_card {
	grid-column: 1 / 3; /* Starts at line 1, ends at line 3 */
  grid-row: 2;
	padding: var(--space-md);
}

#frequency_graph {
	width: 100%;
	height: 350px;
	background: #fafafa;
	border-radius: 6px;
	border: 1px solid #e0e0e0;
}

/* Piano keyboard */
.piano-card {
	grid-column: 1 / -1;
	padding: var(--space-md);
}

.piano {
	position: relative;
	height: 150px;
	/* border-radius: 10px; */
	/* background: #fafafa; */
	/* border: 1px solid #e9e9e9; */
	overflow: hidden;
}

.piano-white {
	display: flex;
	height: 100%;
	gap: 2px;
	/* padding: 10px 10px 12px 10px; */
}

.piano-key {
	user-select: none;
	-webkit-user-select: none;
}

.piano-key.white {
	flex: 1;
	background: #fff;
	border: 1.5px solid #e3e3e3;
	border-radius: 0 0 10px 10px;
	position: relative;
	/* box-shadow: inset 0 -10px 18px rgba(0,0,0,0.04); */
}

.piano-key.white.active {
	border-color: rgba(32, 32, 142, 0.55);
	background: linear-gradient(180deg, #ffffff 0%, #d6e9ff 100%);
}

.piano-black {
	position: absolute;
	top: 0px;
	left: 10px;
	right: 10px;
	height: 65%;
	pointer-events: none;
	z-index: 2;
}

.piano-key.black {
	position: absolute;
	top: 0;
	height: 100%;
	background: rgba(0, 0, 0, 0.963);
	border-radius: 0 0 7px 7px;
	/* box-shadow: 0 10px 16px rgba(0,0,0,0.22); */
	border: 1px solid rgba(255,255,255,0.05);
	pointer-events: auto;
}

.piano-key.black.active {
    border-color: rgba(32, 32, 142, 0.55);
	background: linear-gradient(180deg, #ffffff 0%,  #d6e9ff 100%);
}

.piano-key.white.in-scale {
	border-width: 1px;
}

.piano-key.white.in-scale::after {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 24px;
	background: var(--scale-color, transparent);
	/* border-radius: 8px 8px 0 0; */
    border-radius: 0 0 0 0;
	opacity: 1;
	pointer-events: none;
}

.piano-key.black.in-scale {
	border-width: 1px;
	border-color: var(--scale-color, rgba(255,255,255,0.18));
	box-shadow: 0 0 0 2px var(--scale-color, transparent);
}

.piano-key.black.in-scale::after {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 24px;
	background: var(--scale-color, transparent);
	border-radius: 0 0 0 0;
	opacity: 1;
	pointer-events: none;
}

.piano-key-label,
.piano-key-western {
	position: absolute;
	bottom: 8px;
	left: 50%;
	transform: translateX(-50%);
	font-size: 0.65rem;
	font-weight: 600;
	color: rgb(0, 0, 0);
	letter-spacing: 0.2px;
	white-space: nowrap;
}

.piano-key-swara {
	position: absolute;
	top: 5px;
	/* bottom: 24px; */
	left: 50%;
	transform: translateX(-50%);
	font-size: 0.6rem;
	font-weight: 600;
	/* color: rgba(0,0,0,0.75); */
    color: white;
	letter-spacing: 0.2px;
	white-space: nowrap;
    z-index: 99;
}


.piano-key.black .piano-key-western {
	color: rgba(255,255,255,0.85);
}

.piano-key.black .piano-key-swara {
    color: black;
}

.piano-key.white.active .piano-key-label {
	color: rgba(32, 32, 142, 0.9);
}

.piano-key.white.active .piano-key-swara,
.piano-key.white.active .piano-key-western {
	color: rgba(32, 32, 142, 0.9);
}

.piano-cursor {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 2px;
	left: 0;
	transform: translateX(-1px);
	background: rgba(32, 32, 142, 0.8);
	box-shadow: 0 0 0 1px rgba(255,255,255,0.65);
	opacity: 0;
	transition: opacity 120ms ease;
	z-index: 3;
	pointer-events: none;
}

.piano.has-cursor .piano-cursor {
	opacity: 1;
}

.graph-label {
	text-align: center;
	font-size: 0.65rem;
	color: #666;
	margin-top: var(--space-xs);
}

/* Responsive */
@media (max-width: 768px) {
	.main-content {
		grid-template-columns: 1fr;
	}
}
