:root {
  --bg: #0f0f12;
  --bg-elev: #1a1a20;
  --bg-elev-2: #25252d;
  --text: #f4f4f7;
  --muted: #9a9aa6;
  --accent: #ff5e57;
  --accent-soft: #ff5e5722;
  --ok: #4ade80;
  --warn: #facc15;
  --err: #f87171;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); min-height: 100dvh; }
body { padding-top: var(--safe-top); padding-bottom: var(--safe-bot); -webkit-font-smoothing: antialiased; }

header {
  padding: 18px 20px 8px;
}
header h1 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.tabs {
  display: flex;
  gap: 6px;
  padding: 12px 16px 0;
}
.tab {
  flex: 1;
  background: var(--bg-elev);
  color: var(--muted);
  border: none;
  border-radius: 12px;
  padding: 12px 0;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.tab.active { background: var(--accent); color: white; }

main { padding: 16px; }
.panel { display: none; }
.panel.active { display: block; }

.field { display: block; }
.field span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
  padding-left: 4px;
}
.field input {
  width: 100%;
  appearance: none;
  background: var(--bg-elev);
  border: 1px solid transparent;
  color: var(--text);
  padding: 14px 16px;
  font-size: 17px;
  border-radius: var(--radius);
  font-family: inherit;
  transition: border-color 0.15s;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
}

.status {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
  padding: 0 4px;
}
.status.error { color: var(--err); }
.status.ok    { color: var(--ok); }

.results {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-elev);
  border-radius: var(--radius);
  padding: 10px;
  cursor: pointer;
  transition: background 0.1s;
}
.result-item:active { background: var(--bg-elev-2); }
.result-item img {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg-elev-2);
  flex-shrink: 0;
}
.result-item .meta { min-width: 0; flex: 1; }
.result-item .album {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-item .artist {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo-picker {
  display: block;
  position: relative;
  background: var(--bg-elev);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  border: 2px dashed var(--bg-elev-2);
}
.photo-picker input[type="file"] {
  position: absolute; inset: 0; opacity: 0;
}
.photo-cta { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.photo-icon { font-size: 36px; }
.photo-label { color: var(--text); font-weight: 600; }

.photo-preview {
  margin-top: 16px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elev);
}
.photo-preview img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
}

.photo-result {
  margin-top: 16px;
  background: var(--bg-elev);
  padding: 14px 16px;
  border-radius: var(--radius);
}
.photo-result .badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  margin-bottom: 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.photo-result .badge.ok   { background: #14532d; color: #86efac; }
.photo-result .badge.warn { background: #713f12; color: #fde68a; }
.photo-result .album      { font-size: 16px; font-weight: 600; }
.photo-result .artist     { color: var(--muted); margin-top: 2px; }
.photo-result .actions    { margin-top: 12px; display: flex; gap: 8px; }
.photo-result button      { flex: 1; }

.sheet {
  position: fixed;
  inset: auto 0 0 0;
  background: var(--bg-elev);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  padding: 8px 16px calc(20px + var(--safe-bot));
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
  transform: translateY(100%);
  transition: transform 0.25s ease-out;
  z-index: 10;
}
.sheet[data-open="true"] { transform: translateY(0); }
.sheet-handle {
  width: 40px; height: 4px;
  background: var(--bg-elev-2);
  border-radius: 999px;
  margin: 6px auto 14px;
}
.sheet-album {
  display: flex; gap: 12px; align-items: center; margin-bottom: 16px;
}
.sheet-album img {
  width: 64px; height: 64px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg-elev-2);
}
.sheet-title { font-weight: 700; font-size: 17px; }
.sheet-artist { color: var(--muted); font-size: 14px; margin-top: 2px; }

.sheet-tag-block label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.sheet-tag-block code {
  display: block;
  margin-top: 6px;
  padding: 12px;
  background: var(--bg-elev-2);
  border-radius: 10px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 13px;
  word-break: break-all;
}
.sheet-actions {
  display: flex; gap: 8px; margin-top: 18px;
}
.sheet-actions button { flex: 1; }

.btn-primary, .btn-secondary, .btn-ghost {
  border: none;
  padding: 14px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: var(--bg-elev-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--muted); width: 100%; margin-top: 8px; padding: 12px; }

.sync-bar {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(28px + env(safe-area-inset-bottom));
  height: 2px;
  background: var(--bg-elev);
  z-index: 5;
}
.sync-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.4s ease-out;
}
.sync-bar.indeterminate .sync-bar-fill {
  width: 30%;
  animation: sync-slide 1.4s ease-in-out infinite;
}
@keyframes sync-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

footer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex; gap: 6px; align-items: center; justify-content: center;
  padding: 8px calc(8px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 11px;
  background: linear-gradient(180deg, transparent, var(--bg) 60%);
  pointer-events: none;
}
.health { font-size: 14px; line-height: 1; }
.health.ok       { color: var(--ok); }
.health.warn     { color: var(--warn); }
.health.err      { color: var(--err); }
.health.unknown  { color: var(--muted); }
