  /* Sidebar offset — match the tracker/workspace pattern so .app-main is
     centered relative to the visible content area (not the full viewport
     including the area the sidebar covers). */
  body[data-page="pals"].sidebar-open .app-main { padding-left: 280px; transition: padding-left 0.22s ease; }
  body[data-page="pals"].sidebar-closed .app-main { padding-left: 56px; transition: padding-left 0.22s ease; }
  @media (max-width: 1023px) {
    body[data-page="pals"].sidebar-open .app-main,
    body[data-page="pals"].sidebar-closed .app-main {
      padding-left: 56px;
    }
  }

  .loops-wrap { max-width: 960px; margin: 0 auto; padding: 28px 24px; }
  .loops-header { margin-bottom: 28px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
  .loops-header-text h1 { font-size: 20px; margin: 0 0 4px 0; font-weight: 600; }
  .loops-header-text .hint { color: var(--fg-muted); font-size: 12px; }
  .lounge-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    background: linear-gradient(135deg, #d9f0c9 0%, #a8d68f 100%);
    color: #2d5016;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid rgba(45, 80, 22, 0.18);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    flex-shrink: 0;
    box-sizing: border-box;
  }
  .lounge-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(45, 80, 22, 0.22);
  }
  body[data-color-mode="dark"] .lounge-btn {
    background: linear-gradient(135deg, #4d5f48 0%, #6b8061 100%);
    color: #e8f3dd;
    border-color: rgba(232, 243, 221, 0.18);
  }
  body[data-color-mode="dark"] .lounge-btn:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  }
  .lounge-btn i,
  .lounge-btn svg { width: 12px !important; height: 12px !important; flex-shrink: 0; }
  .loops-section { margin-bottom: 28px; }
  .loops-section h2 { font-size: 11px; font-weight: 600; color: var(--fg-muted); margin: 0 0 10px 0; text-transform: uppercase; letter-spacing: 0.6px; }
  .loops-error { padding: 10px 12px; background: var(--danger-bg, #fee2e2); color: var(--danger-fg, #991b1b); border-radius: 6px; margin-bottom: 16px; font-size: 13px; }

  /* Loop cards — one per loop with a friendly avatar + plain-English description */
  .loop-list { display: flex; flex-direction: column; gap: 12px; }
  .loop-card {
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 16px 18px;
    background: var(--bg);
    display: grid;
    grid-template-columns: 64px 1fr auto;
    gap: 16px;
    align-items: start;
  }
  .loop-avatar {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    line-height: 1;
    user-select: none;
  }
  .loop-avatar img { width: 100%; height: 100%; object-fit: contain; }
  .loop-card.working .loop-avatar { animation: avatarBob 1.4s ease-in-out infinite; }
  @keyframes avatarBob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
  }
  .loop-body { min-width: 0; }
  .loop-headline { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
  .loop-charname { font-weight: 600; color: var(--fg); font-size: 15px; }
  .loop-tagline { color: var(--fg-muted); font-size: 12px; font-weight: 500; }
  .loop-techname { font-family: ui-monospace, monospace; font-size: 11px; color: var(--fg-muted); opacity: 0.7; }
  .loop-description { color: var(--fg-secondary); font-size: 13px; line-height: 1.45; margin: 4px 0 8px 0; }
  .loop-rhythm { color: var(--fg-muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 12px; }
  .loop-rhythm span strong { color: var(--fg); font-weight: 500; }
  .loop-recent { font-size: 12.5px; color: var(--fg-secondary); margin-top: 8px; font-style: italic; line-height: 1.45; }
  .loop-bubble {
    margin-top: 10px;
    padding: 8px 12px;
    background: var(--bg-secondary, #f4f4f3);
    border-radius: 12px;
    border-top-left-radius: 4px;
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--fg-secondary);
    display: flex;
    gap: 8px;
    align-items: flex-start;
  }
  .loop-bubble-emoji { flex-shrink: 0; opacity: 0.7; }
  .loop-bubble-text { flex: 1; min-width: 0; word-wrap: break-word; }
  .loop-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 12px;
    background: var(--bg-elevated);
    color: var(--fg-muted);
    white-space: nowrap;
  }
  .loop-status .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--fg-muted); display: inline-block; }
  .loop-status.running { background: rgba(22,163,74,0.08); color: #16a34a; }
  .loop-status.running .dot { background: #16a34a; box-shadow: 0 0 0 3px rgba(22,163,74,0.18); }
  .loop-status.working { background: rgba(37,99,235,0.10); color: #2563eb; }
  .loop-status.working .dot { background: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.20); animation: workingPulse 1.4s ease-in-out infinite; }
  @keyframes workingPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 3px rgba(37,99,235,0.20); }
    50% { transform: scale(1.2); box-shadow: 0 0 0 6px rgba(37,99,235,0.12); }
  }
  .loop-log-details { margin-top: 10px; grid-column: 1 / -1; }
  .loop-log-details summary { font-size: 11px; color: var(--fg-muted); cursor: pointer; user-select: none; padding: 2px 0; }
  .loop-log-details summary:hover { color: var(--fg); }
  .loop-log { font-family: ui-monospace, monospace; font-size: 11px; color: var(--fg-muted); white-space: pre-wrap; max-height: 96px; overflow: auto; background: var(--bg-elevated); padding: 8px 10px; border-radius: 4px; margin-top: 8px; }
  .loop-empty { padding: 14px 16px; color: var(--fg-muted); font-size: 12px; border: 1px dashed var(--border-subtle); border-radius: 8px; }

  /* Card is tappable to expand a drawer with actions */
  .loop-card { cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease; }
  .loop-card:hover { background: var(--bg-elevated); }
  .loop-card.expanded { background: var(--bg-elevated); }
  .loop-card.off { opacity: 0.7; }
  .loop-card.off .loop-avatar { filter: grayscale(0.5); }

  /* Drawer: appears below card body when expanded */
  .loop-drawer {
    grid-column: 1 / -1;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-subtle);
    display: none;
    gap: 8px;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .loop-card.expanded .loop-drawer { display: flex; }
  .loop-action-btn {
    font: inherit;
    font-size: 12.5px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 32px;
    padding: 0 12px;
    color: var(--fg);
    background: var(--bg);
    border: 1px solid var(--border-stronger);
    border-radius: 6px;
    cursor: pointer;
    box-sizing: border-box;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
  }
  .loop-action-btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
  .loop-action-btn:disabled { cursor: not-allowed; opacity: 0.5; }
  .loop-action-btn.delete:hover { color: #dc2626; border-color: #dc2626; }
  .loop-action-btn.delete.confirming {
    color: #fff; background: #dc2626; border-color: #dc2626;
  }
  .loop-action-btn.delete.confirming:hover { background: #b91c1c; border-color: #b91c1c; }
  .loop-action-btn.resume:hover { color: #16a34a; border-color: #16a34a; }
  .loop-action-btn i,
  .loop-action-btn svg { width: 11px !important; height: 11px !important; flex-shrink: 0; }
  .loop-delete-cancel {
    font: inherit;
    font-size: 12px;
    color: var(--fg-muted);
    background: transparent;
    border: none;
    padding: 6px 8px;
    cursor: pointer;
  }
  .loop-delete-cancel:hover { color: var(--fg); }
  .loop-drawer-spacer { flex: 1; }
  .loop-drawer-hint {
    color: var(--fg-muted);
    font-size: 11px;
    font-style: italic;
  }

  /* Toast */
  .toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--fg);
    color: var(--bg);
    font-size: 13px;
    padding: 8px 14px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 100;
  }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
  .toast.error { background: #dc2626; }

  /* + New pal button in header */
  .new-pal-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    background: var(--fg);
    color: var(--bg);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    flex-shrink: 0;
    box-sizing: border-box;
  }
  .new-pal-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.18); }
  .new-pal-btn i,
  .new-pal-btn svg { width: 12px !important; height: 12px !important; flex-shrink: 0; }
  .loops-header-actions { display: flex; gap: 8px; align-items: center; }

  /* Modal */
  /* ── Lounge: top-down garden where pals roam ───────────────────────── */
  :root { --lounge-height: 38vh; }

  .lounge-panel {
    /* The garden is always there at the top — sits below the main sheet on
       the z-axis. When you open the hangout the main sheet slides DOWN to
       reveal the garden that was already behind it. The panel itself does
       NOT animate; only the sheet does. */
    position: fixed;
    top: 0; right: 0;
    left: 56px;
    height: var(--lounge-height);
    z-index: 0; /* behind .app-main (auto stacking) */
    overflow: hidden;
    pointer-events: none;
    transition: left 0.22s ease;
    /* Layered top-down garden:
       - Base grass: soft sage green gradient
       - Sun-dappled patches (radial gradients)
       - River cuts diagonally
     */
    background:
      radial-gradient(ellipse 240px 120px at 15% 70%, rgba(255,255,255,0.18), transparent 60%),
      radial-gradient(ellipse 300px 140px at 75% 30%, rgba(255,255,255,0.14), transparent 60%),
      radial-gradient(ellipse 200px 90px at 50% 90%, rgba(0,0,0,0.06), transparent 60%),
      linear-gradient(180deg, #d9f0c9 0%, #b9e0a2 60%, #9fd086 100%);
    box-shadow: inset 0 -8px 24px -10px rgba(34, 84, 28, 0.22);
  }
  body.lounge-open .lounge-panel {
    pointer-events: auto;
  }
  /* When the sidebar is open, push the lounge panel right to clear it —
     matches the same offset .app-main gets. */
  body[data-page="pals"].sidebar-open .lounge-panel { left: 280px; }
  body[data-page="pals"].sidebar-closed .lounge-panel { left: 56px; }
  @media (max-width: 1023px) {
    body[data-page="pals"].sidebar-open .lounge-panel,
    body[data-page="pals"].sidebar-closed .lounge-panel {
      left: 56px;
    }
  }

  body[data-color-mode="dark"] .lounge-panel,
  body[data-color-mode="system"] .lounge-panel {
    /* will be overridden by media query below for system mode */
  }
  body[data-color-mode="dark"] .lounge-panel {
    background:
      radial-gradient(ellipse 240px 120px at 15% 70%, rgba(255,255,255,0.06), transparent 60%),
      radial-gradient(ellipse 300px 140px at 75% 30%, rgba(255,255,255,0.05), transparent 60%),
      radial-gradient(ellipse 200px 90px at 50% 90%, rgba(0,0,0,0.18), transparent 60%),
      linear-gradient(180deg, #2d3a2a 0%, #3a4a36 60%, #4d5f48 100%);
    box-shadow: inset 0 -8px 24px -10px rgba(0,0,0,0.3);
  }
  @media (prefers-color-scheme: dark) {
    body[data-color-mode="system"] .lounge-panel {
      background:
        radial-gradient(ellipse 240px 120px at 15% 70%, rgba(255,255,255,0.06), transparent 60%),
        radial-gradient(ellipse 300px 140px at 75% 30%, rgba(255,255,255,0.05), transparent 60%),
        radial-gradient(ellipse 200px 90px at 50% 90%, rgba(0,0,0,0.18), transparent 60%),
        linear-gradient(180deg, #2d3a2a 0%, #3a4a36 60%, #4d5f48 100%);
      box-shadow: inset 0 -8px 24px -10px rgba(0,0,0,0.3);
    }
  }

  /* River — an SVG that fills the lounge */
  .lounge-river {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    pointer-events: none;
  }

  /* Floor — pals are absolutely positioned within this */
  .lounge-floor {
    position: absolute;
    inset: 0;
    overflow: hidden;
  }
  .lounge-pal {
    position: absolute;
    width: 44px; height: 44px;
    cursor: pointer;
    /* JS sets left/top with smooth transitions. The wrapper handles
       the wandering motion; an inner span handles idle bobbing so the
       two animations compose cleanly. */
    transition: left 4s linear, top 4s linear;
    filter: drop-shadow(0 4px 4px rgba(0,0,0,0.18));
    transform-origin: center bottom;
  }
  .lounge-pal-inner {
    display: block;
    width: 100%; height: 100%;
    animation: loungeBob var(--bob-dur, 2.4s) ease-in-out infinite;
    animation-delay: var(--bob-delay, 0s);
  }
  /* Walking: faster bob + slight side-to-side sway, like footsteps */
  .lounge-pal.walking .lounge-pal-inner {
    animation: loungeWalk 0.42s ease-in-out infinite !important;
  }
  @keyframes loungeWalk {
    0%   { transform: translateY(0)    rotate(0deg); }
    25%  { transform: translateY(-2.5px) rotate(-4deg); }
    50%  { transform: translateY(0)    rotate(0deg); }
    75%  { transform: translateY(-2.5px) rotate(4deg); }
    100% { transform: translateY(0)    rotate(0deg); }
  }
  .lounge-pal img {
    width: 100%; height: 100%;
    object-fit: contain;
    pointer-events: none;
  }
  .lounge-pal:hover { z-index: 5; }
  .lounge-pal:hover .lounge-pal-inner { animation-play-state: paused; transform: scale(1.15); }
  @keyframes loungeBob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
  }

  /* Bounce reaction when clicked */
  .lounge-pal-bounce .lounge-pal-inner {
    animation: loungeBounce 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  }
  @keyframes loungeBounce {
    0% { transform: translateY(0) scale(1); }
    30% { transform: translateY(-22px) scale(1.12); }
    60% { transform: translateY(0) scale(1); }
    75% { transform: translateY(-6px) scale(1.04); }
    100% { transform: translateY(0) scale(1); }
  }

  /* Facing direction: flip the img when walking left */
  .lounge-pal[data-facing="left"] img { transform: scaleX(-1); }

  /* Chatting: when two pals get close, they pause and wiggle excitedly
     with a little speech bubble above their heads */
  .lounge-pal.chatting {
    transition: none; /* freeze movement while chatting */
  }
  .lounge-pal.chatting .lounge-pal-inner {
    animation: chatWiggle 0.45s ease-in-out infinite !important;
  }
  @keyframes chatWiggle {
    0%   { transform: translate(0, 0) rotate(0deg); }
    25%  { transform: translate(-1.5px, -1.5px) rotate(-4deg); }
    50%  { transform: translate(0, -2px) rotate(0deg); }
    75%  { transform: translate(1.5px, -1.5px) rotate(4deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
  }

  .speech-bubble {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(4px) scale(0.6);
    margin-bottom: 8px;
    padding: 5px 9px;
    background: rgba(255, 255, 255, 0.96);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    white-space: nowrap;
  }
  .speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 6px; height: 6px;
    background: rgba(255, 255, 255, 0.96);
  }
  .lounge-pal.chatting .speech-bubble {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
  body[data-color-mode="dark"] .speech-bubble,
  body[data-color-mode="dark"] .speech-bubble::after {
    background: rgba(28, 25, 23, 0.92);
  }
  .speech-bubble .dot {
    display: inline-block;
    width: 3px; height: 3px;
    background: #57534e;
    border-radius: 50%;
    animation: dotPulse 1.1s ease-in-out infinite;
  }
  .speech-bubble .dot:nth-child(2) { animation-delay: 0.15s; }
  .speech-bubble .dot:nth-child(3) { animation-delay: 0.3s; }
  body[data-color-mode="dark"] .speech-bubble .dot { background: #d6d3d1; }
  @keyframes dotPulse {
    0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
    30%           { opacity: 1;    transform: translateY(-2px); }
  }

  /* The main sheet sits above the lounge panel on the z-axis. The garden
     is always there behind it; on lounge-open the sheet slides DOWN to
     reveal what's already been there the whole time. The solid bg is what
     makes the sheet read as opaque — without it the garden bleeds through. */
  body[data-page="pals"] .app-main {
    position: relative;
    z-index: 1;
    background: var(--bg);
    /* Slower drop with a slight overshoot/bounce when it lands. The Y > 1
       on the third control point causes the sheet to dip past the target
       and settle back, like a real bottom sheet hitting its stop. */
    transition: transform 1.5s cubic-bezier(0.34, 1.56, 0.64, 1),
                padding-left 0.22s ease;
  }
  body.lounge-open .app-main {
    transform: translateY(var(--lounge-height));
  }

  /* Hangout button: trees when closed, chevron-up when open (so chevron
     sits to the left of "Hangout", not sandwiched between two icons). */
  body.lounge-open .lounge-btn > i[data-lucide="trees"],
  body.lounge-open .lounge-btn > svg.lucide-trees { display: none; }
  .lounge-btn .lounge-icon-close { display: none; }
  body.lounge-open .lounge-btn .lounge-icon-close { display: inline-flex; }

  .modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .modal-backdrop.show { opacity: 1; pointer-events: auto; }
  .pal-modal {
    background: var(--bg);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    width: min(620px, calc(100vw - 32px));
    max-height: calc(100vh - 60px);
    display: flex; flex-direction: column;
    box-shadow: 0 12px 36px rgba(0,0,0,0.25);
    transform: translateY(12px) scale(0.98);
    transition: transform 0.2s ease;
  }
  .modal-backdrop.show .pal-modal { transform: translateY(0) scale(1); }
  .modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 28px 18px;
    border-bottom: 1px solid var(--border-subtle);
  }
  .modal-head h2 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
  .modal-close { background: none; border: none; cursor: pointer; padding: 6px; color: var(--fg-muted); border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; }
  .modal-close:hover { background: var(--bg-elevated); color: var(--fg); }
  .modal-close i,
  .modal-close svg { width: 16px !important; height: 16px !important; flex-shrink: 0; }
  .modal-body { padding: 24px 28px 8px; overflow-y: auto; flex: 1; }
  .modal-foot {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 16px 28px; border-top: 1px solid var(--border-subtle);
  }
  .modal-btn {
    font: inherit;
    font-size: 13px;
    padding: 9px 18px; border-radius: 8px; font-weight: 500;
    cursor: pointer; border: 1px solid var(--border-stronger); background: var(--bg);
    color: var(--fg);
    transition: background 0.12s, border-color 0.12s;
  }
  .modal-btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
  .modal-btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
  .modal-btn.primary:hover { opacity: 0.88; background: var(--fg); }
  .modal-btn:disabled { opacity: 0.4; cursor: not-allowed; }

  /* Sections inside modal */
  .pal-section { margin-bottom: 26px; }
  .pal-section:last-child { margin-bottom: 16px; }
  .pal-section-label {
    display: block; font-size: 13px; font-weight: 600;
    color: var(--fg); margin-bottom: 4px;
    letter-spacing: -0.005em;
  }
  .pal-section-hint { font-size: 12.5px; color: var(--fg-muted); margin: 0 0 12px 0; line-height: 1.45; }
  .pal-input, .pal-textarea, .pal-select {
    width: 100%; padding: 10px 14px;
    border: 1px solid var(--border-stronger); border-radius: 8px;
    background: var(--bg); color: var(--fg);
    font-size: 13px; font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.12s, background 0.12s;
  }
  .pal-textarea { resize: vertical; min-height: 96px; font-family: inherit; line-height: 1.5; }
  .pal-input:focus, .pal-textarea:focus, .pal-select:focus {
    outline: none; border-color: var(--fg); background: var(--bg);
  }

  /* Figpal picker — figpals float freely, no container chrome */
  .figpal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 6px;
    max-height: 230px; overflow-y: auto;
    padding: 6px 4px;
    margin: 0 -4px;
  }
  .figpal-tile {
    aspect-ratio: 1;
    border-radius: 12px;
    background: transparent;
    border: 2px solid transparent;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background 0.12s, transform 0.12s, border-color 0.12s;
    padding: 6px;
  }
  .figpal-tile:hover { background: var(--bg-elevated); transform: translateY(-1px); }
  .figpal-tile.selected { border-color: var(--fg); background: var(--bg-elevated); }
  .figpal-tile img {
    width: 100%; height: 100%; object-fit: contain;
    opacity: 0;
    animation: figpalFadeIn 0.4s ease forwards;
  }
  @keyframes figpalFadeIn {
    to { opacity: 1; }
  }

  /* Skeleton shimmer while figpals load */
  .figpal-skeleton {
    aspect-ratio: 1;
    border-radius: 12px;
    background: linear-gradient(
      90deg,
      var(--bg-elevated) 0%,
      var(--bg-hover) 50%,
      var(--bg-elevated) 100%
    );
    background-size: 200% 100%;
    animation: figpalShimmer 1.4s ease-in-out infinite;
  }
  @keyframes figpalShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
  }

  /* Name builder */
  .pal-name-row { display: flex; gap: 10px; align-items: center; }
  .pal-name-row .pal-input { flex: 1 1 50%; }
  .pal-figpal-display {
    flex: 1 1 50%;
    padding: 10px 14px;
    background: var(--bg-elevated);
    border: 1px dashed var(--border-stronger);
    border-radius: 8px;
    font-size: 13px;
    color: var(--fg-muted);
    text-align: center;
    box-sizing: border-box;
  }
  .pal-figpal-display.has-figpal { color: var(--fg); font-weight: 500; }
  .pal-name-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
  .pal-name-suggestion {
    font: inherit;
    padding: 5px 12px; border-radius: 999px;
    border: 1px solid var(--border-stronger);
    background: var(--bg);
    font-size: 12.5px; cursor: pointer;
    color: var(--fg);
    transition: background 0.12s, border-color 0.12s;
  }
  .pal-name-suggestion:hover { background: var(--bg-hover); border-color: var(--border-strong); }
  .pal-name-suggestion.loading {
    color: var(--fg-muted);
    pointer-events: none;
    opacity: 0.6;
    font-style: italic;
  }
  .pal-suggest-btn {
    font: inherit;
    margin-top: 10px;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px dashed var(--border-stronger);
    background: transparent;
    font-size: 12.5px;
    color: var(--fg-muted);
    cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
    transition: color 0.12s, border-color 0.12s;
  }
  .pal-suggest-btn:hover { color: var(--fg); border-color: var(--border-strong); }
  .pal-suggest-btn i,
  .pal-suggest-btn svg { width: 11px !important; height: 11px !important; flex-shrink: 0; }

  /* Inferred-schedule line in the name section */
  .pal-inferred-schedule {
    display: none;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 9px 12px;
    background: var(--bg-elevated);
    border-radius: 8px;
    font-size: 12.5px;
    color: var(--fg-secondary);
  }
  .pal-inferred-schedule.show { display: flex; flex-wrap: wrap; }
  .pal-inferred-schedule i,
  .pal-inferred-schedule svg { width: 12px !important; height: 12px !important; flex-shrink: 0; color: var(--fg-muted); }
  .pal-inferred-schedule .schedule-text { color: var(--fg); font-weight: 500; }
  .pal-inferred-schedule .schedule-edit-link {
    margin-left: auto;
    font: inherit;
    font-size: 12px;
    background: none;
    border: none;
    color: var(--fg-muted);
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
  }
  .pal-inferred-schedule .schedule-edit-link:hover { color: var(--fg); }

  /* Schedule editor — hidden by default, expanded via inferred-schedule edit link */
  .pal-schedule-editor { display: none; margin-top: 12px; padding-top: 16px; border-top: 1px dashed var(--border-subtle); }
  .pal-schedule-editor.show { display: block; }

  /* Schedule picker — segmented type chooser + stacked fields */
  .schedule-type-picker {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    padding: 4px;
    background: var(--bg-elevated);
    border-radius: 10px;
    margin-bottom: 16px;
  }
  .schedule-type-option {
    font: inherit;
    font-size: 13px;
    padding: 8px 10px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--fg-muted);
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    text-align: center;
  }
  .schedule-type-option:hover { color: var(--fg); }
  .schedule-type-option.selected {
    background: var(--bg);
    color: var(--fg);
    border-color: var(--border-stronger);
    font-weight: 500;
  }

  .schedule-fields {
    display: flex; flex-direction: column;
    gap: 12px;
    padding: 4px 0;
  }
  .schedule-field { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
  .schedule-field-label {
    font-size: 13px;
    color: var(--fg-secondary);
    min-width: 76px;
  }
  .schedule-field input[type="number"],
  .schedule-field input[type="time"],
  .schedule-field select {
    padding: 8px 12px;
    border: 1px solid var(--border-stronger);
    border-radius: 7px;
    background: var(--bg);
    color: var(--fg);
    font-size: 13px;
    font-family: inherit;
    box-sizing: border-box;
  }
  .schedule-field input[type="number"]:focus,
  .schedule-field input[type="time"]:focus,
  .schedule-field select:focus { outline: none; border-color: var(--fg); }
  .schedule-field input[type="number"] { width: 72px; text-align: center; }
  .schedule-field input[type="time"] { width: 110px; }
  .schedule-field select { width: auto; min-width: 130px; }
  .schedule-field-unit { font-size: 13px; color: var(--fg-secondary); }
  .schedule-checkbox-row {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 13px; color: var(--fg-secondary);
    cursor: pointer; user-select: none;
  }
  .schedule-checkbox-row input { width: 14px; height: 14px; margin: 0; cursor: pointer; }
  .schedule-tz-note {
    font-size: 12px; color: var(--fg-muted);
    margin: 12px 0 0;
    padding-top: 12px;
    border-top: 1px dashed var(--border-subtle);
  }

  .pal-form-error {
    padding: 10px 14px;
    background: rgba(220, 38, 38, 0.08);
    color: #dc2626;
    border: 1px solid rgba(220, 38, 38, 0.22);
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 18px;
  }
