            /* ---------- row height variants ---------- */
            .g-rh-medium .g-cell {
                height: 48px;
            }
            .g-rh-tall .g-cell {
                height: auto;
                min-height: 80px;
                align-items: flex-start;
                padding-top: 8px;
                padding-bottom: 8px;
                white-space: normal;
            }
            .g-rh-tall .g-cell .txt {
                white-space: normal;
                display: -webkit-box;
                -webkit-line-clamp: 4;
                -webkit-box-orient: vertical;
                overflow: hidden;
            }
            .g-rh-tall .g-row {
                align-items: stretch;
            }
            .g-rh-medium .g-handle,
            .g-rh-tall .g-handle {
                align-items: flex-start;
                padding-top: 9px;
            }

            /* ---------- row drag reorder ---------- */
            .g-row.row-dragging {
                opacity: 0.4;
            }
            .g-row .g-handle {
                cursor: grab;
            }
            .drop-indicator {
                height: 2px;
                background: var(--accent);
                width: 100%;
                position: relative;
                z-index: 40;
                box-shadow: 0 0 0 1px var(--accent);
            }

            /* ---------- context menu (reuses .pop styling) ---------- */
            .ctxmenu {
                position: fixed;
                z-index: 130;
            }

            @media (prefers-reduced-motion: reduce) {
                * {
                    transition: none !important;
                    animation: none !important;
                }
            }

            /* ---------- app shell visibility ---------- */
            body.home-mode #viewbar,
            body.home-mode #gridwrap,
            body.home-mode #addTableBtn,
            body.home-mode #tabs {
                display: none !important;
            }
            body.home-mode .basename {
                display: none !important;
            }
            #home {
                display: none;
                flex: 1;
                overflow: auto;
                background: var(--bg);
            }
            body.home-mode #home {
                display: block;
            }
            .home-wrap {
                max-width: 980px;
                margin: 0 auto;
                padding: 40px 24px 80px;
            }
            .home-head {
                display: flex;
                align-items: flex-end;
                gap: 14px;
                margin-bottom: 26px;
                flex-wrap: wrap;
            }
            .home-head h1 {
                font-family: "Instrument Serif", Georgia, serif;
                font-style: italic;
                font-weight: 400;
                font-size: 34px;
                color: var(--ink);
                line-height: 1;
            }
            .home-head .sub {
                color: var(--faint);
                font-size: 13px;
                margin-bottom: 3px;
            }
            .home-actions {
                margin-left: auto;
                display: flex;
                gap: 8px;
            }
            .basegrid {
                display: grid;
                grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
                gap: 14px;
            }
            .basecard {
                position: relative;
                background: var(--paper);
                border: 1px solid var(--line);
                border-radius: 12px;
                padding: 16px;
                cursor: pointer;
                transition:
                    box-shadow 0.12s,
                    border-color 0.12s,
                    transform 0.12s;
                display: flex;
                flex-direction: column;
                gap: 10px;
                min-height: 130px;
            }
            .basecard:hover {
                border-color: var(--line2);
                box-shadow: var(--shadow);
                transform: translateY(-1px);
            }
            .basecard .bc-top {
                display: flex;
                align-items: center;
                gap: 10px;
            }
            .basecard .bc-icon {
                width: 42px;
                height: 42px;
                border-radius: 10px;
                display: grid;
                place-items: center;
                font-size: 22px;
                flex: 0 0 auto;
                color: #fff;
            }
            .basecard .bc-name {
                font-weight: 700;
                font-size: 15px;
                color: var(--ink);
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
                flex: 1;
            }
            .basecard .bc-meta {
                color: var(--faint);
                font-size: 12px;
                margin-top: auto;
            }
            .basecard .bc-counts {
                display: flex;
                gap: 12px;
                color: var(--mut);
                font-size: 12.5px;
            }
            .basecard .bc-counts b {
                color: var(--ink);
                font-variant-numeric: tabular-nums;
            }
            .basecard .bc-menu {
                position: absolute;
                top: 10px;
                right: 8px;
                width: 26px;
                height: 26px;
                border-radius: 6px;
                color: var(--faint);
                display: grid;
                place-items: center;
                font-size: 16px;
                opacity: 0;
            }
            .basecard:hover .bc-menu {
                opacity: 1;
            }
            .basecard .bc-menu:hover {
                background: var(--hover);
                color: var(--ink);
            }
            .basecard.newcard {
                align-items: center;
                justify-content: center;
                border-style: dashed;
                color: var(--mut);
                gap: 6px;
            }
            .basecard.newcard:hover {
                color: var(--ink);
                border-color: var(--accent-border);
                transform: none;
            }
            .basecard.newcard .plus {
                font-size: 26px;
            }
            .home-empty {
                text-align: center;
                padding: 70px 20px;
                color: var(--mut);
            }
            .home-empty .big {
                font-size: 17px;
                color: var(--ink);
                font-weight: 600;
                margin-bottom: 6px;
            }
            .home-drop {
                outline: 2px dashed var(--accent-border);
                outline-offset: -10px;
            }

            /* ---------- CSV drop overlay (in-base grid) ---------- */
            .csv-drop {
                position: absolute;
                inset: 0;
                z-index: 60;
                display: none;
                place-items: center;
                background: color-mix(in srgb, var(--bg) 78%, transparent);
                backdrop-filter: blur(1px);
            }
            .csv-drop.on {
                display: grid;
            }
            .csv-drop-card {
                pointer-events: none;
                border: 2px dashed var(--accent-border);
                background: var(--paper);
                border-radius: 14px;
                padding: 30px 46px;
                text-align: center;
                box-shadow: var(--shadow);
            }
            .csv-drop-ic {
                font-size: 30px;
                color: var(--accent-border);
                margin-bottom: 6px;
            }
            .csv-drop-title {
                font-weight: 700;
                font-size: 16px;
                color: var(--ink);
            }
            .csv-drop-sub {
                color: var(--mut);
                font-size: 12.5px;
                margin-top: 4px;
            }

            /* ---------- import modal / preview ---------- */
            .import-modal {
                width: min(94vw, 920px) !important;
            }
            .import-body {
                display: flex;
                flex-direction: column;
                gap: 12px;
            }
            .import-controls {
                display: flex;
                align-items: flex-end;
                gap: 16px;
                flex-wrap: wrap;
            }
            .imp-ctl {
                display: flex;
                flex-direction: column;
                gap: 4px;
            }
            .imp-lab {
                font-size: 11px;
                font-weight: 600;
                color: var(--mut);
                text-transform: uppercase;
                letter-spacing: 0.3px;
            }
            .imp-ctl-chk {
                display: flex;
                align-items: center;
                gap: 6px;
                font-size: 12.5px;
                color: var(--ink);
                cursor: pointer;
                padding-bottom: 6px;
            }
            .imp-ctl-chk.disabled {
                opacity: 0.45;
            }
            .imp-modes {
                flex-direction: row;
                gap: 14px;
                align-items: center;
            }
            .imp-count {
                color: var(--mut);
                font-size: 12px;
                font-weight: 600;
                padding-bottom: 6px;
            }
            .imp-hint {
                font-size: 12px;
                color: var(--mut);
            }
            .import-preview {
                overflow: auto;
                border: 1px solid var(--line);
                border-radius: 8px;
                max-height: min(48vh, 440px);
                background: var(--paper);
            }
            .import-table {
                border-collapse: separate;
                border-spacing: 0;
                width: max-content;
                min-width: 100%;
                font-size: 12.5px;
            }
            .import-table thead th {
                position: sticky;
                top: 0;
                background: var(--head-bg);
                z-index: 2;
            }
            .import-table thead tr:nth-child(2) th {
                top: 42px;
            }
            .imp-th {
                border-right: 1px solid var(--line);
                border-bottom: 1px solid var(--line2);
                padding: 5px 6px;
                vertical-align: top;
                text-align: left;
                min-width: 130px;
                background: var(--head-bg);
            }
            .imp-namewrap {
                display: flex;
                align-items: center;
                gap: 4px;
            }
            .imp-prim {
                flex: 0 0 auto;
                color: var(--faint);
                font-size: 14px;
                line-height: 1;
                width: 20px;
            }
            .imp-prim.on {
                color: var(--accent-border);
            }
            .imp-name,
            .imp-type,
            .imp-map,
            .imp-newtype {
                width: 100%;
                font-size: 12px;
                padding: 4px 5px;
            }
            .imp-type,
            .imp-newtype {
                margin-top: 4px;
            }
            .imp-mapwrap {
                display: flex;
                flex-direction: column;
                gap: 4px;
            }
            .imp-srcname {
                font-weight: 600;
                color: var(--ink);
                padding: 2px 2px 4px;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }
            .imp-td {
                border-right: 1px solid var(--line);
                border-bottom: 1px solid var(--line);
                padding: 4px 7px;
                color: var(--ink);
                max-width: 220px;
            }
            .imp-cell {
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
                max-width: 210px;
            }

            /* ---------- emoji / color pickers ---------- */
            .emojipick {
                display: grid;
                grid-template-columns: repeat(8, 1fr);
                gap: 4px;
                max-height: 150px;
                overflow: auto;
            }
            .emojipick button {
                font-size: 18px;
                padding: 5px;
                border-radius: 6px;
                line-height: 1;
            }
            .emojipick button:hover {
                background: var(--hover);
            }
            .emojipick button.sel {
                background: var(--accent);
            }
            .colorpick {
                display: flex;
                gap: 8px;
                flex-wrap: wrap;
            }
            .colorpick .sw {
                width: 26px;
                height: 26px;
                border-radius: 7px;
                cursor: pointer;
                border: 2px solid transparent;
                transition: none;
            }
            .colorpick .sw.sel {
                border-color: var(--ink);
                box-shadow: 0 0 0 2px var(--paper) inset;
            }
            .tpl-grid {
                display: grid;
                gap: 6px;
            }

            /* ---------- settings ---------- */
            .set-section {
                margin-bottom: 22px;
            }
            .set-section > h3 {
                font-size: 11px;
                font-weight: 700;
                text-transform: uppercase;
                letter-spacing: 0.06em;
                color: var(--faint);
                margin-bottom: 10px;
            }
            .set-row {
                display: flex;
                align-items: center;
                gap: 12px;
                padding: 7px 0;
            }
            .set-row .lab {
                font-weight: 500;
                flex: 1;
            }
            .set-row .lab .hint {
                display: block;
                color: var(--faint);
                font-size: 11.5px;
                font-weight: 400;
                margin-top: 2px;
            }
            .set-row select.tin,
            .set-row input.tin {
                width: auto;
                min-width: 160px;
            }
            .seg {
                display: inline-flex;
                border: 1px solid var(--line2);
                border-radius: 7px;
                overflow: hidden;
            }
            .seg button {
                padding: 5px 12px;
                font-size: 12.5px;
                font-weight: 500;
                color: var(--mut);
                border-right: 1px solid var(--line2);
            }
            .seg button:last-child {
                border-right: 0;
            }
            .seg button.on {
                background: var(--sel);
                color: var(--sel-tx);
            }
            .meter {
                height: 10px;
                border-radius: 999px;
                background: var(--meter-track);
                overflow: hidden;
                margin: 6px 0 4px;
            }
            .meter > span {
                display: block;
                height: 100%;
                background: var(--accent);
                border-radius: 999px;
            }
            .pillstat {
                display: inline-flex;
                align-items: center;
                gap: 5px;
                padding: 2px 9px;
                border-radius: 999px;
                font-size: 12px;
                font-weight: 600;
            }
            .pillstat.ok {
                background: var(--tint-filter-bg);
                color: var(--tint-filter-tx);
            }
            .pillstat.no {
                background: var(--danger-bg);
                color: var(--danger-tx);
            }
            .pillstat.na {
                background: var(--tint-hide-bg);
                color: var(--tint-hide-tx);
            }
            .warnline {
                color: var(--mut);
                font-size: 12px;
                margin-top: 8px;
                line-height: 1.5;
            }
            .backup-row {
                display: flex;
                align-items: center;
                gap: 10px;
                padding: 8px 10px;
                border: 1px solid var(--line);
                border-radius: 8px;
                margin-bottom: 6px;
            }
            .backup-row .bk-info {
                flex: 1;
                overflow: hidden;
            }
            .backup-row .bk-when {
                font-weight: 600;
                font-size: 12.5px;
            }
            .backup-row .bk-sub {
                color: var(--faint);
                font-size: 11.5px;
            }
            .backup-row .btn {
                padding: 4px 9px;
                font-size: 11.5px;
            }
            .trash-ic {
                width: 30px;
                height: 30px;
                flex-shrink: 0;
                display: grid;
                place-items: center;
                border-radius: 7px;
                background: var(--hover);
                color: var(--mut);
                font-size: 15px;
            }

            /* ===== record history panel (expand modal) ===== */
            .rh-section {
                margin-top: 8px;
                border-top: 1px solid var(--line);
                padding-top: 12px;
            }
            .rh-head {
                display: flex;
                align-items: center;
                gap: 6px;
                width: 100%;
                font-size: 11.5px;
                font-weight: 700;
                text-transform: uppercase;
                letter-spacing: 0.06em;
                color: var(--faint);
                cursor: pointer;
                user-select: none;
            }
            .rh-head .rh-caret {
                transition: transform 0.12s ease;
                font-size: 9px;
            }
            .rh-head.open .rh-caret {
                transform: rotate(90deg);
            }
            .rh-head .rh-count {
                margin-left: auto;
                font-weight: 600;
                color: var(--faint);
                font-size: 11px;
            }
            .rh-list {
                margin-top: 10px;
            }
            .rh-row {
                display: flex;
                align-items: flex-start;
                gap: 10px;
                padding: 8px 0;
                border-bottom: 1px solid var(--line);
            }
            .rh-row:last-child {
                border-bottom: 0;
            }
            .rh-main {
                flex: 1;
                min-width: 0;
            }
            .rh-field {
                font-size: 12.5px;
                font-weight: 600;
                color: var(--ink);
            }
            .rh-when {
                font-size: 11px;
                color: var(--faint);
                margin-top: 1px;
            }
            .rh-delta {
                font-size: 12px;
                color: var(--mut);
                margin-top: 4px;
                line-height: 1.45;
                word-break: break-word;
            }
            .rh-delta .rh-from {
                color: var(--faint);
                text-decoration: line-through;
            }
            .rh-delta .rh-to {
                color: var(--ink);
            }
            .rh-delta .rh-arrow {
                color: var(--faint);
                margin: 0 5px;
            }
            .rh-empty {
                font-size: 12px;
                color: var(--mut);
                padding: 8px 0;
            }
            .rh-revert {
                padding: 3px 9px;
                font-size: 11px;
                flex-shrink: 0;
            }

