/*
  BM3 Setlist のビジュアル基盤。LunaDock と同じく iOS 26 / macOS Tahoe の Liquid Glass に寄せる。
   1. 背景を透かす半透明のガラス。ただし文字が読める濃さは保つ
   2. 縁を走るスペキュラハイライト（.glass::after）
   3. バーやパネルを画面端にベタ付けせず「島」として浮かせる
  ぼかし（backdrop-filter）は数の少ない面（バー・パネル・シート）にだけ掛ける。
  一覧のカードには掛けない（iPhone の Safari はぼかしの数が増えると重くなる）。
*/

/* ===== トークン ===== */
:root {
    --ease: cubic-bezier(0.32, 0.72, 0, 1);
    --spring: cubic-bezier(0.3, 1.3, 0.5, 1);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --bar-h: 56px;
    --top-space: calc(var(--safe-top) + 10px + var(--bar-h) + 14px);

    --r-sm: 12px;
    --r-md: 16px;
    --r-lg: 20px;
    --r-xl: 26px;
    --r-3xl: 34px;

    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Hiragino Kaku Gothic ProN",
        "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
    --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Hiragino Sans", "Yu Gothic UI", system-ui, sans-serif;
}

:root,
[data-theme="light"] {
    color-scheme: light;
    --bg: #eeedf4;
    --txt: #16161d;
    --txt-2: #5a5a6b;
    --txt-3: #8e8e9e;

    --accent: #5146e0;
    --accent-soft: rgb(81 70 224 / 0.12);
    --on-accent: #fff;
    --danger: #c8332c;
    --danger-soft: rgb(200 51 44 / 0.12);
    --teal: #12897a;
    --teal-soft: rgb(18 137 122 / 0.14);
    --warm: #c25e0c;
    --warm-soft: rgb(208 102 15 / 0.13);

    --sep: rgb(0 0 0 / 0.08);
    --fill: rgb(120 120 140 / 0.12);
    --fill-strong: rgb(120 120 140 / 0.22);
    --seg-thumb: rgb(255 255 255 / 0.95);

    --glass-rgb: 255 255 255;
    --glass-a: 0.62;
    --glass-bar-a: 0.72;
    --sheet-a: 0.96;
    --card-a: 0.6;
    --card-solid-a: 0.84;
    --rim-strong: rgb(255 255 255 / 0.9);
    --rim-weak: rgb(255 255 255 / 0.3);
    --shadow-glass: 0 10px 30px -12px rgb(10 10 30 / 0.28), 0 1px 3px rgb(10 10 30 / 0.06);
    --shadow-card: 0 6px 18px -12px rgb(10 10 30 / 0.35);
    --shadow-lift: 0 22px 40px -14px rgb(10 10 30 / 0.45);
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b0b12;
    --txt: #f2f2f7;
    --txt-2: #a9a9ba;
    --txt-3: #6f6f82;

    --accent: #9b94ff;
    --accent-soft: rgb(155 148 255 / 0.16);
    --on-accent: #0b0b18;
    --danger: #ff6b63;
    --danger-soft: rgb(255 107 99 / 0.16);
    --teal: #3fd3be;
    --teal-soft: rgb(63 211 190 / 0.15);
    --warm: #ffa95c;
    --warm-soft: rgb(255 169 92 / 0.15);

    --sep: rgb(255 255 255 / 0.09);
    --fill: rgb(255 255 255 / 0.08);
    --fill-strong: rgb(255 255 255 / 0.16);
    --seg-thumb: rgb(255 255 255 / 0.16);

    --glass-rgb: 30 30 44;
    --glass-a: 0.56;
    --glass-bar-a: 0.66;
    --sheet-a: 0.96;
    --card-a: 0.46;
    --card-solid-a: 0.82;
    --rim-strong: rgb(255 255 255 / 0.38);
    --rim-weak: rgb(255 255 255 / 0.1);
    --shadow-glass: 0 14px 36px -14px rgb(0 0 0 / 0.8), 0 1px 3px rgb(0 0 0 / 0.45);
    --shadow-card: 0 8px 20px -14px rgb(0 0 0 / 0.9);
    --shadow-lift: 0 24px 44px -14px rgb(0 0 0 / 0.95);
}

/* ===== 土台 ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--txt);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.45;
    font-feature-settings: "palt" 1;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
}

button,
input,
select {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.ico {
    width: 1em;
    height: 1em;
    flex: none;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ===== Liquid Glass ===== */
.glass {
    position: relative;
    background: rgb(var(--glass-rgb) / var(--glass-a));
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    backdrop-filter: blur(28px) saturate(180%);
    box-shadow: var(--shadow-glass);
}

/* 縁のスペキュラハイライト。Liquid Glass はこれが無いと成立しない */
.glass::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    padding: 1px;
    background: linear-gradient(150deg, var(--rim-strong), var(--rim-weak) 34%, transparent 58%, var(--rim-weak));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask-composite: exclude;
}

.glass-bar {
    background: rgb(var(--glass-rgb) / var(--glass-bar-a));
    -webkit-backdrop-filter: blur(40px) saturate(190%);
    backdrop-filter: blur(40px) saturate(190%);
}

.card {
    position: relative;
    background: rgb(var(--glass-rgb) / var(--card-a));
    box-shadow: var(--shadow-card), inset 0 0 0 1px var(--rim-weak);
}

.press {
    transition: transform 160ms var(--spring), filter 160ms, background-color 200ms, opacity 200ms, color 200ms;
}

.press:active:not(:disabled) {
    transform: scale(0.955);
    filter: brightness(1.08);
}

/* ガラスの下に色が無いと透け感が出ないので、地に色を敷いておく */
.wallpaper {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(760px 480px at 6% 2%, rgb(120 100 255 / 0.2), transparent 62%),
        radial-gradient(640px 540px at 98% 22%, rgb(0 190 190 / 0.17), transparent 60%),
        radial-gradient(760px 520px at 42% 106%, rgb(255 120 170 / 0.17), transparent 62%),
        var(--bg);
}

[data-theme="dark"] .wallpaper {
    background:
        radial-gradient(820px 520px at 6% 0%, rgb(100 80 240 / 0.28), transparent 62%),
        radial-gradient(660px 560px at 98% 28%, rgb(0 140 170 / 0.2), transparent 60%),
        radial-gradient(780px 540px at 44% 108%, rgb(190 70 140 / 0.2), transparent 62%),
        var(--bg);
}

/* ===== 上のバー ===== */
.topbar {
    position: fixed;
    top: calc(var(--safe-top) + 10px);
    left: 16px;
    right: 16px;
    z-index: 40;
}

.topbar-inner {
    max-width: 1600px;
    height: var(--bar-h);
    margin: 0 auto;
    padding: 0 8px 0 14px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 17px;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.brand-mark {
    width: 32px;
    height: 32px;
    flex: none;
    border-radius: 8px;
    box-shadow: 0 0 14px rgb(130 110 255 / 0.4), 0 0 0 0.5px rgb(255 255 255 / 0.18);
}

/* 元プロジェクトの切り替え。見た目はピル、押すと端末のピッカー（select）が開く */
.project-pill {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    height: 40px;
    padding: 0 14px 0 12px;
    border-radius: 999px;
    background: var(--fill);
    font-size: 14px;
    cursor: pointer;
}

.project-pill .pill-label {
    color: var(--txt-3);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.project-pill strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 650;
}

.project-pill .ico {
    color: var(--txt-2);
}

.project-pill select {
    position: absolute;
    inset: 0;
    width: 100%;
    opacity: 0;
    cursor: pointer;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12.5px;
    color: var(--txt-2);
    white-space: nowrap;
    padding: 0 6px;
}

.status-chip::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--txt-3);
}

.status-chip[data-state="ok"]::before {
    background: var(--teal);
    box-shadow: 0 0 8px var(--teal);
}

.status-chip[data-state="busy"]::before {
    background: var(--accent);
    animation: pulse 0.9s ease-in-out infinite alternate;
}

.status-chip[data-state="error"]::before {
    background: var(--danger);
}

@keyframes pulse {
    from { opacity: 0.35; }
    to { opacity: 1; }
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 0;
    display: grid;
    place-items: center;
    font-size: 19px;
    background: var(--fill);
    color: var(--txt-2);
    flex: none;
}

@media (hover: hover) {
    .icon-btn:hover {
        background: var(--fill-strong);
        color: var(--txt);
    }
}

/* ===== 作業エリア ===== */
.workspace {
    height: 100dvh;
    padding: var(--top-space) 16px 16px;
    max-width: 1632px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
    gap: 16px;
}

.panel {
    border-radius: var(--r-xl);
    padding: 16px 14px 14px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 4px 12px;
    min-height: 36px;
}

.panel-head h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 700;
}

.panel-sub {
    font-size: 12.5px;
    color: var(--txt-3);
    white-space: nowrap;
}

.head-actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

.chip-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 13px;
    border: 0;
    border-radius: 999px;
    background: var(--fill);
    color: var(--txt-2);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.chip-btn .ico {
    font-size: 15px;
}

@media (hover: hover) {
    .chip-btn:hover {
        background: var(--fill-strong);
        color: var(--txt);
    }
}

.chip-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    margin: 0 -6px;
    padding: 2px 6px 10px;
    scrollbar-width: thin;
    overscroll-behavior: contain;
}

/* 検索欄 */
.search-field {
    display: flex;
    align-items: center;
    gap: 9px;
    height: 42px;
    padding: 0 14px;
    margin-bottom: 12px;
    border-radius: 999px;
    background: var(--fill);
    color: var(--txt-3);
    flex: none;
}

.search-field input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: none;
    font-size: 15px;
    color: var(--txt);
}

.search-field input::placeholder {
    color: var(--txt-3);
}

.search-field input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

kbd {
    font-family: inherit;
    font-size: 11px;
    color: var(--txt-3);
    border: 1px solid var(--sep);
    border-radius: 5px;
    padding: 0 5px;
}

/* ===== ライブラリ（曲の一覧） ===== */
.song {
    border-radius: var(--r-md);
    margin-bottom: 8px;
    overflow: hidden;
}

.song-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 6px 6px 4px;
}

.song-main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 0;
    background: none;
    padding: 6px 4px 6px 10px;
    text-align: left;
    border-radius: var(--r-sm);
}

.song-art {
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    background: linear-gradient(140deg, hsl(var(--h) 75% 62%), hsl(calc(var(--h) + 40) 70% 48%));
    box-shadow: inset 0 0 0 0.5px rgb(255 255 255 / 0.3);
}

.song-text {
    min-width: 0;
    flex: 1;
}

.song-title {
    display: block;
    font-weight: 650;
    font-size: 14.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.song-meta {
    display: flex;
    gap: 6px;
    align-items: center;
    font-size: 12px;
    color: var(--txt-3);
}

.song-meta .in-arr {
    color: var(--teal);
    font-weight: 600;
}

.song-main .chev {
    color: var(--txt-3);
    font-size: 15px;
    transition: transform 280ms var(--ease);
}

.song.open .song-main .chev {
    transform: rotate(90deg);
}

.add-btn {
    width: 36px;
    height: 36px;
    flex: none;
    border: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 18px;
    background: var(--accent-soft);
    color: var(--accent);
}

@media (hover: hover) {
    .add-btn:hover {
        background: var(--accent);
        color: var(--on-accent);
    }

    .song-main:hover {
        background: var(--fill);
    }
}

.clip-list {
    padding: 0 8px 8px 12px;
}

.clip-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 4px 5px 6px;
    border-radius: 10px;
    font-size: 13.5px;
}

.clip-row + .clip-row {
    border-top: 1px solid var(--sep);
}

.clip-row.skip {
    opacity: 0.5;
}

.clip-row .clip-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.clip-row .clip-meta {
    font-size: 12px;
    color: var(--txt-3);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.clip-row .add-btn {
    width: 30px;
    height: 30px;
    font-size: 15px;
}

.sec {
    min-width: 34px;
    height: 22px;
    padding: 0 7px;
    border-radius: 7px;
    display: inline-grid;
    place-items: center;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: var(--accent-soft);
    color: var(--accent);
    flex: none;
}

.sec[data-kind="ch"] {
    background: var(--warm-soft);
    color: var(--warm);
}

.sec[data-kind="io"] {
    background: var(--teal-soft);
    color: var(--teal);
}

.sec[data-kind="keep"] {
    background: var(--fill);
    color: var(--txt-2);
}

/* ===== 構成（並べたもの） ===== */
.arr-list {
    padding-bottom: 20px;
}

.block {
    border-radius: var(--r-md);
    margin-bottom: 8px;
    transition: opacity 200ms;
}

.block.dragging,
.clip-item.dragging {
    opacity: 0.3;
}

.block-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 8px 8px 4px;
}

.grip {
    width: 30px;
    height: 34px;
    flex: none;
    display: grid;
    place-items: center;
    color: var(--txt-3);
    font-size: 16px;
    cursor: grab;
    touch-action: none;
    border-radius: 8px;
}

.grip:active {
    cursor: grabbing;
}

.block-index {
    font-size: 12px;
    font-weight: 700;
    color: var(--txt-3);
    font-variant-numeric: tabular-nums;
    min-width: 18px;
}

.block-title {
    flex: 1;
    min-width: 0;
    font-weight: 700;
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.block-sub {
    font-size: 12px;
    color: var(--txt-3);
    white-space: nowrap;
}

.del-btn {
    width: 32px;
    height: 32px;
    flex: none;
    border: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: none;
    color: var(--txt-3);
    font-size: 15px;
}

@media (hover: hover) {
    .del-btn:hover {
        background: var(--danger-soft);
        color: var(--danger);
    }
}

.block-clips {
    padding: 0 10px 8px 38px;
}

.clip-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 0;
    font-size: 13.5px;
    border-radius: 10px;
}

.clip-item .grip {
    width: 26px;
    height: 30px;
    font-size: 14px;
}

.clip-item .clip-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.clip-item .clip-meta {
    font-size: 12px;
    color: var(--txt-3);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.clip-item .del-btn {
    width: 28px;
    height: 28px;
    font-size: 13px;
}

/* ブランク（曲間のすき間）は細い区切りとして見せる */
.block.blank {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 8px 2px 4px;
    background: none;
    box-shadow: none;
}

.block.blank .blank-line {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--txt-3);
}

.block.blank .blank-line::before,
.block.blank .blank-line::after {
    content: "";
    flex: 1;
    border-top: 1.5px dashed var(--fill-strong);
}

.drop-line {
    height: 3px;
    margin: -1px 6px 6px;
    border-radius: 2px;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
}

.clip-item + .drop-line,
.block-clips > .drop-line {
    margin: 1px 0;
}

#ghost {
    position: fixed;
    z-index: 300;
    pointer-events: none;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 650;
    background: var(--accent);
    color: var(--on-accent);
    box-shadow: var(--shadow-lift);
    transform: translate(-50%, -130%);
    white-space: nowrap;
    max-width: 70vw;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.is-dragging,
body.is-dragging * {
    cursor: grabbing !important;
    user-select: none;
    -webkit-user-select: none;
}

/* 構成パネルが受け取れるときの合図（ライブラリからドラッグ中） */
.panel.drop-target {
    box-shadow: var(--shadow-glass), 0 0 0 2px var(--accent);
}

/* 空のとき */
.empty {
    display: grid;
    justify-items: center;
    gap: 8px;
    text-align: center;
    padding: 40px 16px;
    color: var(--txt-2);
    font-size: 14px;
}

.empty .ico {
    font-size: 34px;
    color: var(--txt-3);
    margin-bottom: 4px;
}

.empty strong {
    color: var(--txt);
    font-size: 15.5px;
}

.empty p {
    margin: 0;
    max-width: 340px;
}

/* ===== 生成バー ===== */
.gen-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    margin-top: 6px;
    border-radius: 999px;
    background: var(--fill);
    flex: none;
}

.out-field {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 12px;
}

.out-field span {
    font-size: 12px;
    font-weight: 600;
    color: var(--txt-3);
    white-space: nowrap;
}

.out-field input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: none;
    font-size: 15px;
    font-weight: 600;
}

.primary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 22px;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 8px 20px -8px var(--accent);
}

.primary-btn:disabled {
    opacity: 0.55;
    cursor: default;
}

.primary-btn .spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-right-color: transparent;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.pill-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    background: var(--fill);
    color: var(--txt);
    font-size: 14.5px;
    font-weight: 650;
    white-space: nowrap;
}

.pill-btn.accent {
    background: var(--accent);
    color: var(--on-accent);
}

.pill-btn.danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.pill-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

/* ===== タブバー（モバイルだけ） ===== */
.tabbar {
    display: none;
}

/* ===== シート ===== */
.sheet-root {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
}

.sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgb(0 0 0 / 0.38);
    opacity: 0;
    transition: opacity 320ms var(--ease);
}

[data-theme="light"] .sheet-backdrop {
    background: rgb(20 20 40 / 0.22);
}

.sheet-root.open .sheet-backdrop {
    opacity: 1;
}

.sheet {
    position: relative;
    width: min(560px, 100%);
    max-height: min(820px, calc(100dvh - 48px));
    display: flex;
    flex-direction: column;
    border-radius: var(--r-3xl);
    background: rgb(var(--glass-rgb) / var(--sheet-a));
    -webkit-backdrop-filter: blur(44px) saturate(190%);
    backdrop-filter: blur(44px) saturate(190%);
    overflow: hidden;
    opacity: 0;
    transform: translateY(18px) scale(0.97);
    transition: transform 380ms var(--ease), opacity 260ms var(--ease);
}

.sheet-root.open .sheet {
    opacity: 1;
    transform: none;
}

.sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 16px 10px 24px;
}

.sheet-head h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
}

.sheet-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 20px 22px;
}

.group {
    margin-bottom: 22px;
}

.group-title {
    margin: 0 4px 8px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--txt-3);
    letter-spacing: 0.04em;
}

.group-box {
    border-radius: var(--r-lg);
    background: var(--fill);
    overflow: hidden;
}

.row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 50px;
    padding: 8px 14px;
    font-size: 14.5px;
}

.row + .row {
    border-top: 1px solid var(--sep);
}

.row .row-main {
    flex: 1;
    min-width: 0;
}

.row .row-title {
    display: block;
    overflow-wrap: anywhere;
}

.row .row-sub {
    display: block;
    font-size: 12px;
    color: var(--txt-3);
}

.row input[type="text"],
.row input[type="password"] {
    flex: 1;
    min-width: 0;
    height: 36px;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: rgb(var(--glass-rgb) / 0.7);
    outline: 0;
    font-size: 14px;
}

.row .chip-btn {
    flex: none;
}

.note {
    margin: 8px 6px 0;
    font-size: 12.5px;
    color: var(--txt-3);
}

.seg {
    display: flex;
    gap: 2px;
    padding: 3px;
    border-radius: 999px;
    background: var(--fill);
}

.seg-btn {
    flex: 1;
    border: 0;
    background: transparent;
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--txt-2);
    white-space: nowrap;
    transition: background-color 250ms var(--ease), color 250ms, box-shadow 250ms;
}

.seg-btn[aria-pressed="true"] {
    background: var(--seg-thumb);
    color: var(--txt);
    box-shadow: 0 3px 10px -2px rgb(0 0 0 / 0.18), inset 0 0 0 0.5px var(--rim-weak);
}

.dropzone {
    display: grid;
    justify-items: center;
    gap: 6px;
    padding: 20px 16px;
    margin-top: 10px;
    border-radius: var(--r-lg);
    border: 1.5px dashed var(--fill-strong);
    color: var(--txt-2);
    font-size: 13.5px;
    text-align: center;
    cursor: pointer;
    transition: border-color 200ms, background-color 200ms;
}

.dropzone .ico {
    font-size: 24px;
    color: var(--accent);
}

.dropzone.over {
    border-color: var(--accent);
    background: var(--accent-soft);
}

/* 生成結果 */
.result-hero {
    display: grid;
    justify-items: center;
    gap: 6px;
    text-align: center;
    padding: 6px 0 18px;
}

.result-hero .check {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 28px;
    background: var(--teal-soft);
    color: var(--teal);
    margin-bottom: 4px;
}

.result-hero strong {
    font-size: 17px;
    overflow-wrap: anywhere;
}

.result-hero span {
    font-size: 13px;
    color: var(--txt-3);
}

.actions {
    display: grid;
    gap: 8px;
}

.steps {
    margin: 0;
    padding: 0 0 0 4px;
    list-style: none;
    counter-reset: step;
    display: grid;
    gap: 10px;
    font-size: 13.5px;
    color: var(--txt-2);
}

.steps li {
    display: flex;
    gap: 10px;
    counter-increment: step;
}

.steps li::before {
    content: counter(step);
    width: 22px;
    height: 22px;
    flex: none;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    background: var(--accent-soft);
    color: var(--accent);
}

.steps code,
.mono {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 12.5px;
    overflow-wrap: anywhere;
}

.warn {
    border-radius: var(--r-md);
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 13px;
    background: var(--warm-soft);
    color: var(--warm);
}

.warn ul {
    margin: 4px 0 0;
    padding-left: 18px;
}

/* ===== トースト ===== */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--safe-bottom) + 28px);
    z-index: 200;
    max-width: calc(100% - 32px);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px 8px 18px;
    min-height: 46px;
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 550;
    background: rgb(var(--glass-rgb) / var(--sheet-a));
    transform: translate(-50%, 12px) scale(0.94);
    opacity: 0;
    pointer-events: none;
    transition: transform 260ms var(--spring), opacity 200ms;
}

.toast.show {
    transform: translate(-50%, 0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.toast span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toast button {
    flex: none;
    border: 0;
    border-radius: 999px;
    padding: 7px 14px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
}

.toast:not(:has(button:not([hidden]))) {
    padding-right: 18px;
}

/* ===== 中くらいの画面（iPad 縦など） ===== */
@media (max-width: 1099px) {
    .workspace {
        grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
        gap: 12px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .brand-name,
    .status-chip {
        display: none;
    }
}

/* ===== モバイル ===== */
@media (max-width: 760px) {
    :root {
        --bar-h: 52px;
        --top-space: calc(var(--safe-top) + 10px + var(--bar-h) + 12px);
        --tab-h: 62px;
    }

    .topbar {
        left: 10px;
        right: 10px;
    }

    .topbar-inner {
        padding: 0 6px;
        gap: 6px;
    }

    .brand {
        display: none;
    }

    .project-pill {
        flex: 1;
        height: 40px;
        background: none;
        padding-left: 12px;
    }

    .project-pill .pill-label {
        display: none;
    }

    .project-pill strong {
        font-size: 16px;
        font-weight: 700;
    }

    .topbar-actions {
        margin-left: 0;
    }

    .workspace {
        display: block;
        height: auto;
        min-height: 100dvh;
        padding: var(--top-space) 12px calc(var(--safe-bottom) + var(--tab-h) + 40px);
    }

    /* パネルは片方ずつ。壁紙の上に直接カードを並べる */
    .panel {
        padding: 0;
        background: none;
        box-shadow: none;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        border-radius: 0;
    }

    .panel::after {
        display: none;
    }

    .workspace[data-tab="library"] #arrPanel,
    .workspace[data-tab="arrangement"] #libraryPanel {
        display: none;
    }

    .panel-head {
        padding: 2px 6px 10px;
    }

    .panel-head h2 {
        font-size: 26px;
    }

    .scroll {
        overflow: visible;
        margin: 0;
        padding: 0;
    }

    .search-field {
        position: sticky;
        top: var(--top-space);
        z-index: 20;
        height: 44px;
        background: rgb(var(--glass-rgb) / var(--glass-bar-a));
        -webkit-backdrop-filter: blur(30px) saturate(180%);
        backdrop-filter: blur(30px) saturate(180%);
        box-shadow: var(--shadow-glass), inset 0 0 0 1px var(--rim-weak);
    }

    .search-field kbd {
        display: none;
    }

    .song,
    .block:not(.blank) {
        background: rgb(var(--glass-rgb) / var(--card-solid-a));
    }

    .add-btn {
        width: 40px;
        height: 40px;
    }

    .clip-row .add-btn {
        width: 36px;
        height: 36px;
    }

    .grip {
        width: 36px;
        height: 40px;
    }

    .block-clips {
        padding-left: 30px;
    }

    .del-btn {
        width: 36px;
        height: 36px;
    }

    .clip-item .del-btn {
        width: 34px;
        height: 34px;
    }

    .head-actions .chip-btn {
        height: 36px;
    }

    /* スマホでは「戻す」「やり直す」はアイコンだけ。ブランクは意味が伝わらないので文字を残す */
    .head-actions .chip-btn:not(#addBlankBtn) .label {
        display: none;
    }

    .head-actions .chip-btn:not(#addBlankBtn) {
        width: 36px;
        padding: 0;
        justify-content: center;
    }

    .toast span {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        line-height: 1.35;
    }

    .toast {
        border-radius: 24px;
    }

    /* 生成バーはタブバーのすぐ上に浮かせる */
    .gen-bar {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: calc(var(--safe-bottom) + var(--tab-h) + 22px);
        z-index: 45;
        max-width: 560px;
        margin: 0 auto;
        background: rgb(var(--glass-rgb) / var(--glass-bar-a));
        -webkit-backdrop-filter: blur(30px) saturate(180%);
        backdrop-filter: blur(30px) saturate(180%);
        box-shadow: var(--shadow-glass), inset 0 0 0 1px var(--rim-weak);
    }

    .workspace[data-tab="arrangement"] {
        padding-bottom: calc(var(--safe-bottom) + var(--tab-h) + 110px);
    }

    .tabbar {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: calc(var(--safe-bottom) + 12px);
        z-index: 50;
        display: flex;
        gap: 4px;
        padding: 6px;
        border-radius: 999px;
        max-width: 420px;
        margin: 0 auto;
    }

    .tab {
        position: relative;
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 7px 0 6px;
        border: 0;
        border-radius: 999px;
        background: none;
        color: var(--txt-3);
        transition: color 300ms, background-color 300ms;
    }

    .tab .ico {
        font-size: 23px;
    }

    .tab-label {
        font-size: 10.5px;
        font-weight: 650;
    }

    .tab[aria-selected="true"] {
        color: var(--accent);
        background: var(--accent-soft);
    }

    .tab-badge {
        position: absolute;
        top: 3px;
        left: calc(50% + 8px);
        min-width: 19px;
        height: 19px;
        padding: 0 5px;
        border-radius: 999px;
        display: grid;
        place-items: center;
        font-size: 11px;
        font-weight: 700;
        background: var(--accent);
        color: var(--on-accent);
    }

    .tab-badge:empty {
        display: none;
    }

    .toast {
        bottom: calc(var(--safe-bottom) + var(--tab-h) + 28px);
    }

    .workspace[data-tab="arrangement"] ~ .toast {
        bottom: calc(var(--safe-bottom) + var(--tab-h) + 92px);
    }

    /* 下から出るシート */
    .sheet-root {
        place-items: end center;
        padding: 0 8px calc(var(--safe-bottom) + 8px);
    }

    .sheet {
        width: 100%;
        max-height: calc(100dvh - var(--safe-top) - 40px);
        border-radius: var(--r-3xl);
        transform: translateY(100%);
    }

    .sheet-body {
        padding: 4px 16px 20px;
    }
}

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