:root {
  color-scheme: dark;
  --bg: #101112;
  --surface: #17191b;
  --surface-2: #202326;
  --surface-3: #292c30;
  --line: rgba(255, 255, 255, .09);
  --line-strong: rgba(255, 255, 255, .16);
  --text: #f4f5f6;
  --muted: #a1a6ac;
  --quiet: #696f76;
  --blue: #5b82ff;
  --blue-bright: #6e94ff;
  --purple: #b88bff;
  --danger: #ff7777;
  --ease: cubic-bezier(.2, 0, 0, 1);
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; }
button, textarea { font: inherit; }
button { border: 0; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible, textarea:focus-visible { outline: 2px solid var(--blue-bright); outline-offset: 3px; }
svg { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
[data-icon] { display: grid; place-items: center; flex: 0 0 auto; line-height: 0; }

.editor-app { min-height: 100dvh; display: flex; flex-direction: column; max-width: 760px; margin: 0 auto; }
.topbar { height: 92px; display: flex; align-items: center; justify-content: space-between; padding: max(16px, env(safe-area-inset-top)) 24px 0; gap: 16px; }
.song-heading { display: grid; gap: 3px; text-align: center; min-width: 0; }
.song-heading strong { font-family: Manrope, sans-serif; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
.eyebrow { color: var(--quiet); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; }
.top-actions { display: flex; gap: 8px; }
.icon-button { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--surface); color: var(--muted); transition: background 180ms var(--ease), color 180ms var(--ease), transform 180ms var(--ease); }
.icon-button:hover { background: var(--surface-2); color: var(--text); }
.icon-button:active, .tool-button:active { transform: scale(.96); }
.icon-button:disabled { color: #454a50; cursor: default; }
.editor-content { flex: 1; padding: 4px 24px 56px; }
.lyrics-toolbar { --toolbar-button-size: 40px; width: min(359px, calc(100vw - 16px)); height: 52px; display: flex; align-items: center; justify-content: center; gap: 3px; padding: 5px; margin: 0 auto 24px; background: rgba(23,25,27,.72); border: 1px solid rgba(255,255,255,.12); border-radius: 20px; box-shadow: 0 8px 26px rgba(0,0,0,.18); -webkit-backdrop-filter: blur(18px) saturate(125%); backdrop-filter: blur(18px) saturate(125%); }
.tool-button { flex: 0 0 var(--toolbar-button-size); width: var(--toolbar-button-size); min-width: 0; height: var(--toolbar-button-size); aspect-ratio: 1; display: grid; place-items: center; border-radius: 15px; color: var(--muted); background: transparent; transition: background 160ms var(--ease), color 160ms var(--ease), transform 160ms var(--ease); }
.tool-button:hover, .tool-button.is-active { color: var(--text); background: var(--surface-3); }
.tool-button.is-active { color: #d9c2ff; }
.tool-button.ai-tool { color: #c3a3ff; }
.tool-button.save-tool { color: #b6e2c4; }
.tool-button.save-tool:hover { color: #e1ffe8; background: rgba(105,197,138,.14); }
.toolbar-divider { height: 24px; width: 1px; margin: 0 6px; background: var(--line); }
.lyrics-document { display: grid; gap: 0; }
.lyrics-block { position: relative; display: grid; gap: 1px; padding: 3px 6px 4px; border: 0; border-radius: 0; transition: opacity 180ms var(--ease), box-shadow 180ms var(--ease), transform 320ms cubic-bezier(.22, 1, .36, 1); }
.lyrics-block.is-entering { animation: block-enter 340ms var(--ease) both; }
.lyrics-block.is-removing { pointer-events: none; animation: block-exit 220ms ease-in both; }
.lyrics-block.is-dragging { z-index: 2; opacity: .96; transform: translateY(-3px) scale(.985); box-shadow: 0 12px 28px rgba(0,0,0,.28); transition: opacity 160ms var(--ease), box-shadow 220ms var(--ease), transform 130ms cubic-bezier(.2, 0, 0, 1); }
.lyrics-block.drop-target::before { position: absolute; top: -1px; right: 6px; left: 6px; height: 2px; border-radius: 2px; background: var(--blue-bright); box-shadow: 0 0 12px rgba(91,130,255,.45); content: ""; opacity: 1; animation: drop-indicator 180ms var(--ease) both; }
.block-heading { display: flex; align-items: center; min-height: 28px; gap: 7px; }
.drag-handle, .block-more { display: grid; place-items: center; flex: 0 0 32px; width: 32px; height: 32px; padding: 0; border-radius: 8px; background: transparent; color: var(--quiet); transition: color 160ms var(--ease), background 160ms var(--ease), transform 160ms var(--ease); }
.drag-handle { cursor: grab; touch-action: none; }
.drag-handle:active { cursor: grabbing; }
.drag-handle:hover, .block-more:hover { color: var(--text); background: var(--surface-2); }
.block-more { margin-left: auto; opacity: 0; }
.lyrics-block:hover .block-more, .lyrics-block:focus-within .block-more, .lyrics-block.is-selected .block-more { opacity: 1; }
.block-label { display: inline-flex; align-items: center; min-height: 28px; padding: 0; color: var(--quiet); background: transparent; font-size: 12px; font-weight: 700; transition: color 160ms var(--ease); }
.block-label:hover, .lyrics-block.is-selected .block-label, .lyrics-block:focus-within .block-label { color: var(--blue-bright); }
.block-grip { display: grid; place-items: center; width: 16px; height: 16px; color: currentColor; }
.block-grip svg { width: 16px; height: 16px; }
.lyrics-text { display: block; width: 100%; min-height: 96px; height: 96px; resize: none; overflow: hidden; padding: 0 0 2px 39px; border: 0; outline: 0; box-shadow: none; background: transparent; color: var(--text); caret-color: var(--blue-bright); font-family: Manrope, sans-serif; font-size: clamp(16px, 4.2vw, 19px); font-weight: 500; line-height: 1.55; letter-spacing: 0; }
.lyrics-text:focus, .lyrics-text:focus-visible { border: 0; outline: 0; box-shadow: none; }
.lyrics-text::selection { background: rgba(91,130,255,.35); }
.lyrics-text::placeholder { color: var(--quiet); opacity: .72; }
.add-block { display: flex; align-items: center; gap: 9px; margin: 8px 45px 0; padding: 9px 0; background: transparent; color: var(--quiet); font-size: 12px; font-weight: 700; transition: color 160ms var(--ease); }
.add-block:hover { color: var(--text); }
.add-block svg { width: 16px; height: 16px; }
.lyrics-toolbar .tool-button svg { width: 20px; height: 20px; }
.lyrics-toolbar .save-tool svg { stroke-width: 2.1; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 94px; width: max-content; max-width: calc(100vw - 36px); padding: 11px 15px; border-radius: 10px; color: var(--text); background: #2a2d31; border: 1px solid var(--line-strong); box-shadow: 0 12px 30px rgba(0,0,0,.3); font-size: 13px; opacity: 0; pointer-events: none; transform: translate(-50%, 8px); transition: opacity 180ms var(--ease), transform 180ms var(--ease); }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.sheet-backdrop { position: fixed; z-index: 9; inset: 0; background: rgba(0,0,0,.58); opacity: 0; pointer-events: none; transition: opacity 220ms var(--ease); }
.sheet-backdrop.is-open { opacity: 1; pointer-events: auto; }
.action-sheet { position: fixed; z-index: 10; right: 0; bottom: 0; left: 0; max-width: 760px; margin: 0 auto; padding: 12px 20px max(22px, env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; background: #232527; box-shadow: 0 -14px 50px rgba(0,0,0,.42); transform: translateY(105%); transition: transform 300ms var(--ease); }
.action-sheet.is-open { transform: translateY(0); }
.sheet-handle { width: 38px; height: 4px; margin: 0 auto 20px; border-radius: 8px; background: #555a60; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 17px; padding: 0 2px; }
.sheet-header h2 { margin: 3px 0 0; font-family: Manrope, sans-serif; font-size: 20px; }
.sheet-header .icon-button { width: 38px; height: 38px; background: var(--surface-3); }
.type-toggle { display: grid; place-items: center; width: 28px; height: 32px; padding: 0; border: 0; outline: 0; border-radius: 7px; color: var(--quiet); background: transparent; cursor: pointer; transition: color 160ms var(--ease), background 160ms var(--ease), transform 160ms var(--ease); }
.type-toggle:hover, .lyrics-block.is-type-open .type-toggle { color: var(--text); background: var(--surface-2); }
.type-toggle[aria-expanded="true"] { color: var(--blue-bright); }
.type-toggle svg { width: 15px; height: 15px; }
.type-menu { position: absolute; z-index: 8; top: 47px; left: 45px; display: grid; width: 190px; padding: 5px; border: 0; border-radius: 10px; background: #24272a; box-shadow: 0 14px 32px rgba(0,0,0,.42); opacity: 0; pointer-events: none; transform: translateY(-4px) scale(.98); transform-origin: top left; transition: opacity 150ms var(--ease), transform 150ms var(--ease); }
.lyrics-block.is-type-open .type-menu { opacity: 1; pointer-events: auto; transform: translateY(0) scale(1); }
.type-option { min-height: 36px; padding: 0 10px; border: 0; border-radius: 6px; color: var(--text); background: transparent; text-align: left; font-size: 12px; cursor: pointer; }
.type-option:hover, .type-option:focus-visible { color: var(--text); background: #383c40; outline: 0; }
.sheet-actions { display: grid; gap: 5px; }
.sheet-actions > button { display: grid; grid-template-columns: 42px 1fr 20px; align-items: center; gap: 12px; width: 100%; min-height: 66px; padding: 8px 10px; text-align: left; border-radius: 13px; background: transparent; transition: background 160ms var(--ease); }
.sheet-actions > button:hover { background: rgba(255,255,255,.06); }
.sheet-actions strong, .sheet-actions small { display: block; }
.sheet-actions strong { font-size: 14px; }
.sheet-actions small { margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.3; }
.sheet-actions > button > [data-icon] { display: grid; place-items: center; align-self: center; justify-self: center; width: 20px; height: 20px; color: var(--quiet); }
.sheet-icon { display: flex; align-items: center; justify-content: center; align-self: center; justify-self: center; width: 40px; height: 40px; padding: 0; overflow: visible; border-radius: 12px; line-height: 0; }
.sheet-icon > [data-icon] { display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; line-height: 0; }
.sheet-icon > [data-icon] svg { display: block; width: 20px; height: 20px; margin: 0; overflow: visible; }
.sheet-icon.accent { color: #c3a3ff; background: rgba(184,139,255,.13); }
.sheet-icon.blue { color: #85a5ff; background: rgba(91,130,255,.14); }
.sheet-icon.neutral { color: #b5bbc2; background: rgba(255,255,255,.08); }
.sheet-icon.danger { color: var(--danger); background: rgba(255,119,119,.11); }
.danger-action { margin-top: 8px; border-top: 1px solid var(--line); border-radius: 0 !important; padding-top: 14px !important; }
.danger-action strong { color: var(--danger); }
.focus-mode .lyrics-block:not(.is-selected) { opacity: .25; }
.focus-mode .lyrics-block.is-selected { opacity: 1; }
@keyframes block-enter {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes block-exit {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-8px) scale(.985); }
}
@keyframes drop-indicator {
  from { opacity: 0; transform: scaleX(.7); }
  to { opacity: 1; transform: scaleX(1); }
}
@keyframes drop-settle {
  from { opacity: .72; transform: scale(.99); }
  to { opacity: 1; transform: scale(1); }
}
@media (min-width: 761px) {
  .editor-app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .editor-content { padding-left: 54px; padding-right: 54px; }
  .topbar { padding-left: 54px; padding-right: 54px; }
  .action-sheet { right: 20px; left: auto; width: 440px; border-radius: 22px; bottom: 24px; transform: translateY(120%) scale(.98); transform-origin: bottom right; }
  .action-sheet.is-open { transform: translateY(0) scale(1); }
  .sheet-backdrop { background: rgba(0,0,0,.3); }
}
@media (max-width: 760px) {
  .editor-content { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
  .lyrics-toolbar { --toolbar-button-size: clamp(32px, calc((100vw - 88px) / 7), 42px); width: min(377px, calc(100vw - 12px)); height: 54px; position: fixed; z-index: 5; top: auto; right: auto; bottom: max(12px, env(safe-area-inset-bottom)); left: 50%; max-width: calc(100vw - 12px); margin: 0; transform: translateX(-50%); }
  .block-more { opacity: 1; }
}
@media (max-width: 390px) {
  .topbar { padding-left: 16px; padding-right: 16px; }
  .editor-content { padding-left: 13px; padding-right: 13px; }
  .lyrics-text { padding-left: 39px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .lyrics-block.is-dragging { transform: none; box-shadow: none; }
}
