/* ========================================================================
   SONGSHEET — APP STYLES (Plex family, paper cream + amber accent)
   ======================================================================== */

:root {
  /* Surfaces */
  --paper:        #efe4b0;
  --paper-2:      #fef9e3;
  --card:         #ffffff;
  --card-hover:   #fafafa;

  /* Ink */
  --ink:          #0f172a;
  --ink-dim:      #44403c;
  --ink-mute:     #78716c;

  /* Lines */
  --rule:         #e7e5e4;
  --rule-strong:  #d6d3d1;

  /* Accent */
  --accent:       #d97706;
  --accent-hover: #b45309;
  --accent-soft:  rgba(217, 119, 6, .08);
  --accent-ring:  rgba(217, 119, 6, .30);

  /* Semantic */
  --danger:       #dc2626;
  --success:      #059669;

  /* Typography */
  --font-serif: 'IBM Plex Serif', Georgia, 'Times New Roman', serif;
  --font-sans:  'IBM Plex Sans', -apple-system, system-ui, sans-serif;
  --font-mono:  'IBM Plex Mono', ui-monospace, 'Cascadia Code', monospace;

  /* Type scale */
  --text-2xs:  10px;
  --text-xs:   12px;
  --text-sm:   14px;
  --text-base: 16px;
  --text-lg:   18px;
  --text-xl:   22px;
  --text-2xl:  28px;
  --text-3xl:  36px;

  /* Leading */
  --leading-tight:   1.25;
  --leading-normal:  1.5;
  --leading-relaxed: 1.75;

  /* Spacing 4/8 */
  --space-1: 4px;   --space-2: 8px;   --space-3: 12px;
  --space-4: 16px;  --space-5: 24px;  --space-6: 32px;  --space-7: 48px;

  /* Radius */
  --radius-sm: 4px; --radius: 6px; --radius-lg: 10px; --radius-xl: 14px;

  /* Focus */
  --focus-ring:   0 0 0 2px var(--accent), 0 0 0 4px var(--paper);

  /* Motion */
  --motion-fast:    120ms cubic-bezier(.2, .8, .2, 1);
  --motion-normal:  220ms cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--ink);
  background: var(--paper);
  min-height: 100dvh;
  overscroll-behavior: contain;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

button, input, textarea, [contenteditable] {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  touch-action: manipulation;
}

button {
  background: none;
  border: none;
  cursor: pointer;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ─────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-3);
  background: var(--card);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: env(safe-area-inset-top);
  height: calc(48px + env(safe-area-inset-top));
}
.topbar-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-size: 18px;
  color: var(--ink-dim);
  transition: background var(--motion-fast);
}
.topbar-btn:hover { background: var(--paper-2); }
.topbar-btn:active { background: var(--paper); }
.topbar-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: block;
  margin-left: var(--space-1);
}
.topbar-title {
  flex: 1;
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-save {
  font-size: var(--text-xs);
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
}

/* ── Update toast ───────────────────────────────────────────────────── */
.update-toast {
  position: fixed;
  bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  z-index: 500;
  box-shadow: 0 4px 16px rgba(15,23,42,.20);
}
.update-toast .btn-primary {
  min-height: 32px;
  padding: 0 var(--space-3);
}

/* ── Library view ───────────────────────────────────────────────────── */
.library-view {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.library-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.library-empty {
  padding: var(--space-5);
  text-align: center;
  color: var(--ink-mute);
  font-style: italic;
}
.library-item {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--card);
}
.library-item-btn {
  flex: 1;
  text-align: left;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.library-item-title {
  font-family: var(--font-serif);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--ink);
}
.library-item-artist {
  font-family: var(--font-serif);
  font-size: var(--text-sm);
  color: var(--ink-dim);
}
.library-item-date {
  font-family: var(--font-sans);
  font-size: var(--text-2xs);
  color: var(--ink-mute);
  margin-top: 2px;
}
.library-item-delete {
  width: 44px;
  border-left: 1px solid var(--rule);
  color: var(--danger);
  font-size: 20px;
}

/* ── Drawer menu ────────────────────────────────────────────────────── */
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(85vw, 320px);
  background: var(--card);
  border-right: 1px solid var(--rule);
  z-index: 401;
  display: none;
  flex-direction: column;
  padding: calc(var(--space-4) + env(safe-area-inset-top)) var(--space-3) calc(var(--space-3) + env(safe-area-inset-bottom));
  gap: var(--space-2);
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform var(--motion-normal);
}
.drawer.visible {
  display: flex;
  transform: translateX(0);
}
.drawer-scrim.visible {
  z-index: 400;
}

.drawer-item {
  text-align: left;
  padding: var(--space-3);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--ink);
  background: transparent;
}
.drawer-item:hover { background: var(--paper-2); }

.drawer-section {
  font-family: var(--font-sans);
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-mute);
  padding: var(--space-3) var(--space-3) var(--space-1);
}

/* ── Preview mode ──────────────────────────────────────────────────── */
.preview-main {
  flex: 1;
  padding: var(--space-4);
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
}
.topbar-btn[aria-label="Pré-visualizar"],
.topbar-btn[aria-label="Editar"] {
  font-size: 16px;
}
