* {
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
}

:root {
	--bg: #020617;
	--panel: rgba(15, 23, 42, .72);
	--panel-border: rgba(148, 163, 184, .18);
	--text: #f8fafc;
	--muted: #94a3b8;
	--red: #ef4444;
	--yellow: #f59e0b;
	--green: #22c55e;
	--blue: #2563ff;
}

html {
	margin: 0;
	padding: 0;
	height: 100%;
	background: #020617;
	overscroll-behavior: none;
}

body {
	margin: 0;
	height: 100%;
	height: 100dvh;
	padding:
		env(safe-area-inset-top)
		env(safe-area-inset-right)
		env(safe-area-inset-bottom)
		env(safe-area-inset-left);
	font-family: Arial;
	color: var(--text);
	display: flex;
	justify-content: center;
	overflow: hidden;
	overscroll-behavior: none;
}

/* fundo fluido: ocupa a tela inteira, inclusive atrás do notch e das barras do celular */
.fluid {
	position: fixed;
	inset: 0;
	z-index: -1;
	overflow: hidden;
	pointer-events: none;
	background: linear-gradient(180deg, #020617 0%, #07111f 35%, #020617 75%, #020617 100%);
}

/* as bordas de cima e de baixo terminam na mesma cor das barras do celular (#020617),
   então não aparece divisão entre o site e o sistema */
.fluid::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(180deg,
		#020617 0%,
		rgba(2, 6, 23, 0) 16%,
		rgba(2, 6, 23, 0) 84%,
		#020617 100%);
}

.fluid span,
.fluid i {
	position: absolute;
	width: 110vmax;
	height: 110vmax;
	border-radius: 50%;
	will-change: transform;
}

.fluid .b1 {
	top: -62vmax;
	left: -40vmax;
	background: radial-gradient(circle, rgba(37, 99, 255, .42), transparent 62%);
	animation: drift1 26s ease-in-out infinite alternate;
}

.fluid .b2 {
	top: -40vmax;
	right: -70vmax;
	background: radial-gradient(circle, rgba(99, 70, 229, .34), transparent 62%);
	animation: drift2 32s ease-in-out infinite alternate;
}

.fluid .b3 {
	bottom: -70vmax;
	left: -30vmax;
	background: radial-gradient(circle, rgba(215, 215, 91, .10), transparent 60%);
	animation: drift3 38s ease-in-out infinite alternate;
}

/* brilho que acompanha o estado da afinação */
.fluid i {
	left: 50%;
	top: 50%;
	margin: -55vmax 0 0 -55vmax;
	opacity: 0;
	transition: opacity 600ms ease;
}

.fluid .g-ok { background: radial-gradient(circle, rgba(34, 197, 94, .30), transparent 55%); }
.fluid .g-warn { background: radial-gradient(circle, rgba(245, 158, 11, .20), transparent 55%); }
.fluid .g-bad { background: radial-gradient(circle, rgba(239, 68, 68, .18), transparent 55%); }

body[data-mode="ok"] .fluid .g-ok,
body[data-mode="warn"] .fluid .g-warn,
body[data-mode="bad"] .fluid .g-bad { opacity: 1; }

@keyframes drift1 {
	from { transform: translate(0, 0) scale(1); }
	to { transform: translate(18vmax, 10vmax) scale(1.15); }
}

@keyframes drift2 {
	from { transform: translate(0, 0) scale(1.1); }
	to { transform: translate(-22vmax, 16vmax) scale(.95); }
}

@keyframes drift3 {
	from { transform: translate(0, 0) scale(.95); }
	to { transform: translate(20vmax, -14vmax) scale(1.12); }
}

@media (prefers-reduced-motion: reduce) {
	.fluid span { animation: none; }
}

.app {
	height: 100%;
	width: min(100%, 460px);
	padding: clamp(10px, 2.2dvh, 22px) 20px clamp(8px, 1.6dvh, 16px);
	display: flex;
	flex-direction: column;
	gap: clamp(8px, 1.6dvh, 14px);
}

.top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	color: var(--muted);
	font-size: 13px;
	letter-spacing: .08em;
	text-transform: uppercase;
}

.menu {
	color: #f5f5d6;
	align-items: center;
	gap: 8px;
	font-weight: 800;
	font-size: 18px;
}

.brand {
	align-items: center;
	gap: 8px;
	font-weight: 800;
	font-size: 18px;
}

.brand-dot {
	width: 9px;
	height: 9px;
	border-radius: 999px;
	background: var(--blue);
	box-shadow: 0 0 18px rgba(37, 99, 255, .95);
}

.trademark {
	font-size: 12px;
	line-height: 1;
	text-align: center;
	color: gray;
}

.state-pill {
	padding: 9px 13px;
	border-radius: 999px;
	border: 1px solid var(--panel-border);
	background: rgba(15, 23, 42, .55);
	font-weight: 800;
	color: #cbd5e1;
	transition: all 160ms ease;
}

.state-pill.bad {
	color: #fecaca;
	background: rgba(239, 68, 68, .16);
	border-color: rgba(239, 68, 68, .35);
}

.state-pill.warn {
	color: #fde68a;
	background: rgba(245, 158, 11, .16);
	border-color: rgba(245, 158, 11, .35);
}

.state-pill.ok {
	color: #bbf7d0;
	background: rgba(34, 197, 94, .18);
	border-color: rgba(34, 197, 94, .40);
}

.lock-card {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	border: 1px solid var(--panel-border);
	border-radius: 30px;
	background:
		linear-gradient(180deg, rgba(15, 23, 42, .62), rgba(2, 6, 23, .72)),
		radial-gradient(circle at center, rgba(37, 99, 255, .18), transparent 46%);
	-webkit-backdrop-filter: blur(18px);
	backdrop-filter: blur(18px);
	box-shadow:
		0 22px 60px rgba(0, 0, 0, .42),
		inset 0 1px 0 rgba(255, 255, 255, .05);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: clamp(56px, 9dvh, 76px) 16px clamp(10px, 2dvh, 20px);
}

.mini-bars {
	position: absolute;
	top: clamp(8px, 1.6dvh, 16px);
	left: 32px;
	right: 32px;
	height: clamp(40px, 6.5dvh, 54px);
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 11px;
	opacity: .92;
}

.mini-bars span {
	width: 6px;
	height: 18px;
	border-radius: 999px;
	background: rgba(148, 163, 184, .24);
	transition: all 140ms ease;
}

.mini-bars span:nth-child(1),
.mini-bars span:nth-child(9) { height: 12px; }

.mini-bars span:nth-child(2),
.mini-bars span:nth-child(8) { height: 20px; }

.mini-bars span:nth-child(3),
.mini-bars span:nth-child(7) { height: 30px; }

.mini-bars span:nth-child(4),
.mini-bars span:nth-child(6) { height: 42px; }

.mini-bars span:nth-child(5) { height: 52px; }

.lock-ring {
	position: relative;
	flex-shrink: 0;
	width: min(68vw, 31dvh, 268px);
	height: min(68vw, 31dvh, 268px);
	border-radius: 999px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 180ms ease;
}

.lock-ring::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	border: 8px solid rgba(148, 163, 184, .10);
	box-shadow: inset 0 0 42px rgba(255, 255, 255, .02);
	transition: all 180ms ease;
}

.lock-ring::after {
	content: "";
	position: absolute;
	inset: 12px;
	border-radius: inherit;
	background: radial-gradient(circle, rgba(255, 255, 255, .05), transparent 64%);
	opacity: .7;
}

.lock-ring.ok::before {
	border-color: var(--green);
	box-shadow:
		0 0 28px rgba(34, 197, 94, .42),
		0 0 88px rgba(34, 197, 94, .16),
		inset 0 0 44px rgba(34, 197, 94, .06);
	animation: lockPulse 1s ease-in-out infinite;
}

.lock-ring.warn::before {
	border-color: rgba(245, 158, 11, .72);
	box-shadow: 0 0 38px rgba(245, 158, 11, .18);
}

.lock-ring.bad::before {
	border-color: rgba(239, 68, 68, .58);
	box-shadow: 0 0 38px rgba(239, 68, 68, .16);
}

@keyframes lockPulse {
	0%, 100% { transform: scale(1); opacity: 1; }
	50% { transform: scale(1.035); opacity: .88; }
}

.note-wrap {
	position: relative;
	z-index: 2;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	line-height: 1;
}

.note {
	font-size: min(42vw, 19dvh, 174px);
	font-weight: 900;
	letter-spacing: -10px;
	color: #ffffff;
	text-shadow:
		0 0 24px rgba(255, 255, 255, .16),
		0 0 48px rgba(37, 99, 255, .18);
}

.octave {
	font-size: min(11vw, 6dvh, 54px);
	font-weight: 900;
	margin-left: 8px;
	margin-bottom: 16px;
	color: #e2e8f0;
}

.check {
	position: absolute;
	right: 8px;
	bottom: 8px;
	z-index: 3;
	width: 58px;
	height: 58px;
	border-radius: 999px;
	display: none;
	align-items: center;
	justify-content: center;
	background: var(--green);
	color: #fff;
	font-size: 36px;
	font-weight: 900;
	box-shadow: 0 0 28px rgba(34, 197, 94, .62);
}

.lock-ring.ok .check {
	display: flex;
}

.freq {
	margin-top: clamp(8px, 1.8dvh, 18px);
	font-size: clamp(16px, 2.6dvh, 20px);
	color: var(--muted);
	min-height: 28px;
	text-align: center;
}

.guidance {
	margin-top: clamp(4px, 1.4dvh, 16px);
	min-height: clamp(70px, 11dvh, 86px);
	text-align: center;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: clamp(4px, .8dvh, 8px);
}

.guidance-main {
	font-size: 21px;
	font-weight: 900;
	color: #e5e7eb;
}

.guidance-sub {
	font-size: 16px;
	line-height: 1.35;
	color: var(--muted);
}

.direction {
	font-size: 40px;
	line-height: 1;
	font-weight: 900;
	color: var(--blue);
	min-height: 40px;
	transition: all 140ms ease;
}

.color-scale {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 20px;
	display: grid;
	grid-template-columns: repeat(5, 1fr);
}

.color-scale div:nth-child(1),
.color-scale div:nth-child(5) { background: var(--red); }

.color-scale div:nth-child(2),
.color-scale div:nth-child(4) { background: var(--yellow); }

.color-scale div:nth-child(3) { background: var(--green); }

.controls {
	display: grid;
	gap: 10px;
}

select {
	width: 100%;
	border-radius: 30px;
	font-family: Arial;
	font-size: 14px;
	padding: 10px 11px;
	border: none;
	/*border: 1px solid rgba(148, 163, 184, .28);*/
	/*background: rgba(15, 23, 42, .92);*/
	/*color: #f8fafc;*/
	background: #fafaea;
	color: black;
	outline: none;
}

button {
	width: 100%;
	border-radius: 30px;
	font-size: 18px;
	font-family: Arial;
	border: 0;
	padding: clamp(12px, 2dvh, 16px);
	background: linear-gradient(135deg, #d7d75b, #4f46e5);
	color: #fff;
	font-weight: 900;
	cursor: pointer;
	box-shadow: 0 12px 30px rgba(37, 99, 235, .34);
}

button:disabled {
	opacity: .6;
	cursor: not-allowed;
}

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* botão da afinação atual */
.tuning-btn {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: clamp(9px, 1.5dvh, 12px) 14px clamp(9px, 1.5dvh, 12px) 18px;
	border-radius: 999px;
	font-size: 15px;
	font-weight: 800;
	text-align: left;
	color: var(--text);
	background: rgba(15, 23, 42, .55);
	border: 1px solid rgba(148, 163, 184, .28);
	-webkit-backdrop-filter: blur(14px);
	backdrop-filter: blur(14px);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}

.tuning-btn .t-name {
	flex: 1;
	min-width: 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.t-chev {
	color: var(--muted);
	font-size: 14px;
}

.t-notes,
.ti-notes {
	display: flex;
	flex-wrap: wrap;
	gap: 3px;
}

.t-notes span,
.ti-notes span {
	min-width: 22px;
	padding: 4px 4px;
	border-radius: 7px;
	background: rgba(245, 245, 214, .12);
	color: #f5f5d6;
	font-size: 11px;
	font-weight: 800;
	line-height: 1;
	text-align: center;
}

.tuning-btn:focus-visible,
.tuning-item:focus-visible {
	outline: 2px solid #8b84ff;
	outline-offset: 2px;
}

/* painel de escolha */
.sheet {
	position: fixed;
	inset: 0;
	z-index: 10;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	background: rgba(2, 6, 23, 0);
	transition: background 220ms ease;
}

.sheet[hidden] {
	display: none;
}

.sheet.open {
	background: rgba(2, 6, 23, .6);
}

.sheet-panel {
	width: min(100%, 460px);
	max-height: 85dvh;
	overflow-y: auto;
	padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
	border-radius: 28px 28px 0 0;
	border: 1px solid var(--panel-border);
	border-bottom: 0;
	background: linear-gradient(180deg, rgba(15, 23, 42, .92), rgba(2, 6, 23, .96));
	-webkit-backdrop-filter: blur(20px);
	backdrop-filter: blur(20px);
	box-shadow: 0 -20px 60px rgba(0, 0, 0, .5);
	transform: translateY(100%);
	transition: transform 220ms ease;
	overscroll-behavior: contain;
}

.sheet.open .sheet-panel {
	transform: none;
}

.sheet-handle {
	width: 40px;
	height: 5px;
	margin: 0 auto 12px;
	border-radius: 999px;
	background: rgba(148, 163, 184, .4);
}

.sheet-title {
	margin-bottom: 14px;
	text-align: center;
	font-size: 13px;
	font-weight: 800;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var(--muted);
}

.tuning-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
}

.tuning-item {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	justify-content: space-between;
	gap: 8px;
	padding: 12px;
	border-radius: 18px;
	text-align: left;
	font-size: 14px;
	font-weight: 800;
	line-height: 1.25;
	color: var(--text);
	background: rgba(15, 23, 42, .6);
	border: 1px solid var(--panel-border);
	box-shadow: none;
	transition: transform 120ms ease, border-color 120ms ease;
}

.tuning-item:active {
	transform: scale(.97);
}

.tuning-item .ti-notes {
	width: 100%;
	flex-wrap: nowrap;
}

.tuning-item .ti-notes span {
	flex: 1 1 0;
	min-width: 0;
	max-width: 28px;
	padding: 5px 0;
}

.tuning-item[aria-selected="true"] {
	border-color: transparent;
	background:
		linear-gradient(rgba(15, 23, 42, .94), rgba(15, 23, 42, .94)) padding-box,
		linear-gradient(135deg, #d7d75b, #4f46e5) border-box;
	box-shadow: 0 8px 24px rgba(79, 70, 229, .3);
}

.tuning-item[aria-selected="true"] .ti-name::after {
	content: " ✓";
	color: var(--green);
}

/* no computador o painel abre no centro */
@media (min-width: 600px) and (min-height: 600px) {
	.sheet { align-items: center; }
	.sheet-panel {
		border-radius: 28px;
		border-bottom: 1px solid var(--panel-border);
		padding-bottom: 18px;
		opacity: 0;
		transform: translateY(20px) scale(.98);
		transition: transform 220ms ease, opacity 220ms ease;
	}
	.sheet.open .sheet-panel { opacity: 1; }
	.sheet-handle { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.sheet, .sheet-panel { transition: none; }
}

.notes {
	display: flex;
	justify-content: center;
	gap: 6px;
}

.notes button {
	background: #f5f5d6;
	width: 50px;
	height: clamp(36px, 5.6dvh, 42px);
	padding: 0;
	border: 0;
	border-radius: 16px;
	color: black;
	font-size: 18px;
	cursor: pointer;
}

.notes button:active {
	background: #2563eb;
	transform: scale(0.96);
}

.help {
	display: none;
	padding: 12px;
	border-radius: 14px;
	background: rgba(127, 29, 29, .9);
	color: #fee2e2;
	font-size: 14px;
	line-height: 1.4;
	text-align: left;
	white-space: pre-line;
}

@media (max-width: 420px) {
	.app {
		padding-left: 14px;
		padding-right: 14px;
	}

	.guidance-main {
		font-size: 19px;
	}
}

/* telas baixas (ex.: iPhone SE com a barra do navegador) */
@media (max-height: 600px) {
	.lock-card { padding-top: 46px; }
	.mini-bars { top: 6px; height: 34px; gap: 9px; }
	.lock-ring { width: min(60vw, 27dvh); height: min(60vw, 27dvh); }
	.note { font-size: min(38vw, 16.5dvh); }
	.check { width: 46px; height: 46px; font-size: 28px; }
	.direction { min-height: 30px; font-size: 32px; }
	.guidance { min-height: 60px; }
}

/* celular deitado: libera a rolagem em vez de espremer */
@media (max-height: 460px) {
	body { overflow-y: auto; height: auto; min-height: 100%; }
	.app { height: auto; }
	.lock-card { min-height: 340px; }
	.lock-ring { width: 200px; height: 200px; }
	.note { font-size: 120px; }
}
