:root {
  --accent: #5aa0ff;
  --accent-2: #ff6b6b;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-soft: 0 4px 16px rgba(0,0,0,0.15);
  --help-border: #cfd8ff;
  --help-key-bg: #0f3460;
  --help-key-fg: #e8f0ff;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  line-height: 1.42;
  padding: 24px;
}

.brand-left { display:inline-flex; align-items:center; gap:10px; }
h1 { color: #9fe87f; text-shadow: 0 0 12px rgba(124,216,90,0.2); margin: 0; text-transform: lowercase; }

header { display: flex; align-items: center; justify-content: space-between; margin: 8px auto 16px; max-width: 1200px; }
.theme-toggle label { display: inline-flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm); cursor: pointer; user-select: none; text-transform: lowercase; }

main { max-width: 1200px; margin: 0 auto; display: grid; gap: 16px; }

#controls, #timelineSection, #playbackControls { border-radius: var(--radius); padding: 16px; backdrop-filter: blur(6px); box-shadow: var(--shadow-soft); }

#controls .row { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }

fieldset.inline { border: none; padding: 0; display: inline-flex; gap: 16px; align-items: center; text-transform: lowercase; }
label.inline { display: inline-flex; align-items: center; gap: 8px; text-transform: lowercase; }
label.file input[type="file"] { padding: 6px 8px; }

input[type="number"], input[type="file"], input[type="checkbox"], input[type="radio"], input[type="text"] { font: inherit; }
input[type="number"], input[type="text"] { min-width: 90px; padding: 8px 10px; border-radius: 8px; border: 1px solid; outline: none; text-transform: lowercase; }

.mp3-block { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 8px; }

.section-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-header .inline-controls { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.section-header .inline-controls .small input[type="text"] { min-width: 110px; }

.inline-row { display: inline-flex; gap: 8px; flex-wrap: wrap; }

.hint { font-size: 0.9rem; opacity: 0.9; margin-top: 6px; text-transform: lowercase; }

.group { border-radius: var(--radius); padding: 12px; border: 1px dashed; }
.group-title { font-weight: 600; margin-bottom: 8px; opacity: 0.9; text-transform: lowercase; }
.group-grid { display: grid; grid-template-columns: repeat(2, minmax(160px, 1fr)); gap: 12px; }
.apply-flex { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Playback: buttons left, loop right */
.playbar-wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.player-bar.left-controls { display: flex; align-items: center; gap: 10px; }
.loop-label.right-loop { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; text-transform: lowercase; opacity: 0.95; }

.timeline-wrap { position: relative; }
#timelineCanvas { position: relative; width: 100%; height: auto; border-radius: 12px; display: block; border: 1px solid; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03); margin-top: 8px; }
.v-needle { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px dashed #ffcf6b; left: 40px; pointer-events: auto; z-index: 3; cursor: ew-resize; }
/* draggable axis scrubber handle at bottom */
.axis-scrubber {
  position: absolute;
  height: 10px;
  width: 18px;
  bottom: 0;
  left: 40px;
  transform: translateX(-9px);
  background: rgba(255,207,107,0.85);
  border: 1px solid #ffcd6b;
  border-radius: 3px 3px 0 0;
  z-index: 4;
  cursor: ew-resize;
}

.player-bar { margin: 8px 0; }
.playpause, .playrestart {
  appearance: none; border: 1px solid transparent;
  background: linear-gradient(180deg, #6aa6ff, #3d86ff);
  color: white; padding: 10px 14px; border-radius: 12px;
  font-weight: 700; letter-spacing: 0.2px;
  box-shadow: 0 6px 16px rgba(62,132,255,0.35);
  min-width: 140px; text-transform: lowercase;
  display: grid; place-items: center; gap: 6px;
}
.playpause .subtext, .playrestart .subtext { font-size: 11px; opacity: 0.9; }
.playrestart.icon .icon-shape { width: 0; height: 0; border-style: solid; border-width: 0 10px 16px 10px; border-color: transparent transparent #ffffff transparent; }
.playpause.icon .icon-shape { width: 0; height: 0; border-style: solid; border-width: 10px 0 10px 16px; border-color: transparent transparent transparent #ffffff; }
.playpause.paused .icon-shape { width: 16px; height: 16px; border: none; background: linear-gradient(90deg, #fff 40%, transparent 40% 60%, #fff 60%); }

button { appearance: none; border: 1px solid transparent; background: linear-gradient(180deg, #6aa6ff, #3d86ff); color: white; padding: 10px 14px; border-radius: 8px; font-weight: 600; letter-spacing: 0.2px; box-shadow: 0 6px 16px rgba(62,132,255,0.35); text-transform: lowercase; }
button.ghost { background: transparent; color: inherit; border-color: currentColor; text-transform: lowercase; }
button:disabled { opacity: 0.55; filter: grayscale(0.2); box-shadow: none; }
button.wide { min-width: 160px; }
#exportBtn { background: linear-gradient(180deg, #43d17c, #1fb86c); box-shadow: 0 6px 16px rgba(46, 204, 113, 0.35); }

.export-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

#status { min-height: 1.2em; padding: 6px 0; font-weight: 600; opacity: 0.95; text-transform: lowercase; }
progress { width: 100%; height: 12px; border-radius: 10px; overflow: hidden; border: 1px solid; }
progress::-webkit-progress-bar { background: transparent; }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--accent), #7bd0ff); }

.pattern-input { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid; margin-top: 8px; text-transform: none; }

/* footer disclaimer link gold theme */
.freq-footer a { color: #f6e7a9; text-decoration: underline; text-underline-offset: 2px; }
.freq-footer a:hover { color: #ffe89c; }
.freq-footer a:visited { color: #f7b8b8; }
.freq-footer a:active { color: #ffc4c4; }

.help-grid { margin-top: 10px; border: 1px solid var(--help-border); border-radius: 10px; padding: 10px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.help-grid .col { display: grid; gap: 8px; }
.help-item { display: flex; align-items: center; gap: 10px; }
.help-item .key { min-width: 28px; text-align: center; padding: 4px 6px; border-radius: 6px; background: var(--help-key-bg); color: var(--help-key-fg); font-weight: 700; letter-spacing: 0.5px; }
.help-item .desc { opacity: 0.95; text-transform: lowercase; }

.home-btn { width: 34px; height: 28px; border: 2px solid #bfc6d8; border-right-color:#7e8aa6; border-bottom-color:#7e8aa6; background: linear-gradient(180deg, #e8eefc, #cfd8f0); border-radius: 3px; box-shadow: inset -2px -2px 0 #aab6d2, inset 2px 2px 0 #f6f9ff; cursor: pointer; position: relative; margin-right: 10px; }
.home-btn::before { content:""; position:absolute; left:9px; top:6px; width:8px; height:8px; border-left:3px solid #355; border-bottom:3px solid #355; transform: rotate(45deg); }
.home-btn::after { content:""; position:absolute; left:16px; top:8px; width:8px; height:10px; background:#355; }

.pepe-snow-canvas { position: fixed; inset:0; pointer-events:none; z-index:0; opacity: 0.85; }
.bg-viz { position: fixed; inset:0; pointer-events: none; z-index: 1; opacity: 0.55; }
header, main, #nodePopup { position: relative; z-index: 2; }

body.playing #controls, body.playing #timelineSection, body.playing #playbackControls { backdrop-filter: blur(10px); background: rgba(24,30,48,0.55); border-color: rgba(122,146,210,0.55); transition: background .2s ease, border-color .2s ease, opacity .2s ease; }

.loading { display: inline-block; padding: 6px 10px; border-radius: 10px; border: 1px solid currentColor; font-size: 12px; opacity: 0.9; }
.hidden { display: none !important; }

@media (max-width: 760px) {
  body { padding: 12px; }
  header { margin: 4px auto 10px; }
  main { gap: 12px; }
  #controls .row { flex-direction: column; align-items: stretch; gap: 12px; }
  fieldset.inline { flex-wrap: wrap; gap: 10px; }
  .mp3-block { grid-template-columns: 1fr 1fr; }
  #timelineSection .section-header { align-items: flex-start; flex-direction: column; gap: 8px; }
  #timelineSection .inline-controls { width: 100%; flex-wrap: wrap; gap: 8px; }
  #timelineSection .inline-controls > * { flex: 1 1 auto; min-width: 140px; }
  #btnNewNode { order: 3; width: 100%; }
  .player-bar { position: sticky; top: 0; z-index: 4; border-radius: 10px; padding: 8px; gap: 8px; }
}

