/* Repertoire studio (board page) — mirrors the React BoardPage light theme. */
.studio {
    display: flex; flex-direction: column; flex: 1; width: 100%; height: calc(100dvh - 64px); min-height: 480px; background: #fff; color: #1c1917; border-bottom: 1px solid var(--s-border); }
body:has(.studio) .site-footer { margin-top: 0; }
.studio .mono, .studio .chip, .studio .branch-move, .studio .tag, .studio .turn, .studio .eyebrow-accent { font-family: ui-monospace, Consolas, monospace; }
.studio .small { font-size: 11px; }
.studio .muted { color: var(--s-muted); }
.studio .sans { font-family: 'Segoe UI', Arial, sans-serif; }
.studio .accent { color: var(--s-accent-2); }
.studio .amber { color: #f59e0b; }
.studio .indigo { color: #818cf8; }
.studio button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.studio-empty { padding: 80px 24px; text-align: center; }

.studio-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 24px; background: #f9f9f8; border-bottom: 1px solid var(--s-border); }
.studio-title { display: flex; align-items: center; gap: 12px; }
.studio-glyph { font-size: 24px; line-height: 1; opacity: .8; color: var(--s-accent); user-select: none; }
.studio-primary { font-family: var(--serif, Georgia, serif); font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.studio-secondary { font-size: 12px; color: var(--s-muted); margin-top: 2px; }
.studio-secondary strong { font-weight: 500; color: #059669; }
.studio-actions { display: flex; align-items: center; gap: 8px; }
.pill-group { display: flex; padding: 2px; border: 1px solid var(--s-border); border-radius: 8px; background: var(--s-soft); }
.pill-group button { padding: 4px 10px; font-size: 12px; font-weight: 500; border-radius: 4px; color: var(--s-muted); }
.pill-group button.active { background: var(--s-accent); color: #fff; }
.icon-pill { padding: 4px 8px !important; border: 1px solid var(--s-border) !important; border-radius: 8px; background: var(--s-soft) !important; font-size: 15px; }

.studio-grid { display: grid; grid-template-columns: minmax(220px, 320px) minmax(0, 1fr) minmax(260px, 380px); flex: 1; min-height: 0; }
.studio-grid > section { padding: 20px; min-height: 0; overflow-y: auto; }
.studio-left { display: flex; flex-direction: column; justify-content: space-between; gap: 16px; background: #fafaf9; border-right: 1px solid var(--s-border); }
.studio-grid > .studio-left { padding-right: 0; }
.studio-left > div:first-child { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.studio-left > div:first-child > :not(.branches), .studio-left > .studio-stats { margin-right: 20px; }
.studio-left .branches { padding-right: 20px; }
.studio-center { container-type: size; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px !important; overflow: hidden !important; }
.studio-center > * { --board-size: min(100cqw, calc(100cqh - 40px), 1024px); }
.studio-right { background: #fafaf9; border-left: 1px solid var(--s-border); display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 1023px) {
    .studio { height: auto; }
    .studio-grid { grid-template-columns: 1fr; }
    .studio-grid > section { overflow: visible; }
    .studio-center { container-type: inline-size; overflow: visible !important; }
    .studio-center > * { --board-size: min(100cqw, 80vh); }
    .studio-left, .studio-right { border: 0; border-bottom: 1px solid var(--s-border); }
}

.section-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 8px; margin-bottom: 12px; border-bottom: 1px solid var(--s-border); }
.section-label { font-size: 12px; font-weight: 500; color: var(--s-muted); text-transform: uppercase; letter-spacing: .08em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }

.btn-share { position: relative; display: inline-flex; align-self: flex-start; align-items: center; justify-content: center; margin-top: 8px; padding: 6px; color: var(--s-accent); border: 1px solid var(--s-muted); border-radius: 6px; background: transparent; cursor: pointer; }
.btn-share:disabled { cursor: default; border-color: rgba(87,83,78,.5); }
.btn-share:disabled svg { opacity: .5; }
.btn-share::after, .copy-link-btn::after {
    content: attr(data-tooltip); position: absolute; top: calc(100% + 8px); left: 0; z-index: 50;
    width: max-content; max-width: 220px; padding: 6px 10px; border-radius: 6px;
    background: #1c1917; color: #fff; font: 500 12px/1.4 'Segoe UI', Arial, sans-serif;
    text-align: left; box-shadow: 0 4px 12px rgba(0,0,0,.18);
    pointer-events: none; visibility: hidden;
}
.btn-share::before, .copy-link-btn::before {
    content: ""; position: absolute; top: calc(100% + 2px); left: 10px; z-index: 50;
    border: 6px solid transparent; border-top: 0; border-bottom-color: #1c1917;
    pointer-events: none; visibility: hidden;
}
.btn-share:hover::after, .btn-share:hover::before,
.btn-share:focus-visible::after, .btn-share:focus-visible::before,
.copy-link-btn:hover::after, .copy-link-btn:hover::before,
.copy-link-btn:focus-visible::after, .copy-link-btn:focus-visible::before { visibility: visible; }
.branches-head {
    display: flex; justify-content: space-between; font-size: 12px; font-weight: 500;
    color: var(--s-muted); margin: 8px 0 8px;
}
.branches { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; overflow-y: auto; padding-right: 4px; }
@media (max-width: 1023px) { .branches { flex: none; contain: none; max-height: 340px; } }
.branches-empty { font-size: 12px; font-style: italic; color: var(--s-muted); padding: 12px; text-align: center; border: 1px dashed var(--s-border); border-radius: 8px; margin: 0; }
.branch-card { cursor: pointer; padding: 10px; border-radius: 12px; background: var(--s-card); border: 1px solid var(--s-border); box-shadow: 0 1px 1px rgba(0,0,0,.03); transition: background .15s; }
.branch-card:hover { background: #fafaf9; }
.branch-row, .defense-card { display: flex; align-items: center; gap: 8px; }
.branch-move { font-weight: 700; font-size: 14px; color: var(--s-accent); white-space: nowrap; }
.branch-move.small { font-size: 12px; }
.branch-name { font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.tag { font-size: 10px; padding: 2px 6px; border-radius: 4px; background: var(--s-soft); color: var(--s-muted); }
.tag.tiny { font-size: 9px; }
.branch-note { font-size: 11px; color: var(--s-muted); margin: 4px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.defenses { margin: 0 0 8px 12px; padding-left: 10px; border-left: 2px solid rgba(16,185,129,.4); display: flex; flex-direction: column; gap: 6px; }
.defenses-head { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; font-family: ui-monospace, Consolas, monospace; color: var(--s-muted); display: flex; align-items: center; gap: 6px; padding-top: 2px; }
.defenses-head .dot { width: 6px; height: 6px; border-radius: 50%; background: #34d399; }
.defense-card { cursor: pointer; padding: 8px; border-radius: 8px; background: var(--s-card); border: 1px solid var(--s-border); }
.defense-card:hover { border-color: rgba(16,185,129,.5); }
.studio-stats { padding-top: 12px; border-top: 1px solid var(--s-border); font-size: 12px; font-weight: 500; color: var(--s-muted); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.arrows-toggle { display: inline-flex; align-items: center; gap: 6px; margin: 0; cursor: pointer; user-select: none; }
.arrows-toggle input { cursor: pointer; }

.board-top { width: var(--board-size); min-width: 280px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 14px; }
.turn { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.turn-dot { width: 10px; height: 10px; border-radius: 50%; background: #fbbf24; display: inline-block; animation: studio-pulse 2s infinite; }
.turn-dot.black { background: #1c1917; box-shadow: 0 0 0 1px #a8a29e; }
@keyframes studio-pulse { 50% { opacity: .5; } }

.studio-board { position: relative; width: var(--board-size); min-width: 280px; aspect-ratio: 1; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr)); border: 4px solid #292524; border-radius: 8px; overflow: hidden; box-shadow: 0 20px 25px -5px rgba(0,0,0,.15); background: #292524 var(--board-image, none) center / 100% 100% no-repeat; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.studio-board .sq { position: relative; display: flex; align-items: center; justify-content: center; padding: 0; border: 0; cursor: pointer; background: transparent; min-width: 0; min-height: 0; overflow: hidden; }
.studio-board .sq.last { background: rgba(245,215,80,.45); }
.studio-board .sq.selected { box-shadow: inset 0 0 0 4px rgba(16,185,129,.8); }
.studio-board .sq:has(.piece):hover:not(.selected) { box-shadow: inset 0 0 0 3px #fff; }
.studio-board .coord { position: absolute; font-size: 10px; font-weight: 600; opacity: .75; pointer-events: none; }
.studio-board .coord.rank { top: 2px; left: 3px; }
.studio-board .coord.file { bottom: 1px; right: 4px; }
.studio-board .sq.light .coord { color: #5b8a6b; }
.studio-board .sq.dark .coord { color: #ebe7dd; }
.studio-board .piece { position: absolute; inset: 6%; width: 88%; height: 88%; background: center / contain no-repeat; user-select: none; cursor: grab; z-index: 1; touch-action: none; }
.piece-ghost { position: fixed; pointer-events: none; background: center / contain no-repeat; z-index: 1000; }
.studio-board .piece.dragging { opacity: .35; }
body.piece-dragging, body.piece-dragging * { cursor: grabbing !important; }
.studio-board .hint { position: absolute; width: 28%; height: 28%; border-radius: 50%; background: rgba(28,25,23,.25); pointer-events: none; z-index: 2; transition: transform .15s ease-out; }
.studio-board .drag-over .hint:not(.capture) { transform: scale(1.35); }
.studio-board .hint.capture { width: 88%; height: 88%; background: none; border: 4px solid rgba(28,25,23,.3); }
.studio-board .move-arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.studio-board .move-arrow { opacity: .35; transition: opacity .15s ease-out; }
.studio-board .move-arrows.has-highlight .move-arrow.highlight { opacity: .75; }
.studio-board .move-arrow polyline { fill: none; stroke: var(--arrow-color, #2563eb); stroke-width: .18; stroke-linejoin: miter; }
.studio-board .move-arrow polygon { fill: var(--arrow-color, #2563eb); }
html.hide-move-arrows .studio-board .move-arrow:not(.highlight) { display: none; }
.promotion-overlay { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.55); }
.promotion-card { background: #fff; border-radius: 16px; padding: 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 12px; }
.promotion-card strong { font-family: var(--serif, Georgia, serif); font-size: 18px; }
.promotion-options { display: flex; gap: 8px; }
.promotion-options button { width: 56px; height: 56px; border-radius: 10px; background: #5b8a6b !important; }
.promotion-options .piece { display: block; cursor: pointer; width: 44px; height: 44px; background: center / contain no-repeat; }
.promotion-card .link { text-decoration: underline; color: #57534e; }

.eyebrow-accent { font-size: 12px; font-weight: 600; color: var(--s-accent-2); }
.move-title { font-family: var(--serif, Georgia, serif); font-size: 24px; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 2px 0 0; }
.name-chip { display: inline-flex; align-items: center; gap: 2px; height: 28px; max-width: 100%; min-width: 0; padding: 0 12px; border-radius: 999px; border: 1px solid #a7f3d0; background: #ecfdf5; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; font-weight: 600; letter-spacing: 0; line-height: 1; }
.move-name { color: #047857; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-actions { display: inline-flex; align-items: center; gap: 2px; margin-left: -4px; }
.name-actions .icon-btn { padding: 6px !important; border-radius: 999px; }
.studio .name-chip.empty { gap: 6px; height: 28px; padding: 0 12px; border: 1px dashed #d6d3d1; border-radius: 999px; background: #fafaf9; color: #78716c; font-family: 'Segoe UI', Arial, sans-serif; font-size: 12px; font-weight: 500; letter-spacing: 0; line-height: 1; transition: border-color .15s, color .15s, background .15s; }
.studio .name-chip.empty:hover, .studio .name-chip.empty:focus-visible { border-style: solid; border-color: #10b981; color: #047857; background: #ecfdf5; outline: none; }
.name-chip.empty svg { width: 12px; height: 12px; flex: none; }
.icon-btn { padding: 4px !important; border-radius: 999px; color: #a8a29e !important; font-size: 14px; align-self: center; font-family: sans-serif; display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.icon-btn svg { width: 14px; height: 14px; display: block; }
.icon-btn:hover { color: #10b981 !important; background: rgba(231,229,228,.5) !important; }
.icon-btn.danger:hover { color: #e11d48 !important; }
.branch-row .tag, .defense-card .tag { margin-left: auto; }
.bin-btn { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 0; height: 26px; margin-left: -8px; padding: 0; border: 0; border-radius: 999px; background: #fff1f2; color: #e11d48; overflow: hidden; opacity: 0; transform: scale(.6); cursor: pointer;
    transition: width .2s ease, margin-left .2s ease, opacity .2s ease, transform .2s ease, background .15s, box-shadow .15s; }
.branch-card:hover .bin-btn, .defense-card:hover .bin-btn, .bin-btn:focus-visible { width: 26px; margin-left: 0; opacity: 1; transform: scale(1); }
.bin-btn:hover { background: #e11d48; color: #fff; box-shadow: 0 2px 6px rgba(225,29,72,.35); }
.bin-btn:focus-visible { outline: 2px solid rgba(225,29,72,.4); outline-offset: 1px; }
@media (prefers-reduced-motion: reduce) { .bin-btn { transition: none; } }
.delete-pgn { margin: 0; padding: 10px 12px; max-height: 220px; overflow-y: auto; background: #fafaf9; border: 1px solid #e7e5e4; border-radius: 12px; line-height: 1.6; }
.delete-tree-prefix { color: #78716c; margin-bottom: 4px; }
.delete-tree, .delete-tree ul { list-style: none; margin: 0; padding: 0; }
.delete-tree ul { padding-left: 18px; }
.delete-tree li { position: relative; }
.delete-tree ul > li { padding-left: 14px; }
.delete-tree ul > li::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; border-left: 1px solid #d6d3d1; }
.delete-tree ul > li:last-child::before { bottom: auto; height: 0.8em; }
.delete-tree ul > li::after { content: ""; position: absolute; left: 0; top: 0.8em; width: 10px; border-top: 1px solid #d6d3d1; }
.delete-tree-move { display: inline-block; padding: 0 6px; border-radius: 6px; }
.delete-tree-root > .delete-tree-move { background: #fee2e2; color: #e11d48; font-weight: 600; }
.inline-edit { display: inline-flex; align-items: center; gap: 6px; align-self: center; font-family: 'Segoe UI', Arial, sans-serif; font-weight: 400; }
.inline-edit input, .note-input { padding: 4px 10px; font-size: 12px; border-radius: 6px; border: 1px solid rgba(16,185,129,.8); background: #fff; min-width: 160px; outline: none; }
.inline-edit input:focus, .note-input:focus { box-shadow: 0 0 0 1px #10b981; }
.studio .btn-save { padding: 4px 10px !important; font-family: 'Segoe UI', Arial, sans-serif; font-size: 12px; font-weight: 600; line-height: 1.4; border-radius: 6px; background: #059669 !important; color: #fff !important; }
.studio .btn-save:hover { background: #10b981 !important; }
.studio .btn-x, .studio .btn-link { padding: 2px 6px !important; font-family: 'Segoe UI', Arial, sans-serif; font-size: 12px; font-weight: 400; line-height: 1.4; color: var(--s-muted) !important; }
.studio .btn-x:hover { color: #1c1917 !important; }
.btn-link:hover { text-decoration: underline; }

.tabs { display: flex; gap: 4px; padding: 4px; background: rgba(231,229,228,.6); border: 1px solid var(--s-border); border-radius: 8px; }
.tabs button { flex: 1; padding: 6px 0 !important; font-size: 12px; font-weight: 500; border-radius: 4px; color: var(--s-muted) !important; }
.tabs button.active { background: #fff !important; color: #1c1917 !important; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.note-card { padding: 14px; border-radius: 12px; background: var(--s-card); border: 1px solid var(--s-border); }
.note-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 12px; }
.note-head strong { font-weight: 600; }
.note-input { width: 100%; padding: 6px 10px; border-radius: 8px; display: block; resize: none; overflow: hidden; field-sizing: content; min-height: 3.2em; font-family: inherit; line-height: 1.6; }
.note-help { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 10px; color: var(--s-muted); }
.note-text { font-size: 12px; line-height: 1.6; margin: 0; white-space: pre-wrap; }
.note-text.note-empty { color: var(--s-muted); font-style: italic; cursor: pointer; }
.note-divider { border: 0; border-top: 1px solid #e7e5e4; margin: 0; opacity: 1; }
.note-history { display: flex; flex-direction: column; gap: 12px; }

.studio-modal-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.7); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 16px; }
.studio-modal { background: #fff; color: #1c1917; border: 1px solid #e7e5e4; border-radius: 24px; box-shadow: 0 25px 50px -12px rgba(0,0,0,.25); max-width: 448px; width: 100%; padding: 28px; display: flex; flex-direction: column; gap: 16px; font-size: 14px; }
.studio-modal p { margin: 0; line-height: 1.6; }
.modal-head { display: flex; align-items: center; gap: 12px; color: #f43f5e; }
.modal-head h4 { font-family: var(--serif, Georgia, serif); font-size: 20px; font-weight: 700; margin: 0; color: #f43f5e; }
.modal-head .mono { font-family: ui-monospace, Consolas, monospace; opacity: .75; }
.modal-icon { flex: none; width: 44px; height: 44px; border-radius: 999px; background: linear-gradient(145deg, #fff1f2, #ffe4e6); border: 1px solid rgba(244,63,94,.25); color: #e11d48; box-shadow: 0 0 0 5px rgba(244,63,94,.08), 0 2px 6px rgba(225,29,72,.15); display: flex; align-items: center; justify-content: center; }
.modal-icon svg { width: 20px; height: 20px; }
.danger-text { color: #f43f5e; font-weight: 600; }
.shared-warning { padding: 12px; border-radius: 12px; background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); font-size: 12px; color: #b45309; }
.shared-warning strong { display: block; margin-bottom: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; padding-top: 12px; border-top: 1px solid #e7e5e4; }
.btn-muted, .btn-danger, .btn-accent { padding: 8px 16px; font-size: 12px; font-weight: 600; border-radius: 12px; border: 0; cursor: pointer; }
.btn-muted { background: #f5f5f4; }
.btn-danger { background: #e11d48; color: #fff; }
.btn-danger:hover { background: #f43f5e; }
.btn-accent { background: #244636; color: #fff; }

.studio-toast { position: fixed; bottom: 20px; right: 20px; z-index: 70; display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 12px; font-size: 12px; font-family: ui-monospace, Consolas, monospace; background: #ecfdf5; border: 1px solid #6ee7b7; color: #065f46; box-shadow: 0 10px 15px -3px rgba(0,0,0,.1); }
.studio-toast.error { background: #fff1f2; border-color: #fda4af; color: #9f1239; }
.studio-toast .dot { width: 8px; height: 8px; border-radius: 50%; background: #10b981; }
.studio-toast.error .dot { background: #f43f5e; }
.studio-toast button { background: none; border: 0; margin-left: 8px; color: #78716c; cursor: pointer; }
