@font-face {
    font-family: "CSA Corsiva";
    src: url("/branding/Monotype-Corsiva-Regular.ttf") format("truetype");
    font-display: swap;
}

@font-face {
    font-family: "CSA Century Gothic";
    src: url("/branding/Century-Gothic-Regular.ttf") format("truetype");
    font-display: swap;
}

@font-face {
    font-family: "CSA UI CJK";
    src: url("/fonts/noto-sans-sc-ui.woff2") format("woff2");
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
}

:root {
    --bg: #f3efe6;
    --panel: #ffffff;
    --panel-muted: #faf6ef;
    --ink: #1d1b16;
    --accent: #2a6f6b;
    --accent-strong: #1b4e4a;
    --border: #e2dacb;
    --app-height: 100dvh;
    --app-offset-top: 0px;
    --app-offset-bottom: 0px;
}

.loading-placeholder {
    background: #d2d5da;
    animation: loading-placeholder-pulse 1.35s ease-in-out infinite;
}

.loading-placeholder.is-hidden {
    opacity: 0;
    animation: none;
    pointer-events: none;
}

.localized-placeholder {
    display: inline-block;
    width: var(--placeholder-width, 7em);
    max-width: 100%;
    height: 0.78em;
    border-radius: 3px;
    vertical-align: baseline;
}

@keyframes loading-placeholder-pulse {
    0%, 100% { opacity: 0.42; }
    50% { opacity: 0.82; }
}

html, body, #app, .app-root {
    height: var(--app-height, 100dvh);
    min-height: var(--app-height, 100dvh);
    margin: 0;
}

html {
    overflow: hidden;
}

body {
    font-family: "Trebuchet MS", "Verdana", "CSA UI CJK", sans-serif;
    background: var(--bg);
    color: var(--ink);
    overflow: hidden;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    padding-top: 0;
    padding-bottom: 0;
}

.app-shell {
    height: var(--app-height, 100dvh);
    min-height: var(--app-height, 100dvh);
    display: flex;
    flex-direction: column;
    padding-top: calc(env(safe-area-inset-top, 0px) + var(--app-offset-top, 0px));
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--app-offset-bottom, 0px));
    box-sizing: border-box;
    position: relative;
}

.title-shell {
    --chart-drawer-height: 72vh;
    position: relative;
    z-index: 10;
}

.title-bar {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 40px;
    box-sizing: border-box;
    padding: 4px 16px 6px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}

.app-shell--chart-loaded .title-shell {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + var(--app-offset-top, 0px));
    right: 0;
    left: 0;
}

.title-bar--chart-loaded {
    background: rgba(255, 255, 255, 0.72);
    border-bottom-color: rgba(102, 112, 124, 0.24);
    -webkit-backdrop-filter: blur(8px) saturate(1.15);
    backdrop-filter: blur(8px) saturate(1.15);
}

.title-bar__name,
.title-bar__action {
    background: none;
    border: none;
    padding: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #1f5cff;
    cursor: pointer;
    text-decoration: none;
    line-height: 1;
}

.title-bar__name {
    flex: 1 1 auto;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: "CSA Corsiva", "Trebuchet MS", "Verdana", "CSA UI CJK", sans-serif;
    font-size: 1.3rem;
    min-width: 0;
}

.title-bar__action {
    flex: 0 0 auto;
}

.title-bar__progress {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 1 320px;
    min-width: 140px;
    justify-content: center;
    margin: 0 auto;
}

.title-bar__progress-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #4f4b43;
    white-space: nowrap;
}

.title-bar__progress-bar {
    position: relative;
    flex: 1 1 auto;
    height: 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.12);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-sizing: border-box;
    max-width: 240px;
}

.title-bar__progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: #4aa35d;
    border-radius: inherit;
    transition: width 160ms ease;
}

.title-bar__progress-text {
    position: relative;
    z-index: 1;
    font-size: 0.7rem;
    line-height: 1;
    color: #1d1b16;
    white-space: nowrap;
}

.title-bar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.title-bar__lang {
    position: relative;
}

.title-bar__lang-btn {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    border: 1px solid rgba(31, 92, 255, 0.25);
    background: rgba(31, 92, 255, 0.08);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #1f5cff;
    padding: 0;
}

.title-bar__lang-btn:hover {
    background: rgba(31, 92, 255, 0.16);
}

.title-bar__help-btn {
    font: 700 1rem/1 "Trebuchet MS", "Verdana", sans-serif;
}

.title-bar__lang-icon {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
}

.title-bar__lang-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 160px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    padding: 6px;
    z-index: 12;
}

.title-bar__lang-option {
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: "Trebuchet MS", "Verdana", "CSA UI CJK", sans-serif;
    color: #1d1b16;
    cursor: pointer;
}

.title-bar__lang-option:hover {
    background: rgba(31, 92, 255, 0.1);
}

.title-bar__lang-option.active {
    background: rgba(31, 92, 255, 0.16);
    color: #1f5cff;
    font-weight: 600;
}

.title-bar__handle {
    position: absolute;
    left: 50%;
    bottom: 1px;
    transform: translate3d(-50%, 0, 0);
    width: 162px;
    height: 7px;
    border-radius: 999px;
    border: 1px solid #c6cbd2;
    background: #d6dae0;
    cursor: pointer;
    z-index: 3;
    transition: transform 220ms ease;
    will-change: transform;
}

.title-bar__handle[aria-expanded="true"] {
    transform: translate3d(-50%, var(--chart-drawer-height), 0);
}

.chart-drawer {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1;
    height: var(--chart-drawer-height);
    overflow: hidden;
    background: var(--panel-muted);
    border-bottom: 1px solid var(--border);
    transform: translate3d(0, -100%, 0);
    transition: transform 220ms ease;
    will-change: transform;
    contain: layout paint;
    pointer-events: none;
}

.chart-drawer.open {
    transform: translate3d(0, 0, 0);
    pointer-events: auto;
}

.chart-drawer__inner {
    height: 100%;
    overflow: auto;
    padding: 16px 16px 36px;
    touch-action: pan-y;
}

.chart-drawer__title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.drawer-muted {
    color: #5f5a4e;
    margin: 8px 0 16px;
}

.drawer-status {
    margin-top: 16px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #f7f3eb;
    border: 1px solid var(--border);
    color: #504b40;
    font-size: 0.85rem;
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 12px;
}

.chart-card--loading {
    pointer-events: none;
    cursor: default;
}

.chart-card__placeholder {
    display: block;
    border-radius: 4px;
}

.chart-card__placeholder--name { width: min(82%, 220px); height: 23px; }
.chart-card__placeholder--size { width: 72px; height: 12px; }
.chart-card__placeholder--progress { width: min(86%, 220px); height: 8px; }
.chart-card__placeholder--action { width: 24px; height: 24px; margin-top: 3px; }

.chart-card {
    display: grid;
    grid-template-columns: 128px 1fr;
    gap: 12px;
    align-items: center;
    height: 148px;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid rgba(31, 92, 255, 0.35);
    background: var(--panel);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
    content-visibility: auto;
    contain-intrinsic-size: auto 148px;
}

.chart-card:hover,
.chart-card:focus-visible,
.chart-card:active {
    border-color: #1f5cff;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
    outline: none;
}

.chart-card.active {
    border-color: #1f5cff;
    box-shadow: 0 0 0 1px #1f5cff;
}

.chart-card--download-only {
    cursor: default;
}

.chart-card--download-only:hover,
.chart-card--download-only:active {
    border-color: var(--chart-card-border, #78aee8);
    background: inherit;
}

.chart-thumb {
    width: 128px;
    height: 128px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #ffffff;
    object-fit: cover;
}

.chart-thumb-shell {
    position: relative;
    width: 128px;
    height: 128px;
}

.chart-thumb-shell .chart-thumb {
    position: absolute;
    inset: 0;
}

.chart-thumb--placeholder {
    z-index: 1;
    background: #d2d5da;
}

.chart-thumb--image,
.splash-cover__logo,
.launcher-icon img {
    opacity: 0;
    transition: opacity 180ms ease;
}

.chart-thumb--image.is-loaded,
.splash-cover__logo.is-loaded,
.launcher-icon img.is-loaded {
    opacity: 1;
}

.chart-card__meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.chart-card__name {
    font-weight: 700;
    font-size: 1.3rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: "CSA Corsiva", "Trebuchet MS", "Verdana", "CSA UI CJK", sans-serif;
}

.chart-card__size {
    font-size: 0.85rem;
    color: #5f5a4e;
}

.chart-card__progress {
    position: relative;
    width: min(86%, 220px);
    height: 8px;
    overflow: hidden;
    border: 1px solid rgba(64, 73, 86, 0.12);
    border-radius: 4px;
    background: #dfe3e7;
}

.chart-card__progress-fill {
    display: block;
    width: 0;
    height: 100%;
    background: #45a863;
    transition: width 175ms ease;
}

.chart-card__link {
    display: inline-grid;
    place-items: center start;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    color: #1f5cff;
    text-decoration: none;
    transition: background-color 120ms ease, color 120ms ease;
}

.chart-card__link:hover,
.chart-card__link:focus-visible {
    color: #1748c7;
    background: rgba(31, 92, 255, 0.1);
    outline: none;
}

.chart-card__download-icon {
    width: 24px;
    height: 24px;
    margin-left: -3px;
}

.chart-list {
    background: var(--panel-muted);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    touch-action: pan-y;
}

.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.list-header h1 {
    font-size: 1.1rem;
    margin: 0;
    letter-spacing: 0.5px;
}

.list-body {
    flex: 1;
    overflow: auto;
    padding: 12px 12px 24px;
}

.chart-item {
    width: 100%;
    text-align: left;
    border: 1px solid transparent;
    background: var(--panel);
    padding: 10px 12px;
    margin-bottom: 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.chart-item:hover {
    border-color: var(--accent);
}

.chart-item.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.chart-name {
    font-weight: 600;
}

.chart-meta {
    font-size: 0.8rem;
    color: #5f5a4e;
    margin-top: 2px;
}

.sync-btn,
.reset-btn {
    border: none;
    background: var(--accent);
    color: #ffffff;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
}

.toggle-btn {
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--ink);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
}

.list-actions,
.workspace-actions {
    display: flex;
    gap: 8px;
}

.sync-btn:disabled,
.reset-btn:disabled {
    background: #9eb6b4;
    cursor: default;
}

.status {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: #504b40;
    background: #f7f3eb;
}

.workspace {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
}

.workspace-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
}

.chart-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-weight: 600;
}

.chart-title small {
    font-size: 0.8rem;
    color: #5f5a4e;
}

.canvas-wrap {
    flex: 1 1 0;
    min-height: 0;
    background: #f9fafb;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.chart-canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    position: absolute;
    inset: 0;
    z-index: 1;
}

.splash-cover {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: clamp(16px, 5vmin, 56px);
    background: #f3efe6;
    z-index: 5;
    pointer-events: none;
    overflow: hidden;
}

.splash-cover__logo-shell {
    width: min(50vw, 700px);
    max-width: 86%;
    aspect-ratio: 1468 / 290;
    margin-bottom: clamp(6px, 1.2vmin, 14px);
    position: relative;
}

.splash-cover__logo,
.splash-cover__logo-placeholder {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 6px;
}

.splash-cover__logo {
    object-fit: contain;
}

.chart-visual-placeholder {
    position: absolute;
    inset: 0;
    z-index: 4;
}

.splash-cover__title {
    max-width: 92%;
    font-family: "CSA Century Gothic", "Century Gothic", "Trebuchet MS", "Verdana", "CSA UI CJK", sans-serif;
    font-size: clamp(0.8rem, 4vw, 3.45rem);
    line-height: 1.12;
    color: #111111;
    text-align: center;
    white-space: nowrap;
    margin-bottom: clamp(3px, 0.8vmin, 7px);
}

.splash-cover__commit {
    max-width: 92%;
    font-size: clamp(0.55rem, 2.2vw, 0.7rem);
    line-height: 1.15;
    color: #2d2d2d;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.thread-panel-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 12;
}

.thread-panel {
    position: absolute;
    right: calc(16px + env(safe-area-inset-right, 0px));
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    width: min(540px, calc(100% - 32px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
    max-width: 540px;
    height: min(72vh, 560px);
    border-radius: 24px;
    box-sizing: border-box;
    background: transparent;
    border: 1px solid transparent;
    box-shadow: none;
    backdrop-filter: none;
    opacity: 0;
    transition: opacity 180ms ease, background 240ms ease, box-shadow 240ms ease;
    pointer-events: none;
    z-index: 1;
}

.thread-panel.open {
    background: rgba(255, 255, 255, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.45);
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(16px) saturate(1.2);
    opacity: 1;
    pointer-events: auto;
    z-index: 3;
}

.thread-panel__toggle {
    position: absolute;
    right: calc(24px + env(safe-area-inset-right, 0px));
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    width: 64px;
    height: 64px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.62);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px) saturate(1.15);
    cursor: pointer;
    pointer-events: auto;
    display: grid;
    place-items: center;
    padding: 0;
    z-index: 2;
    /* Morph animation: button expands to become the full popup perimeter */
    transition:
        width 380ms cubic-bezier(0.2, 0, 0, 1),
        height 380ms cubic-bezier(0.2, 0, 0, 1),
        left 380ms cubic-bezier(0.2, 0, 0, 1),
        right 380ms cubic-bezier(0.2, 0, 0, 1),
        bottom 380ms cubic-bezier(0.2, 0, 0, 1),
        background 380ms ease,
        border-color 380ms ease,
        box-shadow 380ms ease;
}

.thread-panel__toggle.open {
    /* The perimeter has expanded; icon no longer looks like a small button */
    background: rgba(255, 255, 255, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.45);
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(16px) saturate(1.2);
    display: block;
    pointer-events: auto;
    z-index: 5;
}

.thread-panel__icon {
    width: 42px;
    height: 42px;
    display: block;
    object-fit: contain;
    pointer-events: none;
}

.thread-panel__icon--threads {
    width: 56px;
    height: 42px;
}

/* === Expanding button-to-popup system === */
/* launcher-icon: holds the icon graphic. Now always fixed to window at the closed button icon position.
   The morphing popup (.thread-panel__toggle) changes shape and contents around it. */
.launcher-icon {
    cursor: pointer;
    z-index: 10;
    position: relative;
}

.launcher-icon__placeholder {
    position: absolute;
    inset: 0;
    width: 42px;
    height: 42px;
    border-radius: 8px;
}

.launcher-icon__placeholder--threads { width: 56px; }

/* Note: launcher-icon uses absolute positioning (with corner offsets calibrated to center the graphic in the small closed button).
   Because the offsets match the ones used in .open, the icon stays at the exact same screen position
   while the toggle morphs (no jump to middle on close). The toggle's right/bottom (or left/bottom) anchor stays fixed. */

/* panel-content: the separated popup contents inside the expanded toggle */
.thread-panel__toggle .panel-content {
    position: absolute;
    top: 12px;
    left: 12px;
    overflow: auto;
    touch-action: pan-y;
    opacity: 0;
    /* Sweep from top to bottom after expansion */
    clip-path: inset(0 0 100% 0);
    transition: opacity 220ms ease 380ms, clip-path 250ms ease 380ms;
    pointer-events: auto;
}

.thread-panel__toggle.open .panel-content {
    opacity: 1;
    clip-path: inset(0);
    z-index: 2;
}

/* Force visibility of moved content (old rules had opacity 0 / absolute inset) */
.thread-panel__toggle.open .panel-content .thread-panel__content,
.thread-panel__toggle.open .panel-content .thread-panel__body,
.thread-panel__toggle.open .panel-content .settings-list,
.thread-panel__toggle.open .panel-content .thread-list {
    position: relative;
    opacity: 1 !important;
    inset: auto;
}

/* Right (thread list) panel: icon pinned bottom-right of popup, content leaves space */
.thread-list-panel__toggle.open {
    /* Anchor right and bottom to original closed button position.
       Expansion only left (width) and up (height). Right/bottom perimeters do not move. */
    right: calc(24px + env(safe-area-inset-right, 0px));
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    width: min(540px, calc(100% - 32px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
    height: min(72vh, 560px);
    border-radius: 18px;  /* same as closed to avoid radius appearing to change during morph */
}

.thread-list-panel__toggle .launcher-icon {
    /* Absolute with offsets that center the icon graphic inside the closed 64px button.
       Same offsets used when open, so icon screen position is identical in closed and open states.
       Prevents jumping to middle of the modal during close (toggle shrinks around the fixed icon). */
    position: absolute;
    right: 4px;
    bottom: 11px;
    width: 56px;
    height: 42px;
    z-index: 10;
}

.thread-list-panel__toggle .launcher-icon img {
    width: 56px;
    height: 42px;
    object-fit: contain;
}

.thread-list-panel__toggle.open .panel-content {
    /* Full width of the popup. Bottom reserved for the icon in corner.
       Content uses full width (right:0). */
    left: 8px;
    top: 8px;
    right: 0;
    bottom: 65px;
    overflow-x: hidden;  /* ensure no horizontal scrollbar appears on the wrapper */
}

/* Make the inner content use even more of the available width by reducing side padding */
.thread-list-panel__toggle.open .thread-panel__content {
    padding-left: 0;
    padding-right: 0;
    padding-top: 4px;
    width: 100%;
    min-width: 0;
}

/* Left (settings) panel */
.settings-panel__toggle.open {
    /* Anchor left and bottom to original closed button position.
       Expansion only right (width) and up (height). Left/bottom perimeters do not move. */
    left: calc(48px + env(safe-area-inset-left, 0px));
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    right: auto;
    width: min(540px, calc(100% - 72px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
    height: min(56vh, 420px);
    border-radius: 18px;  /* same as closed to avoid radius appearing to change during morph */
}

.settings-panel__toggle .launcher-icon {
    /* Absolute with offsets that center the icon graphic inside the closed 64px button.
       Same offsets used when open, so icon screen position is identical in closed and open states.
       Prevents jumping to middle of the modal during close (toggle shrinks around the fixed icon). */
    position: absolute;
    left: 11px;
    bottom: 11px;
    width: 42px;
    height: 42px;
    z-index: 10;
}

.settings-panel__toggle.open .panel-content {
    /* full width content, reserve only bottom for icon in its own row at bottom-left corner */
    left: 8px;
    top: 8px;
    right: 8px;
    bottom: 55px;
    overflow-x: hidden; /* prevent any horizontal scrollbar */
}

/* Ensure settings contents use full available width inside the modal */
.settings-panel__toggle.open .thread-panel__content,
.settings-panel__toggle.open .settings-panel__content {
    padding-left: 0;
    padding-right: 0;
    width: 100%;
    min-width: 0;
}

.settings-panel__toggle.open .thread-panel__body {
    overflow-x: hidden;
    padding-right: 0;
}

.settings-list {
    width: 100%;
}

.settings-row {
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

.settings-panel__body {
    width: 100%;
}

.thread-panel__content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    padding: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
}

.thread-panel.open .thread-panel__content {
    opacity: 1;
    pointer-events: auto;
}

.thread-panel__header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
}

/* For thread list in expanded popup, make header use full width: tabs left, clear pushed right */
.thread-list-panel__toggle.open .thread-panel__header {
    justify-content: space-between;
    width: 100%;
}

.thread-list-panel__toggle.open .thread-panel__body,
.thread-list-panel__toggle.open .thread-list {
    width: 100%;
    overflow-x: hidden; /* prevent horizontal scrollbar when content fits */
}

.thread-list-panel__toggle.open .thread-list-header,
.thread-list-panel__toggle.open .thread-item {
    box-sizing: border-box;
    min-width: 0;
}

.thread-panel__filter-toggle {
    border: 1px solid rgba(0, 0, 0, 0.13);
    background: rgba(255, 255, 255, 0.72);
    color: #2b2822;
    padding: 6px 12px;
    font-size: 0.72rem;
    border-radius: 999px;
    cursor: pointer;
}

.thread-panel__filter-toggle.active {
    background: #1f5cff;
    color: #ffffff;
    border-color: transparent;
}

.thread-panel__close {
    width: 32px;
    height: 32px;
    margin-left: auto;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: rgba(255, 255, 255, 0.7);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}

.thread-panel__clear {
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: rgba(255, 255, 255, 0.72);
    color: #1d1b16;
    font-size: 0.72rem;
    padding: 4px 10px;
    border-radius: 999px;
    cursor: pointer;
}

.thread-panel__body {
    flex: 1;
    margin-top: 10px;
    overflow: auto;
    touch-action: pan-y;
    padding-right: 6px;
}

.thread-panel__empty {
    margin: 8px 0 0;
    color: #58564f;
    font-size: 0.85rem;
}

.thread-notes {
    margin: 0;
    font-size: 0.8rem;
    line-height: 1.35;
    white-space: pre-wrap;
    color: #2f2b25;
}

.thread-panel__footer {
    position: absolute;
    left: 16px;
    bottom: 16px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.thread-tab-group {
    display: inline-flex;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.143);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.792);
    backdrop-filter: blur(8px);
}

.thread-tab {
    border: none;
    background: transparent;
    padding: 6px 12px;
    font-size: 0.75rem;
    cursor: pointer;
    color: #2b2822;
}

.thread-tab.active {
    background: #1f5cff;
    color: #ffffff;
}

.thread-toggle-group {
    display: inline-flex;
    gap: 8px;
}

.thread-toggle-btn {
    border: 1px solid rgba(0, 0, 0, 0.121);
    background: rgba(255, 255, 255, 0.847);
    color: #1d1b16;
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 0.75rem;
    cursor: pointer;
    backdrop-filter: blur(8px);
    min-width: 104px;
    text-align: center;
}

.thread-toggle-btn.active {
    background: #1f5cff;
    color: #ffffff;
    border-color: transparent;
}

.thread-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.thread-divider {
    height: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.18);
    margin: 4px 2px;
}

.thread-item {
    display: grid;
    grid-template-columns: 28px 48px 1fr;
    gap: 10px;
    align-items: center;
    padding: 6px 8px;
    border-radius: 14px;
}

.thread-item.highlighted {
    background: rgba(197, 197, 197, 0.55);
    animation: thread-highlight-pulse 1.2s ease 1;
    animation-fill-mode: forwards;
}

@keyframes thread-highlight-pulse {
    0% {
        background: rgba(197, 197, 197, 0.1);
    }
    25% {
        background: rgba(197, 197, 197, 0.6);
    }
    50% {
        background: rgba(197, 197, 197, 0.15);
    }
    75% {
        background: rgba(197, 197, 197, 0.6);
    }
    100% {
        background: rgba(197, 197, 197, 0.55);
    }
}

.thread-select {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 2px solid rgba(0, 0, 0, 0.15);
    background: #ffffff;
    cursor: pointer;
    padding: 0;
}

.thread-select.selected {
    background: #1f5cff;
    border-color: #1f5cff;
}

.thread-swatch {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.09);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.thread-swatch--line {
    background: #ffffff;
}

.thread-swatch--bead {
    background: #ffffff;
}

.thread-bead-symbol {
    position: relative;
    width: 66%;
    height: 84%;
    border: 1.5px solid #1d1d1d;
    border-radius: 999px;
    box-sizing: border-box;
    display: grid;
    place-items: center;
}

.thread-bead-symbol::before,
.thread-bead-symbol::after {
    content: "";
    position: absolute;
    left: 18%;
    right: 18%;
    height: 1.5px;
    border-radius: 999px;
    background: linear-gradient(90deg, #1d1d1d 0 24%, transparent 24% 76%, #1d1d1d 76% 100%);
}

.thread-bead-symbol::before {
    top: 19%;
}

.thread-bead-symbol::after {
    bottom: 19%;
}

.thread-bead-symbol__glyph {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
}

.thread-line-symbol {
    width: 8px;
    height: 36px;
    border-radius: 999px;
    transform: rotate(42deg);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.24);
}

.thread-symbol {
    font-family: "Trebuchet MS", "Verdana", "CSA UI CJK", sans-serif;
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    color: inherit;
}

.chart-symbol-glyph,
.chart-symbol-glyph__fallback {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
}

.chart-symbol-glyph__fallback {
    display: grid;
    place-items: center;
}

.chart-symbol-glyph__layer {
    position: absolute;
    transform: translate(-50%, -50%);
}

.chart-symbol-glyph__text {
    display: grid;
    place-items: center;
    line-height: 1;
    font-size: 1.2rem;
}

.chart-symbol-glyph__mask {
    background: currentColor;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-size: contain;
    mask-size: contain;
}

.chart-symbol-glyph__image {
    object-fit: contain;
}

.thread-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.thread-code {
    font-weight: 700;
    font-size: 0.9rem;
}

.thread-desc {
    font-size: 0.82rem;
    color: #4f4b43;
}

.thread-progress {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: #3d3a34;
}

.thread-progress__label {
    flex: 0 0 auto;
    font-weight: 600;
    white-space: nowrap;
}

.thread-progress__bar {
    position: relative;
    flex: 1 1 auto;
    height: 12px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.121);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-sizing: border-box;
}

.thread-progress__fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: #4aa35d;
    border-radius: inherit;
    transition: width 160ms ease;
}

.thread-progress__text {
    position: relative;
    z-index: 1;
    font-size: 0.7rem;
    line-height: 1;
    color: #1d1b16;
}

.thread-stats {
    font-size: 0.75rem;
    color: #3d3a34;
}

.canvas-effects {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}

.backstitch-tooltip {
    max-width: 260px;
    background: rgba(255, 255, 255, 0.95);
    color: #111111;
    border: 1px solid #111111;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 0.75rem;
    line-height: 1.2;
    white-space: pre;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.canvas-menu {
    background: rgba(255, 255, 255, 0.95);
    color: #111111;
    border: 1px solid #111111;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.8rem;
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 160ms ease, transform 160ms ease;
    pointer-events: none;
    will-change: opacity, transform;
    z-index: 7;
}

.canvas-menu.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.press-ripple {
    position: absolute;
    width: 13.5px;
    height: 13.5px;
    border-radius: 50%;
    border: 2px solid rgba(50, 120, 220, 0.75);
    background: rgba(50, 120, 220, 0.2);
    box-shadow: 0 0 8px rgba(50, 120, 220, 0.35);
    transform: translate(-50%, -50%) scale(0.75);
    animation: pressRipple 520ms ease-out forwards;
    pointer-events: none;
    z-index: 6;
}

@keyframes pressRipple {
    0% {
        opacity: 0.7;
        transform: translate(-50%, -50%) scale(0.75);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(12);
    }
}

#blazor-error-ui {
    color-scheme: light only;
    background: #fde6c8;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.log-overlay {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    max-height: 40vh;
    height: min(40vh, 320px);
    background: #111;
    color: #f2f2f2;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    padding: 12px;
    z-index: 2000;
    pointer-events: auto;
    user-select: text;
    -webkit-user-select: text;
    -webkit-touch-callout: default;
    touch-action: auto;
}

.log-overlay * {
    user-select: text;
    -webkit-user-select: text;
    -webkit-touch-callout: default;
}

.log-overlay.hidden {
    display: none;
}

.log-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.log-header button {
    border: 1px solid #444;
    background: #1d1d1d;
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
}

#log-body {
    margin: 0;
    white-space: pre-wrap;
    font-size: 0.75rem;
    overflow: auto;
    flex: 1;
    min-height: 120px;
    user-select: text;
}

@media (max-width: 900px) {
    .title-shell {
        --chart-drawer-height: 78vh;
    }

    .chart-grid {
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    }

    .thread-panel.open {
        max-width: 480px;
        height: min(78vh, 520px);
    }

    .thread-panel__footer {
        left: 14px;
        flex-wrap: wrap;
        gap: 6px;
    }
}

@media (max-width: 860px) {
    .title-bar__progress-label {
        display: none;
    }
}

@media (max-width: 760px) {
    .title-bar {
        display: grid;
        grid-template-columns: minmax(9rem, 1fr) auto;
        gap: 8px;
        padding: 4px 12px 6px;
    }

    .title-bar__name {
        min-width: 0;
        font-size: 1.15rem;
    }

    .title-bar__progress {
        min-width: 0;
        width: 100%;
        flex: none;
        margin: 0;
        justify-content: stretch;
    }

    .title-bar__progress-bar {
        max-width: none;
        width: 100%;
        height: 8px;
        padding: 0 4px;
    }

    .title-bar__progress-text {
        font-size: 0.55rem;
    }

    .title-bar__actions {
        min-width: 0;
        justify-content: flex-end;
    }

}

@media (max-width: 420px) {
    .title-bar {
        grid-template-columns: minmax(8.5rem, 1fr) auto;
        gap: 7px;
    }

    .title-bar__name {
        font-size: 1.1rem;
    }
}

/* Thread panel UX refresh */
.settings-panel__toggle {
    left: calc(48px + env(safe-area-inset-left, 0px));
    right: auto;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

.thread-list-panel__toggle {
    right: calc(24px + env(safe-area-inset-right, 0px));
}

.settings-panel {
    left: env(safe-area-inset-left, 0px);
    right: auto;
    height: auto;
    min-height: 240px;
    max-height: min(56vh, 420px);
}

.settings-panel__content {
    padding-bottom: 14px;
}

.settings-panel__title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #2b2822;
}

.settings-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.605);
    border: 1px solid rgba(0, 0, 0, 0.077);
    position: relative;
    appearance: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    pointer-events: auto;
    transition: background-color 140ms ease, border-color 140ms ease;
}

.settings-row:hover {
    background: rgba(255, 255, 255, 0.825);
    border-color: rgba(31, 92, 255, 0.242);
}

.settings-row:focus-visible {
    outline: 2px solid #1f5cff;
    outline-offset: 2px;
}

.settings-row__label {
    font-size: 0.86rem;
    font-weight: 650;
    color: #2b2822;
}

.settings-toggle {
    width: 44px;
    height: 24px;
    background: #c7ccd4;
    border: 1px solid rgba(0, 0, 0, 0.165);
    border-radius: 999px;
    padding: 0;
    position: relative;
    transition: background-color 160ms ease, border-color 160ms ease;
    flex-shrink: 0;
    z-index: 3;
    pointer-events: auto;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.198);
}

.settings-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.385);
    transition: transform 160ms ease;
}

.settings-toggle.active {
    background: #1f5cff;
    border-color: #1f5cff;
}

.settings-toggle.active::after {
    transform: translateX(20px);
}

.thread-panel__header {
    flex-wrap: wrap;
    gap: 8px;
}

.thread-panel__filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    white-space: nowrap;
}

.thread-panel__filter-icon {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
}

.thread-list {
    gap: 8px;
}

.thread-list-header,
.thread-item {
    display: grid;
    grid-template-columns: 44px minmax(72px, 0.58fr) minmax(86px, 1fr) minmax(92px, 0.92fr);
    gap: 8px;
    align-items: center;
}

.thread-list-header {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 6px 8px;
    border-radius: 12px;
    background: rgb(247, 248, 251);
    color: #6d6a62;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    backdrop-filter: blur(8px);
}

.thread-section-divider {
    display: grid;
    grid-template-columns: 16px auto 1fr;
    align-items: center;
    gap: 7px;
    margin: 8px 4px 2px;
    color: #8a877f;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.thread-section-divider::before,
.thread-section-divider::after {
    content: "";
    height: 1px;
    background: rgba(0, 0, 0, 0.18);
}

.thread-section-divider span {
    white-space: nowrap;
}

.thread-item {
    padding: 6px 8px;
}

.thread-item--loading > span {
    display: block;
    border-radius: 4px;
}

.thread-loading__visibility { width: 24px; height: 24px; }
.thread-loading__swatch { width: 68px; height: 34px; }
.thread-loading__description { width: 88%; height: 13px; }
.thread-loading__progress { width: 100%; height: 30px; }

@media (prefers-reduced-motion: reduce) {
    .loading-placeholder {
        animation: none;
        opacity: 0.62;
    }

    .chart-thumb--image,
    .splash-cover__logo,
    .launcher-icon img {
        transition: none;
    }
}

.thread-code-cell {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 7px;
}

.thread-swatch {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 0.86rem;
    flex: 0 0 auto;
}

.thread-line-symbol {
    height: 26px;
    width: 6px;
}

.thread-code {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.thread-code--stacked {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    line-height: 1.05;
    white-space: normal;
}

.thread-code--stacked span {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thread-desc {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.thread-desc--scroll {
    text-overflow: clip;
}

.thread-desc__track {
    display: inline-flex;
    align-items: center;
    column-gap: 28px;
    min-width: max-content;
    transform: translateX(0);
}

.thread-desc__repeat {
    display: none;
}

.thread-desc--scroll.is-overflowing .thread-desc__repeat {
    display: inline;
}

.thread-desc--scroll.is-overflowing .thread-desc__track {
    animation: thread-description-scroll var(--thread-desc-duration, 8s) linear 1s infinite;
}

.thread-item:hover .thread-desc__track,
.thread-item:focus-visible .thread-desc__track,
.thread-item:focus-within .thread-desc__track {
    animation-play-state: paused;
}

@keyframes thread-description-scroll {
    to {
        transform: translateX(calc(-1 * var(--thread-desc-distance, 0px)));
    }
}

@media (prefers-reduced-motion: reduce) {
    .thread-desc--scroll.is-overflowing .thread-desc__track {
        animation: none;
    }

    .thread-desc--scroll.is-overflowing .thread-desc__repeat {
        display: none;
    }
}

.thread-progress {
    min-width: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
}

.thread-progress__bar {
    width: 100%;
}

.thread-progress__label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.thread-visibility {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.13);
    background: rgba(255, 255, 255, 0.9);
    color: #2f332f;
    cursor: pointer;
    padding: 0;
    display: grid;
    place-items: center;
}

.thread-visibility svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.thread-visibility.selected {
    color: #1f5cff;
    border-color: rgba(31, 92, 255, 0.5);
    background: rgba(31, 92, 255, 0.11);
}

.thread-visibility.hidden {
    color: #8a877f;
    background: rgba(255, 255, 255, 0.5);
}

@media (max-width: 520px) {
    .thread-panel {
        right: calc(10px + env(safe-area-inset-right, 0px));
        bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        width: calc(100% - 20px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
        height: min(76vh, 620px);
        border-radius: 20px;
    }

    .settings-panel {
        left: env(safe-area-inset-left, 0px);
        right: auto;
        height: auto;
        min-height: 220px;
    }

    .thread-panel__content {
        padding: 12px 10px;
    }

    .settings-panel__content {
        padding-bottom: 12px;
    }

    .thread-panel__toggle {
        width: 56px;
        height: 56px;
        border-radius: 16px;
        right: calc(18px + env(safe-area-inset-right, 0px));
        bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    }

    .settings-panel__toggle {
        left: calc(42px + env(safe-area-inset-left, 0px));
        right: auto;
        bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    }

    .thread-list-panel__toggle {
        right: calc(18px + env(safe-area-inset-right, 0px));
    }

    .thread-panel__icon {
        width: 38px;
        height: 38px;
    }

    .thread-panel__icon--threads {
        width: 50px;
        height: 36px;
    }

    /* Ensure thread list icon uses matching mobile size also when closed (the non-media descendant rule would otherwise force desktop 56px and mis-center or crowd the graphic in the 56px button) */
    .thread-list-panel__toggle .launcher-icon img {
        width: 50px;
        height: 36px;
        object-fit: contain;
    }

    /* Mobile morph: smaller corner reserve + mobile panel sizes */
    .thread-list-panel__toggle.open {
        /* Anchor right and bottom to original closed button position (mobile).
           Expansion left and up. */
        right: calc(18px + env(safe-area-inset-right, 0px));
        bottom: calc(18px + env(safe-area-inset-bottom, 0px));
        width: calc(100% - 20px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
        height: min(76vh, 620px);
        border-radius: 16px;  /* same as closed to avoid radius appearing to change during morph */
    }

    .thread-list-panel__toggle .launcher-icon {
        /* Absolute with offsets that center the icon graphic inside the closed 56px button.
           Same offsets keep icon fixed on screen during morph. */
        position: absolute;
        right: 3px;
        bottom: 10px;
        width: 50px;
        height: 36px;
        z-index: 10;
    }

    .thread-list-panel__toggle.open .launcher-icon img {
        width: 50px;
        height: 36px;
        object-fit: contain;
    }

    .thread-list-panel__toggle.open .panel-content {
        left: 8px;
        top: 8px;
        right: 16px;
        bottom: 58px;
    }

    .settings-panel__toggle.open {
        /* Anchor left and bottom to original closed button position (mobile).
           Expansion only right and up. */
        left: calc(42px + env(safe-area-inset-left, 0px));
        bottom: calc(18px + env(safe-area-inset-bottom, 0px));
        right: auto;
        width: calc(100% - 60px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
        height: min(56vh, 420px);
        border-radius: 16px;  /* same as closed to avoid radius appearing to change during morph */
    }

    .settings-panel__toggle .launcher-icon {
        /* Absolute with offsets that center the icon graphic inside the closed 56px button.
           Same offsets keep icon fixed on screen during morph. */
        position: absolute;
        left: 9px;
        bottom: 9px;
        width: 38px;
        height: 38px;
        z-index: 10;
    }

    .settings-panel__toggle.open .panel-content {
        /* full width content, reserve only bottom for icon in its own row at bottom-left */
        left: 8px;
        top: 8px;
        right: 8px;
        bottom: 50px;
    }

    .thread-tab,
    .thread-panel__filter-toggle,
    .thread-panel__clear {
        font-size: 0.68rem;
        padding: 5px 8px;
    }

    .thread-list-header,
    .thread-item {
        grid-template-columns: 34px minmax(64px, 0.6fr) minmax(74px, 1fr) minmax(78px, 0.9fr);
        gap: 6px;
        padding-left: 4px;
        padding-right: 4px;
    }

    .thread-list-header {
        font-size: 0.58rem;
    }

    .thread-visibility {
        width: 30px;
        height: 30px;
    }

    .thread-swatch {
        width: 28px;
        height: 28px;
        border-radius: 8px;
        font-size: 0.76rem;
    }

    .thread-code-cell {
        gap: 5px;
    }

    .thread-code {
        font-size: 0.76rem;
    }

    .thread-desc {
        font-size: 0.7rem;
    }

    .thread-progress__label,
    .thread-progress__text {
        font-size: 0.58rem;
    }

    .thread-progress__bar {
        height: 10px;
        padding: 0 3px;
    }
}

/* Mobile refinements after screenshot review */
.thread-panel__body {
    padding-bottom: 76px;
}

.thread-list-header > div {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 520px) {
    .thread-list-header,
    .thread-item {
        grid-template-columns: 44px minmax(82px, 0.72fr) minmax(78px, 1fr) minmax(82px, 0.82fr);
        gap: 4px;
    }

    .thread-list-header > div {
        font-size: 0;
    }

    .thread-list-header > div:nth-child(1)::after {
        content: "Vis.";
        font-size: 0.56rem;
    }

    .thread-list-header > div:nth-child(2)::after {
        content: "Code";
        font-size: 0.56rem;
    }

    .thread-list-header > div:nth-child(3)::after {
        content: "Desc.";
        font-size: 0.56rem;
    }

    .thread-list-header > div:nth-child(4)::after {
        content: "Prog.";
        font-size: 0.56rem;
    }

    .thread-section-divider {
        grid-template-columns: 14px auto 1fr;
        color: #6f6c65;
    }

    .thread-section-divider::before,
    .thread-section-divider::after {
        background: rgba(0, 0, 0, 0.26);
    }

    .thread-progress {
        gap: 2px;
    }

    .thread-progress__label {
        max-width: 100%;
    }

    .thread-progress__bar {
        min-width: 0;
    }
}

/* Open panels overlap launcher areas; only the active launcher rises above its panel to dismiss it. */
.thread-panel {
    z-index: 1;
}

.thread-panel.open {
    z-index: 4;
}

.thread-panel__toggle {
    z-index: 2;
}

.thread-panel__toggle.open {
    z-index: 5;
}

.cache-bust-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: #f3efe6;
    color: #2b2b2b;
}

.cache-bust-card {
    width: min(34rem, 100%);
    padding: 1.5rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.12);
}

.cache-bust-card h1 {
    margin: 0 0 .5rem;
    font-size: 1.25rem;
}

.cache-bust-card p {
    margin: .4rem 0;
}

/* Thread work-set controls */
.thread-list-panel__toggle.open .panel-content {
    bottom: 0;
    overflow: hidden;
}

.thread-list-panel__toggle.open .thread-panel__content {
    height: 100%;
    padding-bottom: 0;
    box-sizing: border-box;
    pointer-events: auto;
}

.thread-list-panel__toggle.open .thread-panel__body {
    min-height: 0;
    padding-bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    margin-top: 2px;
    background: rgba(95, 112, 128, 0.039);
}

.thread-list-panel__toggle.open .thread-list {
    overflow: visible;
}

.thread-search svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.thread-item {
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 140ms ease, border-color 140ms ease, opacity 140ms ease;
}

.thread-item.work-set-selected {
    border-color: rgba(212, 167, 44, 0.946);
    background: rgba(255, 249, 224, 0.22);
}

.thread-item.work-set-unselected {
    opacity: 0.803;
}

.thread-item:hover,
.thread-item:focus-visible {
    opacity: 1;
    border-color: #1f5cff;
    background: rgba(31, 92, 255, 0.088);
    outline: none;
}

.thread-category-pin,
.thread-section-divider {
    display: grid;
    grid-template-columns: 44px minmax(72px, 0.58fr) minmax(86px, 1fr) minmax(92px, 0.92fr);
    gap: 8px;
    align-items: center;
    box-sizing: border-box;
    width: 100%;
    padding: 2px 8px;
    margin: 0;
    background: transparent;
    color: #77746d;
    font-size: 0.72rem;
    font-weight: 700;
}

.thread-category-pin {
    flex: 0 0 22px;
    min-height: 22px;
    overflow: hidden;
}

.thread-category-label {
    grid-column: 1 / -1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.thread-category-label::before,
.thread-category-label::after {
    content: "";
    height: 1px;
    background: rgba(0, 0, 0, 0.22);
}

.thread-category-label::before {
    flex: 0 0 16px;
}

.thread-category-label::after {
    flex: 1 1 auto;
}

.thread-section-divider::before,
.thread-section-divider::after {
    content: none;
}

.thread-list > .thread-section-divider:first-child {
    height: 0;
    min-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
    opacity: 0;
}

.thread-panel__search-row {
    flex: 0 0 auto;
    min-width: 0;
    width: 100%;
    padding: 0;
    box-sizing: border-box;
    background: transparent;
    z-index: 4;
    display: block;
}

.thread-search {
    position: relative;
    display: flex;
    align-items: center;
}

.thread-search svg {
    position: absolute;
    left: 10px;
    width: 17px;
    height: 17px;
    color: #656a73;
    pointer-events: none;
}

.thread-search input {
    width: 100%;
    height: 36px;
    box-sizing: border-box;
    border: 1px solid rgba(40, 48, 62, 0.341);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.22);
    backdrop-filter: none;
    color: #242830;
    padding: 0 10px 0 34px;
    font: inherit;
    font-size: 0.78rem;
}

.thread-workset-checkbox {
    width: 44px;
    height: 44px;
    justify-self: center;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.143);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.869);
    color: #737982;
    cursor: pointer;
}

.thread-workset-checkbox svg {
    width: 29px;
    height: 29px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.25;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.thread-workset-checkbox.selected {
    color: #1f5cff;
    border-color: rgba(31, 92, 255, 0.55);
    background: rgba(31, 92, 255, 0.121);
}

.thread-workset-checkbox.partial path {
    opacity: 0.53;
    stroke-width: 2.2;
}

.thread-progress {
    height: 100%;
    flex-direction: row;
    align-items: center;
    gap: 0;
}

.thread-progress__bar {
    height: 18px;
}

.thread-progress__text {
    font-size: 0.66rem;
}

.thread-item.highlighted,
.thread-item.highlighted:hover,
.thread-item.highlighted:focus-visible {
    background: rgba(31, 92, 255, 0.22);
    border-color: #164bd8;
    animation: none;
}

.thread-search input:disabled {
    opacity: 0.627;
    cursor: default;
}

.thread-panel__search-row .thread-tab-group {
    background: rgba(255, 255, 255, 0.22);
    backdrop-filter: none;
}

.thread-panel__toggle.open .launcher-icon,
.thread-panel__toggle.open .settings-row,
.thread-panel__toggle.open .thread-tab-group,
.thread-panel__toggle.open .thread-toggle-btn,
.thread-panel__toggle.open .thread-list-header {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

.thread-search input:focus {
    border-color: #1f5cff;
    outline: 2px solid rgba(31, 92, 255, 0.198);
}

.help-dialog {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 14px;
    background: rgba(27, 34, 47, 0.28);
    backdrop-filter: blur(3px);
}

.help-dialog__panel {
    width: min(1040px, calc(100vw - 28px));
    height: min(820px, calc(100dvh - 28px));
    min-height: min(560px, calc(100dvh - 28px));
    overflow: hidden;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    box-sizing: border-box;
    border: 1px solid rgba(31, 92, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 18px 46px rgba(28, 36, 50, 0.24);
    color: #242830;
}

.help-dialog__header {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    padding: 18px 22px 16px;
    border-bottom: 1px solid rgba(53, 63, 78, 0.13);
}

.help-dialog__header h2 {
    min-width: 0;
    margin: 0;
    font-size: 1.2rem;
    line-height: 1.25;
}

.help-dialog__header p {
    max-width: 760px;
    margin: 5px 0 0;
    color: #59616d;
    font-size: 0.88rem;
    line-height: 1.45;
}

.help-dialog__close {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    margin-left: auto;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.76);
    color: #353942;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
}

.help-dialog__body {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    padding: 0 24px 22px;
}

.help-topic-index {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 18px 0 20px;
}

.help-topic-index__title {
    margin-right: 4px;
    color: #4d5560;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.help-topic-index button {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border: 1px solid rgba(31, 92, 255, 0.22);
    border-radius: 6px;
    background: rgba(31, 92, 255, 0.055);
    color: #1748c7;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 650;
    cursor: pointer;
}

.help-topic-index button:hover,
.help-topic-index button:focus-visible {
    border-color: #1f5cff;
    background: rgba(31, 92, 255, 0.1);
    outline: none;
}

.help-topic {
    display: grid;
    grid-template-columns: minmax(260px, 0.9fr) minmax(320px, 1.1fr);
    align-items: center;
    gap: 28px;
    padding: 30px 4px;
    border-top: 1px solid rgba(53, 63, 78, 0.13);
    scroll-margin-top: 12px;
}

.help-topic__figure {
    min-width: 0;
    margin: 0;
}

.help-topic__figure img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 360px;
    object-fit: contain;
    object-position: center;
    border: 1px solid rgba(31, 92, 255, 0.2);
    border-radius: 6px;
    background: #f7f9fb;
    box-shadow: 0 10px 24px rgba(35, 45, 60, 0.11);
}

.help-topic__figure--portrait img {
    width: min(100%, 390px);
    margin: 0 auto;
}

.help-topic__figure--app-icon img {
    width: 152px;
    height: 152px;
    margin: 0 auto;
    border: 0;
    border-radius: 28px;
    box-shadow: 0 12px 24px rgba(35, 45, 60, 0.14);
}

.help-topic__copy {
    min-width: 0;
}

.help-topic__copy h3 {
    margin: 0 0 8px;
    color: #252b34;
    font-size: 1.08rem;
    line-height: 1.3;
}

.help-topic__copy p,
.help-topic__copy li {
    font-size: 0.88rem;
    line-height: 1.5;
}

.help-topic__copy p {
    margin: 9px 0;
}

.help-topic__copy ul {
    display: grid;
    gap: 7px;
    margin: 13px 0;
    padding-left: 1.25rem;
}

.help-topic__lead {
    color: #3d4652;
}

.help-topic__tip {
    padding-left: 12px;
    border-left: 3px solid #d6a11d;
    color: #5a4b20;
}

.help-topic--offline {
    align-items: start;
}

.help-dialog__footer {
    display: flex;
    justify-content: flex-end;
    padding: 12px 22px;
    border-top: 1px solid rgba(53, 63, 78, 0.13);
    background: rgba(247, 249, 252, 0.94);
}

.help-dialog__done {
    border: 0;
    border-radius: 6px;
    min-height: 38px;
    padding: 8px 16px;
    background: #1f5cff;
    color: #fff;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
}

@media (max-width: 760px) {
    .help-dialog {
        padding: 7px;
    }

    .help-dialog__panel {
        width: calc(100vw - 14px);
        height: calc(100dvh - 14px);
        min-height: 0;
    }

    .help-dialog__header {
        padding: 14px 14px 12px;
    }

    .help-dialog__header h2 {
        font-size: 1.05rem;
    }

    .help-dialog__header p {
        font-size: 0.8rem;
    }

    .help-dialog__body {
        padding: 0 14px 18px;
    }

    .help-topic-index {
        padding: 14px 0 16px;
    }

    .help-topic-index__title {
        width: 100%;
    }

    .help-topic {
        grid-template-columns: minmax(0, 1fr);
        gap: 18px;
        padding: 24px 2px;
    }

    .help-topic__figure img {
        max-height: 300px;
    }

    .help-topic__figure--portrait img {
        width: min(100%, 360px);
    }

    .help-dialog__footer {
        padding: 10px 14px;
    }
}

@media (max-width: 520px) {
    .thread-category-pin,
    .thread-section-divider {
        grid-template-columns: 44px minmax(82px, 0.72fr) minmax(78px, 1fr) minmax(82px, 0.82fr);
        gap: 4px;
        padding-left: 4px;
        padding-right: 4px;
    }

}

/* Fixed work-set header, footer, and chart launchers */
.thread-workset-sticky {
    position: relative;
    flex: 0 0 auto;
    display: block;
    padding: 0 6px 4px;
    z-index: 5;
    box-shadow: 0 8px 14px -10px rgba(28, 40, 52, 0.638);
}

.thread-workset-header-row {
    min-height: 44px;
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    align-items: center;
    gap: 12px;
}

.thread-workset-header-row .thread-tab-group {
    justify-self: start;
    background: rgba(255, 255, 255, 0.22);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

.thread-workset-progress {
    min-width: 0;
    width: min(280px, 100%);
    justify-self: end;
    display: grid;
    grid-template-columns: max-content minmax(92px, 1fr);
    align-items: center;
    gap: 7px;
}

.thread-workset-progress__label {
    color: #494d55;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.thread-workset-progress .thread-progress__bar {
    width: 100%;
    height: 18px;
}

.thread-panel__bottom-sticky {
    position: relative;
    flex: 0 0 var(--launcher-size);
    min-height: var(--launcher-size);
    width: 100%;
    display: grid;
    grid-template-rows: 34px 36px;
    align-content: center;
    gap: 4px;
    padding: 0 calc(var(--launcher-size) + 6px) 0 9px;
    box-sizing: border-box;
    z-index: 6;
    box-shadow: 0 -8px 14px -10px rgba(28, 40, 52, 0.638);
}

.thread-workset-actions {
    display: grid;
    grid-template-columns: max-content max-content max-content;
    align-items: stretch;
    justify-content: start;
    gap: 8px;
    min-width: 0;
    padding: 0;
}

.thread-workset-action {
    min-width: 0;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px 7px 4px 9px;
    border: 1px solid rgba(48, 56, 69, 0.242);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.22);
    color: #555b65;
    font: inherit;
    font-size: 0.69rem;
    font-weight: 650;
    line-height: 1.1;
    white-space: nowrap;
    cursor: pointer;
}

.thread-workset-action svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.thread-workset-action:hover,
.thread-workset-action:focus-visible {
    border-color: #1f5cff;
    color: #164bd8;
    outline: none;
}

.thread-workset-filter.active {
    border-color: #164bd8;
    background: rgba(31, 92, 255, 0.165);
    color: #164bd8;
    box-shadow: inset 0 0 0 1px rgba(31, 92, 255, 0.198);
}

.chart-input-mode-toggle {
    --mode-toggle-size: 96px;
    --mode-toggle-inset: 4px;
    --mode-icon-size: 40px;
    position: absolute;
    top: calc(40px + env(safe-area-inset-top, 0px));
    left: calc(40px + env(safe-area-inset-left, 0px));
}

.chart-undo-button {
    position: absolute;
    top: calc(40px + env(safe-area-inset-top, 0px));
    right: calc(16px + env(safe-area-inset-right, 0px));
}

.chart-input-mode-toggle,
.chart-undo-button {
    z-index: 10;
    display: grid;
    place-items: center;
    width: 96px;
    height: 96px;
    padding: 0;
    overflow: hidden;
    isolation: isolate;
    border: 1px solid rgba(255, 255, 255, 0.84);
    border-radius: 20px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.25), rgba(220, 233, 243, 0.09) 52%, rgba(255, 255, 255, 0.15)),
        rgba(223, 234, 243, 0.13);
    box-shadow:
        0 24px 34px rgba(18, 26, 38, 0.46),
        0 8px 14px rgba(18, 26, 38, 0.26),
        inset 0 1px 0 rgb(255, 255, 255),
        inset 0 -1px 0 rgba(45, 58, 72, 0.2);
    -webkit-backdrop-filter: blur(22px) saturate(1.28) brightness(1.06);
    backdrop-filter: blur(22px) saturate(1.28) brightness(1.06);
    cursor: pointer;
    touch-action: manipulation;
}

.chart-undo-button {
    z-index: 12;
}

.chart-input-mode-toggle::before,
.chart-input-mode-toggle::after,
.chart-undo-button::before,
.chart-undo-button::after {
    content: "";
    position: absolute;
    pointer-events: none;
}

.chart-input-mode-toggle::before,
.chart-undo-button::before {
    inset: 1px 1px auto;
    z-index: 0;
    height: 42%;
    border-radius: inherit;
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.37), rgba(255, 255, 255, 0) 68%);
}

.chart-input-mode-toggle::after,
.chart-undo-button::after {
    inset: 2px;
    z-index: 1;
    border: 1px solid rgba(255, 255, 255, 0.33);
    border-radius: 18px;
    box-shadow: inset 0 -12px 24px rgba(93, 117, 137, 0.09);
}

.chart-input-mode-toggle__selection {
    position: absolute;
    top: var(--mode-toggle-inset);
    bottom: var(--mode-toggle-inset);
    left: var(--mode-toggle-inset);
    z-index: 2;
    width: calc(50% - var(--mode-toggle-inset));
    border: 1px solid rgba(255, 255, 255, 0.82);
    border-radius: 16px 7px 7px 16px;
    background:
        linear-gradient(150deg, rgba(255, 255, 255, 0.48), rgba(202, 219, 232, 0.18)),
        rgba(255, 255, 255, 0.17);
    box-shadow:
        0 7px 15px rgba(27, 39, 54, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.9),
        inset 0 -1px 0 rgba(66, 82, 98, 0.15);
    transition: transform 175ms cubic-bezier(0.2, 0.75, 0.25, 1), border-radius 175ms ease;
}

.chart-input-mode-toggle.is-mark-mode .chart-input-mode-toggle__selection {
    border-radius: 7px 16px 16px 7px;
    transform: translateX(100%);
}

.chart-input-mode-toggle__icon {
    position: absolute;
    top: var(--mode-toggle-inset);
    bottom: var(--mode-toggle-inset);
    z-index: 3;
    width: calc(50% - var(--mode-toggle-inset) - 3px);
    display: grid;
    place-items: center;
    pointer-events: none;
    transition: opacity 175ms ease, filter 175ms ease;
}

.chart-input-mode-toggle__icon svg {
    width: var(--mode-icon-size);
    height: var(--mode-icon-size);
    overflow: visible;
}

.chart-input-mode-toggle__icon--move {
    left: var(--mode-toggle-inset);
    opacity: 0.62;
}

.chart-input-mode-toggle__icon--move svg {
    fill: none;
    stroke: #23384c;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.9));
}

.chart-input-mode-toggle__icon--mark {
    right: var(--mode-toggle-inset);
    opacity: 0.62;
}

.chart-input-mode-toggle__icon--mark svg {
    fill: none;
    stroke: #936514;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter:
        drop-shadow(0 1px 0 rgba(255, 255, 255, 0.8))
        drop-shadow(0 2px 2px rgba(89, 61, 15, 0.22));
}

.chart-input-mode-toggle.is-pan-mode .chart-input-mode-toggle__icon--move,
.chart-input-mode-toggle.is-mark-mode .chart-input-mode-toggle__icon--mark {
    opacity: 1;
    filter: saturate(1.08) contrast(1.04);
}

.chart-undo-button svg {
    position: relative;
    z-index: 3;
    width: 58px;
    height: 58px;
    fill: none;
    stroke: #23384c;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.9));
}

.chart-input-mode-toggle:hover,
.chart-undo-button:not(:disabled):hover {
    border-color: rgba(255, 255, 255, 0.96);
}

.chart-input-mode-toggle:focus-visible,
.chart-undo-button:focus-visible {
    outline: 3px solid rgba(31, 92, 255, 0.65);
    outline-offset: 3px;
}

.chart-undo-button:disabled {
    cursor: default;
    opacity: 0.43;
    box-shadow:
        0 12px 22px rgba(18, 26, 38, 0.24),
        0 4px 9px rgba(18, 26, 38, 0.16),
        inset 0 1px 0 rgb(255, 255, 255),
        inset 0 -1px 0 rgba(45, 58, 72, 0.15);
}

.thread-panel__toggle {
    --launcher-size: 96px;
    --launcher-inset: 4px;
    --launcher-face-size: 88px;
    overflow: hidden;
    isolation: isolate;
    border-color: rgba(255, 255, 255, 0.84);
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.25), rgba(220, 233, 243, 0.09) 52%, rgba(255, 255, 255, 0.15)),
        rgba(223, 234, 243, 0.13);
    box-shadow:
        0 24px 34px rgba(18, 26, 38, 0.46),
        0 8px 14px rgba(18, 26, 38, 0.26),
        inset 0 1px 0 rgb(255, 255, 255),
        inset 0 -1px 0 rgba(45, 58, 72, 0.2);
    -webkit-backdrop-filter: blur(22px) saturate(1.28) brightness(1.06);
    backdrop-filter: blur(22px) saturate(1.28) brightness(1.06);
}

.settings-dismiss-surface {
    position: absolute;
    inset: 0;
    z-index: 11;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: default;
    touch-action: none;
}

.thread-panel__toggle::before,
.thread-panel__toggle::after {
    content: "";
    position: absolute;
    pointer-events: none;
}

.thread-panel__toggle::before {
    inset: 1px 1px auto;
    height: 42%;
    border-radius: inherit;
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.37), rgba(255, 255, 255, 0) 68%);
    z-index: 0;
}

.thread-panel__toggle::after {
    inset: 2px;
    border: 1px solid rgba(255, 255, 255, 0.33);
    border-radius: calc(20px - 2px);
    box-shadow: inset 0 -12px 24px rgba(93, 117, 137, 0.09);
    z-index: 1;
}

.thread-panel__toggle:not(.open) {
    width: var(--launcher-size);
    height: var(--launcher-size);
    border-radius: 20px;
}

.thread-panel__toggle.open {
    border-color: rgba(255, 255, 255, 0.825);
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.242), rgba(218, 231, 241, 0.099) 48%, rgba(255, 255, 255, 0.154)),
        rgba(234, 241, 246, 0.825);
    box-shadow:
        0 28px 54px rgba(18, 26, 38, 0.462),
        0 10px 20px rgba(18, 26, 38, 0.242),
        inset 0 1px 0 rgb(255, 255, 255),
        inset 0 -1px 0 rgba(45, 58, 72, 0.165);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

.thread-panel__toggle.open::before {
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.407), rgba(255, 255, 255, 0) 68%);
}

.thread-panel__toggle.open::after {
    border-color: rgba(255, 255, 255, 0.363);
    box-shadow: inset 0 -12px 24px rgba(93, 117, 137, 0.099);
}

.settings-panel__toggle,
.settings-panel__toggle.open {
    left: calc(40px + env(safe-area-inset-left, 0px));
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

.thread-list-panel__toggle,
.thread-list-panel__toggle.open {
    right: calc(16px + env(safe-area-inset-right, 0px));
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

.settings-panel__toggle .launcher-icon,
.thread-list-panel__toggle .launcher-icon {
    bottom: var(--launcher-inset);
    width: var(--launcher-face-size);
    height: var(--launcher-face-size);
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid transparent;
    border-radius: 18px;
    box-sizing: border-box;
}

.settings-panel__toggle .launcher-icon {
    left: var(--launcher-inset);
}

.thread-list-panel__toggle .launcher-icon {
    right: var(--launcher-inset);
}

.thread-panel__toggle.open .launcher-icon {
    border-color: rgba(255, 255, 255, 0.627);
    background: rgba(255, 255, 255, 0.11);
    box-shadow:
        0 10px 22px rgba(22, 30, 43, 0.286),
        inset 0 1px 0 rgba(255, 255, 255, 0.869);
}

.launcher-icon__face {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: inherit;
    transition: opacity 130ms ease, transform 160ms ease;
}

.launcher-icon__face--default {
    opacity: 1;
    transform: scale(1);
    transition-delay: 120ms;
}

.launcher-icon__face--close {
    opacity: 0;
    transform: scale(0.88);
    transition-delay: 0ms;
}

.thread-panel__toggle.open .launcher-icon__face--default {
    opacity: 0;
    transform: scale(0.92);
    transition-delay: 0ms;
}

.thread-panel__toggle.open .launcher-icon__face--close {
    opacity: 1;
    transform: scale(1);
    transition-delay: 120ms;
}

.thread-panel__toggle .launcher-icon img.launcher-close-icon {
    position: absolute;
    inset: -4px;
    display: block;
    width: calc(100% + 8px);
    height: calc(100% + 8px);
    max-width: none;
    object-fit: cover;
    object-position: center;
    pointer-events: none;
    user-select: none;
}

.settings-panel__toggle .launcher-icon img.thread-panel__icon--visibility.is-loaded {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    opacity: 0.77;
    mix-blend-mode: multiply;
    filter: saturate(0.72) contrast(1.18);
    transform: scale(1.04);
}

.launcher-icon__placeholder {
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 16px;
}

.thread-launcher-tile {
    width: 84px;
    height: 84px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 17px;
    background: rgba(130, 193, 205, 0.68);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.79),
        inset 0 -5px 12px rgba(22, 72, 82, 0.17);
    -webkit-backdrop-filter: blur(7px) saturate(1.18);
    backdrop-filter: blur(7px) saturate(1.18);
}

.thread-launcher-tile__glyph {
    width: 90%;
    height: 88%;
    background: #183238;
    -webkit-mask: url("../icons/thread-d598.svg") center / contain no-repeat;
    mask: url("../icons/thread-d598.svg") center / contain no-repeat;
}

.settings-panel__toggle.open {
    height: min(610px, calc(100dvh - 72px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
}

.settings-panel__toggle.open .panel-content {
    top: 10px;
    bottom: 108px;
    overflow: visible;
}

.settings-panel__toggle.open .settings-panel__body {
    margin-top: 8px;
    padding: 0;
    overflow: visible;
    touch-action: none;
}

.settings-panel__toggle.open .settings-list {
    gap: 8px;
}

.settings-panel__toggle.open .settings-row {
    min-height: 46px;
    padding: 8px 12px;
    border-color: rgba(255, 255, 255, 0.528);
    background: rgba(255, 255, 255, 0.528);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.583);
}

.settings-row--mark-colour {
    position: relative;
    cursor: pointer;
}

.settings-row__colour-input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.settings-row__colour-swatch {
    width: 36px;
    height: 26px;
    flex: 0 0 auto;
    box-sizing: border-box;
    border: 1px solid rgba(43, 48, 56, 0.34);
    border-radius: 7px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        0 1px 3px rgba(28, 35, 44, 0.18);
}

.settings-row--mark-colour:focus-within {
    border-color: #1f5cff;
    outline: 2px solid rgba(31, 92, 255, 0.35);
    outline-offset: 1px;
}

.settings-panel__toggle.open .settings-row:hover,
.settings-panel__toggle.open .settings-row:focus-visible {
    background: rgba(255, 255, 255, 0.682);
}

.thread-list-panel__toggle.open .thread-panel__body .thread-item:not(.thread-item--loading) {
    border-color: rgba(255, 255, 255, 0.528);
    background: rgba(255, 255, 255, 0.528);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.583);
}

.thread-list-panel__toggle.open .thread-panel__body .thread-item.work-set-selected {
    border-color: rgba(212, 167, 44, 0.946);
    background:
        linear-gradient(rgba(255, 249, 224, 0.22), rgba(255, 249, 224, 0.22)),
        rgba(255, 255, 255, 0.528);
}

.thread-list-panel__toggle.open .thread-panel__body .thread-item:not(.thread-item--loading):hover,
.thread-list-panel__toggle.open .thread-panel__body .thread-item:not(.thread-item--loading):focus-visible {
    border-color: #1f5cff;
    background:
        linear-gradient(rgba(31, 92, 255, 0.088), rgba(31, 92, 255, 0.088)),
        rgba(255, 255, 255, 0.682);
}

.thread-list-panel__toggle.open .thread-panel__body .thread-item.highlighted,
.thread-list-panel__toggle.open .thread-panel__body .thread-item.highlighted:hover,
.thread-list-panel__toggle.open .thread-panel__body .thread-item.highlighted:focus-visible {
    border-color: #164bd8;
    background:
        linear-gradient(rgba(31, 92, 255, 0.22), rgba(31, 92, 255, 0.22)),
        rgba(255, 255, 255, 0.682);
}

.settings-panel__toggle.open .settings-panel__title,
.settings-panel__toggle.open .settings-row__label {
    text-shadow: 0 1px 1px rgb(255, 255, 255);
}

@media (max-width: 520px) {
    .thread-workset-action,
    .thread-workset-progress__label {
        font-size: 0.63rem;
    }

    .thread-workset-sticky {
        padding-right: 4px;
        padding-left: 4px;
    }

    .thread-workset-header-row {
        min-height: 42px;
        gap: 6px;
    }

    .thread-workset-header-row .thread-tab {
        padding: 5px 7px;
        font-size: 0.63rem;
    }

    .thread-workset-progress {
        width: 100%;
        grid-template-columns: max-content minmax(70px, 1fr);
        gap: 4px;
    }

    .thread-workset-progress .thread-progress__bar {
        height: 16px;
    }

    .thread-panel__bottom-sticky {
        grid-template-rows: 36px 36px;
        padding: 0 calc(var(--launcher-size) + 4px) 0 6px;
    }

    .thread-workset-actions {
        grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.12fr) minmax(0, 1.26fr);
        gap: 4px;
    }

    .thread-workset-action {
        min-height: 36px;
        gap: 3px;
        padding: 4px;
        font-size: 0.58rem;
        white-space: normal;
    }

    .thread-workset-action svg {
        width: 15px;
        height: 15px;
    }

    .thread-panel__toggle {
        --launcher-size: 84px;
        --launcher-inset: 3px;
        --launcher-face-size: 78px;
    }

    .chart-input-mode-toggle {
        --mode-toggle-size: 84px;
        --mode-toggle-inset: 3px;
        --mode-icon-size: 34px;
        top: calc(35px + env(safe-area-inset-top, 0px));
        left: calc(35px + env(safe-area-inset-left, 0px));
        width: var(--mode-toggle-size);
        height: var(--mode-toggle-size);
        border-radius: 19px;
    }

    .chart-undo-button {
        top: calc(35px + env(safe-area-inset-top, 0px));
        right: calc(11px + env(safe-area-inset-right, 0px));
        width: 84px;
        height: 84px;
        border-radius: 19px;
    }

    .chart-input-mode-toggle::after,
    .chart-undo-button::after {
        border-radius: 17px;
    }

    .chart-undo-button svg {
        width: 50px;
        height: 50px;
    }

    .chart-input-mode-toggle__selection {
        border-radius: 15px 7px 7px 15px;
    }

    .chart-input-mode-toggle.is-mark-mode .chart-input-mode-toggle__selection {
        border-radius: 7px 15px 15px 7px;
    }

    .thread-panel__toggle:not(.open) {
        border-radius: 19px;
    }

    .settings-panel__toggle,
    .settings-panel__toggle.open {
        left: calc(35px + env(safe-area-inset-left, 0px));
        bottom: calc(11px + env(safe-area-inset-bottom, 0px));
    }

    .thread-list-panel__toggle,
    .thread-list-panel__toggle.open {
        right: calc(11px + env(safe-area-inset-right, 0px));
        bottom: calc(11px + env(safe-area-inset-bottom, 0px));
    }

    .settings-panel__toggle .launcher-icon,
    .thread-list-panel__toggle .launcher-icon {
        border-radius: 16px;
    }

    .settings-panel__toggle .launcher-icon {
        left: var(--launcher-inset);
    }

    .thread-list-panel__toggle .launcher-icon {
        right: var(--launcher-inset);
    }

    .thread-launcher-tile {
        width: 74px;
        height: 74px;
        border-radius: 15px;
    }

    .settings-panel__toggle.open {
        height: min(610px, calc(100dvh - 72px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
    }

    .settings-panel__toggle.open .panel-content {
        bottom: 96px;
    }

    .thread-panel__search-row {
        width: 100%;
    }
}

@media (max-height: 650px) {
    .settings-panel__toggle.open .settings-list {
        gap: 4px;
    }

    .settings-panel__toggle.open .settings-row {
        min-height: 40px;
        padding-block: 5px;
    }

    .settings-panel__toggle.open .settings-panel__header {
        min-height: 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .chart-input-mode-toggle__selection,
    .chart-input-mode-toggle__icon,
    .chart-undo-button,
    .launcher-icon__face,
    .thread-panel__toggle.open .launcher-icon__face {
        transition-duration: 0ms;
        transition-delay: 0ms;
    }
}
