/* ==========================================================================
   Paddy Prompt Studio — free online music editor
   Layers on /blog/style.css (same dark indigo/cyan palette and type scale).
   Only the interactive editor lives here; prose styling is inherited.
   ========================================================================== */

:root {
  --good: #34d399;
  --sel: #fcd34d;
  --off: #fb7185;
}

/* ------------------------------------------------------------ Shell */
.editor {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border); border-radius: 22px;
  padding: 1.25rem; margin: 0.5rem 0 1rem;
  box-shadow: 0 30px 70px -40px rgba(99, 102, 241, 0.6);
}

/* ------------------------------------------------------------ Drop zone */
.drop {
  display: grid; justify-items: center; gap: 0.55rem; text-align: center;
  padding: 1.6rem 1rem; border: 2px dashed rgba(129, 140, 248, 0.45);
  border-radius: 16px; background: rgba(99, 102, 241, 0.06);
  transition: border-color 0.15s ease, background 0.15s ease, padding 0.2s ease;
  cursor: pointer;
}
.drop:hover, .drop:focus-visible, .drop.over {
  border-color: #22d3ee; background: rgba(34, 211, 238, 0.08); outline: none;
}
.drop .drop-title {
  font-family: "Space Grotesk", "Inter", sans-serif; font-weight: 800;
  font-size: 1.25rem; color: #fff; margin: 0;
}
.drop .drop-sub { margin: 0; font-size: 0.88rem; color: var(--text-muted); }
.drop .drop-ico { width: 2.6rem; height: 2.6rem; color: #a5b4fc; }
.drop-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; margin-top: 0.3rem; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
/* Once a file is open the drop zone steps aside for the waveform */
.editor[data-state="ready"] .drop { display: none; }
body.dragging .editor[data-state="ready"] .drop { display: grid; }

.btn-primary, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; cursor: pointer;
  min-height: 44px; padding: 0.55rem 1rem; border-radius: 12px;
  font: inherit; font-size: 0.92rem; font-weight: 700; text-decoration: none; line-height: 1.2;
}
.btn-primary { border: 0; background: linear-gradient(135deg, #818cf8, #22d3ee); color: #0b0620; }
.btn-primary:hover { filter: brightness(1.08); text-decoration: none; }
.btn-ghost {
  background: rgba(255, 255, 255, 0.04); color: var(--text); border: 1px solid var(--border);
}
.btn-ghost:hover { background: rgba(129, 140, 248, 0.16); text-decoration: none; }
.btn-primary[disabled], .btn-ghost[disabled] { opacity: 0.4; cursor: not-allowed; filter: none; }
.btn-primary:focus-visible, .btn-ghost:focus-visible { outline: 2px solid #22d3ee; outline-offset: 2px; }

.ed-status { margin: 0.75rem 0 0; font-size: 0.9rem; color: var(--text-muted); min-height: 1.4em; }
.ed-status.ok { color: #a7f3d0; }
.ed-status.err { color: #fca5a5; font-weight: 600; }
.editor[data-state="busy"] .ed-status::after {
  content: ""; display: inline-block; width: 0.8em; height: 0.8em; margin-left: 0.5em; vertical-align: -0.1em;
  border: 2px solid rgba(165, 180, 252, 0.4); border-top-color: #22d3ee; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ Workspace */
.ws-top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem;
  margin-bottom: 0.7rem;
}
.file-name {
  margin: 0; font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.8rem; color: #a5f3fc; word-break: break-all;
}
.ws-stats { display: flex; flex-wrap: wrap; gap: 0.4rem 0.9rem; margin: 0.15rem 0 0; font-size: 0.78rem; color: var(--text-dim); }
.ws-stats b { color: var(--text); font-weight: 700; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.78rem; }

.wave-wrap { position: relative; }
.wave {
  display: block; width: 100%; height: 190px; border-radius: 14px; touch-action: none;
  background:
    linear-gradient(180deg, rgba(99, 102, 241, 0.05), rgba(34, 211, 238, 0.03)),
    #07080d;
  border: 1px solid var(--border-soft); cursor: text;
}
.wave:focus-visible { outline: 2px solid #22d3ee; outline-offset: 2px; }
.ruler { position: relative; height: 1.3rem; margin-top: 0.2rem; }
.ruler span {
  position: absolute; top: 0; transform: translateX(-1px); padding-left: 3px;
  border-left: 1px solid rgba(255, 255, 255, 0.18);
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.62rem; color: var(--text-dim);
}

/* Transport */
.transport { display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem; margin-top: 0.4rem; }
.play-btn { min-width: 9.5rem; }
.play-btn .ico-pause { display: none; }
.editor.is-playing .play-btn .ico-play { display: none; }
.editor.is-playing .play-btn .ico-pause { display: inline; }
.clock {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.95rem; color: #fff;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border); border-radius: 12px;
  padding: 0.5rem 0.75rem; min-height: 44px; display: inline-flex; align-items: center;
}
.clock small { color: var(--text-dim); margin: 0 0.35rem; }
.check {
  display: inline-flex; align-items: center; gap: 0.45rem; min-height: 44px;
  font-size: 0.88rem; color: var(--text-muted); cursor: pointer;
}
.check input { width: 1.15rem; height: 1.15rem; accent-color: #818cf8; }

/* Panels */
.panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; margin-top: 1rem; }
.panel {
  border: 1px solid var(--border); border-radius: 16px; padding: 0.8rem 0.9rem 0.9rem;
  background: rgba(255, 255, 255, 0.025);
}
.panel.wide { grid-column: 1 / -1; }
.panel h3 {
  margin: 0 0 0.6rem; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.66rem;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--indigo); font-weight: 700;
}
.panel .row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.panel .row + .row { margin-top: 0.55rem; }
.panel .hint { margin: 0.55rem 0 0; font-size: 0.8rem; color: var(--text-dim); line-height: 1.5; }
.panel.sel-panel { border-color: rgba(252, 211, 77, 0.28); }
.editor.has-sel .panel.sel-panel { background: rgba(252, 211, 77, 0.05); }

.field { display: grid; gap: 0.2rem; }
.field > span {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.6rem;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-dim); font-weight: 700;
}
.field input, .field select, .inline-select {
  font: inherit; font-size: 0.92rem; font-weight: 600; color: var(--text);
  background: #07080d; border: 1px solid var(--border); border-radius: 10px;
  padding: 0.45rem 0.6rem; min-height: 44px;
}
.field input { width: 7.2rem; font-family: "JetBrains Mono", ui-monospace, monospace; }
.field input:focus, .field select:focus, .inline-select:focus { outline: 2px solid #818cf8; outline-offset: 1px; border-color: transparent; }
.sel-len { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.85rem; color: var(--sel); align-self: end; padding-bottom: 0.6rem; }

.btn-ghost.danger:hover { background: rgba(251, 113, 133, 0.14); border-color: rgba(251, 113, 133, 0.5); }
.btn-ghost.keep { border-color: rgba(252, 211, 77, 0.45); }
.btn-ghost.keep:not([disabled]):hover { background: rgba(252, 211, 77, 0.14); }

.history { margin: 0.3rem 0 0; padding-left: 1.2rem; font-size: 0.85rem; color: var(--text-muted); max-height: 9.5rem; overflow: auto; }
.history li { margin: 0.15rem 0; }
.history li.none { list-style: none; margin-left: -1.2rem; color: var(--text-dim); }

.export-row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.export-row .btn-primary { flex: 0 0 auto; }

.tuner-hint {
  margin: 0.9rem 0 0; text-align: center; font-size: 0.85rem; color: var(--text-dim); line-height: 1.9;
}
.tuner-hint kbd, .article-body kbd {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.78rem;
  background: rgba(129, 140, 248, 0.14); border: 1px solid var(--border-soft);
  border-radius: 5px; padding: 0.05em 0.35em; color: #c7d2fe;
}

/* ------------------------------------------------------------ Prose tables */
.table-wrap { overflow-x: auto; margin: 0 0 1.5rem; border: 1px solid var(--border); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
table.data caption { text-align: left; padding: 0.85rem 1rem 0.2rem; color: var(--text-dim); font-size: 0.82rem; }
table.data th, table.data td { padding: 0.6rem 1rem; text-align: left; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
table.data thead th {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.68rem;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--indigo); font-weight: 700;
  background: rgba(255, 255, 255, 0.03);
}
table.data tbody tr:last-child td, table.data tbody tr:last-child th { border-bottom: 0; }
table.data tbody tr:hover { background: rgba(129, 140, 248, 0.05); }

@media (prefers-reduced-motion: reduce) {
  .editor[data-state="busy"] .ed-status::after { animation: none; }
}

/* ------------------------------------------------------------ Responsive */
@media (max-width: 720px) {
  .editor { padding: 0.9rem; border-radius: 18px; }
  .panels { grid-template-columns: 1fr; }
  .drop-actions { width: 100%; }
  .drop-actions .btn-primary, .drop-actions .btn-ghost { width: 100%; }
  .wave { height: 150px; }
  .panel .row .btn-ghost, .panel .row .btn-primary { flex: 1 1 auto; }
  table.data th, table.data td { padding: 0.55rem 0.7rem; }
}

.edit-log { margin-top: 0.7rem; }
.edit-log summary { cursor: pointer; display: inline-block; }
.edit-log summary:hover { color: var(--text-muted); }
