:root {
            --bg: #050506;
            --s1: #141518;
            --s2: #1d1f23;
            --s3: #26292f;
            --t1: rgba(255, 255, 255, .92);
            --t2: rgba(255, 255, 255, .64);
            --t3: rgba(255, 255, 255, .43);
            --sep: rgba(255, 255, 255, .12);
            --blue: #72a7ff;
            --red: #ff6262;
            --green: #32c985;
            --purple: #BF5AF2;
            --orange: #f4c542;
            --gold: #f4c542;
        }

        html { font-size: 14px; line-height: 1.45; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

        body {
            margin: 0;
            padding: 10px 12px 124px;
            background: var(--bg);
            color: var(--t1);
            font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "YuGothic", "Noto Sans JP", "Segoe UI", sans-serif;
            letter-spacing: 0;
            -webkit-tap-highlight-color: transparent;
            user-select: none;
            max-width: 420px;
            margin-inline: auto;
        }

        *, *::before, *::after { box-sizing: border-box; }
        button, input, textarea { font: inherit; letter-spacing: 0; }

        .status-bar {
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto auto;
            align-items: center;
            column-gap: 6px;
            background: linear-gradient(180deg, #181a1e, #111215);
            border: 0.5px solid var(--sep);
            border-radius: 8px;
            padding: 6px 9px;
            min-height: 55px;
            margin-bottom: 8px;
            color: var(--t2);
        }

        .status-bar.active {
            color: var(--gold);
            border-color: rgba(244,197,66,0.28);
            background: linear-gradient(180deg, #1b1b18, #12120f);
        }

        .status-main {
            min-width: 0;
        }

        .machine-name {
            color: var(--t1);
            font-size: 0.8rem;
            font-weight: 900;
            line-height: 1.15;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .status-session {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-top: 2px;
            font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
            font-variant-numeric: tabular-nums;
            font-size: 0.71rem;
            line-height: 1.15;
            font-weight: 800;
        }

        .status-dot {
            width: 6px;
            height: 6px;
            border-radius: 999px;
            background: var(--t3);
            flex: 0 0 auto;
        }

        .status-bar.active .status-dot {
            background: var(--gold);
            box-shadow: 0 0 8px rgba(244,197,66,0.5);
        }

        .header-icon-btn {
            width: 28px;
            min-width: 28px;
            height: 28px;
            min-height: 28px;
            padding: 0;
            border-radius: 999px;
            color: var(--t2);
            background: rgba(255,255,255,0.04);
            border: 0.5px solid var(--sep);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .header-icon-btn svg {
            width: 14px;
            height: 14px;
            display: block;
            stroke: currentColor;
            stroke-width: 2.2;
            stroke-linecap: round;
            stroke-linejoin: round;
            fill: none;
        }

        .card {
            background: var(--s1);
            border: 0.5px solid var(--sep);
            border-radius: 8px;
            padding: 12px;
            margin-bottom: 10px;
        }

        .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
        .grid-4-action { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
        .grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
        .grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }

        button {
            background: var(--s2);
            color: var(--t1);
            border: 0.5px solid var(--sep);
            border-radius: 8px;
            min-height: 46px;
            padding: 8px 4px;
            font-size: 0.95rem;
            font-weight: 850;
            cursor: pointer;
            position: relative;
            display: flex;
            align-items: center;
            justify-content: center;
            text-align: center;
            outline: none;
            -webkit-tap-highlight-color: transparent;
        }

        button:active:not(:disabled) {
            transform: translateY(1px);
            background-color: var(--s3);
        }

        button:disabled { opacity: 0.25; cursor: not-allowed; }

        .btn-main {
            background: var(--s3);
            color: var(--t1);
            padding: 12px 4px;
            font-size: 1rem;
            border: 0.5px solid var(--sep);
        }

        .btn-2line {
            flex-direction: column;
            line-height: 1.2;
            padding: 6px 2px;
            font-size: 0.85rem;
        }

        .btn-2line span { display: block; text-align: center; width: 100%; }

        .title-wrap {
            font-size: 1.2rem;
            font-weight: bold;
            display: flex;
            gap: 8px;
            align-items: center;
            min-width: 0;
        }

        .title-pt {
            font-size: 1.2rem;
            font-weight: bold;
            color: var(--t2);
        }

        .title-flash-rate {
            font-size: 0.78rem;
            font-weight: 800;
            color: var(--t2);
            white-space: nowrap;
        }

        .label-sm {
            font-size: 0.8rem;
            color: var(--t2);
            margin-bottom: 8px;
            display: block;
            font-weight: bold;
        }

        .flex-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

        .hi-tabs {
            display: flex;
            width: 132px;
            background: rgba(0, 0, 0, 0.28);
            border-radius: 8px;
            padding: 2px;
            gap: 4px;
            flex: 0 0 auto;
        }

        .hi-tabs button {
            flex: 1 1 0;
            min-height: 40px;
            padding: 6px 0;
            font-size: 0.76rem;
            background: transparent;
            color: var(--t2);
            border-radius: 7px;
            border: none;
        }

        .hi-tabs button.active-norm { background: var(--s2); color: var(--t1); }
        .hi-tabs button.active-gold {
            background: rgba(244,197,66,0.16);
            color: var(--gold);
            border: 0.5px solid rgba(244,197,66,0.42);
            font-weight: bold;
        }

        .glow-btn-row button {
            border-color: rgba(244, 197, 66, 0.62);
            box-shadow: inset 0 0 0 1px rgba(244, 197, 66, 0.18);
        }

        .cz-input-layout {
            display: grid;
            grid-template-columns: minmax(0, 1fr) 72px;
            gap: 6px;
            align-items: stretch;
        }

        .cz-input-layout.cz-result-mode { display: block; }

        .pt-row {
            display: grid;
            grid-template-columns: repeat(6, 1fr);
            gap: 6px;
            grid-auto-rows: minmax(46px, auto);
        }

        .pt-row button:nth-child(1),
        .pt-row button:nth-child(2),
        .pt-row button:nth-child(3) {
            grid-column: span 2;
        }

        .pt-row button:nth-child(2) {
            background: rgba(244,197,66,0.16);
            color: var(--gold);
            border-color: rgba(244,197,66,0.42);
        }

        .pt-row button:nth-child(4),
        .pt-row button:nth-child(5) {
            grid-column: span 3;
        }

        .pt-row.hi-pt-row button:first-child { grid-column: span 6; }
        .pt-row.hi-pt-row button:nth-child(2),
        .pt-row.hi-pt-row button:nth-child(3) { display: none; }
        .pt-row.hi-pt-row button:nth-child(4),
        .pt-row.hi-pt-row button:nth-child(5) { grid-column: span 3; }

        .btn-pt {
            flex-direction: column;
            gap: 2px;
            line-height: 1.1;
        }

        .btn-pt .pt-val {
            display: block;
            color: var(--t2);
            font-size: 0.7rem;
            font-weight: 900;
        }

        #czbox-mu { border-left: 3px solid var(--red); }
        #czbox-ik { border-left: 3px solid var(--green); }
        #czbox-bi { border-left: 3px solid var(--purple); }

        .zone-btns button { font-size: 1rem; padding: 10px 0; }
        .zone-btns button.active { background: rgba(244,197,66,0.16); color: var(--gold); border-color: rgba(244,197,66,0.42); }
        .action-btns { margin-top: 8px; }
        .btn-zone1000-epi { width: 100%; }

        .cz-flow { margin-top: 8px; }
        .cz-input-layout .cz-flow {
            margin-top: 0;
            display: flex;
            min-height: 102px;
        }
        .cz-input-layout.cz-result-mode .cz-flow {
            display: block;
            min-height: 0;
        }
        .cz-flow-grid { display: grid; gap: 6px; }
        .cz-flow-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
        .cz-flow-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
        .cz-flow-grid button {
            padding: 8px 2px;
            min-height: 48px;
            font-size: 0.82rem;
            font-weight: 800;
            line-height: 1.15;
        }
        .cz-flow-grid .btn-2line {
            padding: 7px 2px;
            font-size: 0.78rem;
        }
        .cz-measure-box {
            background: rgba(0,0,0,0.22);
            border: 0.5px solid var(--sep);
            border-radius: 6px;
            padding: 8px;
            margin-bottom: 8px;
        }
        .cz-measure-title {
            color: var(--t2);
            font-size: 0.75rem;
            font-weight: 900;
            margin-bottom: 6px;
        }
        .cz-measure-stat {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 8px;
            font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
            font-variant-numeric: tabular-nums;
            font-size: 0.82rem;
            margin-bottom: 6px;
            color: var(--t1);
        }
        .cz-measure-note {
            font-size: 0.68rem;
            color: var(--t2);
            line-height: 1.35;
            margin-top: 6px;
        }
        .cz-measure-actions {
            display: grid;
            gap: 6px;
        }
        .cz-measure-actions.cols-2 { grid-template-columns: repeat(2, 1fr); }
        .cz-measure-actions.cols-2 > button:only-child { grid-column: 1 / -1; }
        .cz-measure-actions.cols-3 { grid-template-columns: repeat(3, 1fr); }
        .cz-measure-actions button {
            min-height: 44px;
            font-size: 0.78rem;
            padding: 7px 2px;
            font-weight: 800;
        }

        .episode-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 6px;
        }
        .count-badge {
            display: block;
            margin-top: 3px;
            font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
            color: var(--t2);
            font-size: 0.72rem;
            font-weight: 800;
        }
        .end-image-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
            margin-top: 7px;
        }
        .end-image-btn {
            width: 100%;
            border: 1px solid var(--sep);
            border-radius: 8px;
            background: var(--s3);
            padding: 7px;
            color: #fff;
            min-height: 72px;
            font-weight: 900;
            flex-direction: column;
            align-items: stretch;
            justify-content: flex-start;
            gap: 6px;
            text-align: center;
        }
        .end-image-btn img {
            display: block;
            width: 100%;
            height: 96px;
            object-fit: cover;
            border-radius: 6px;
            margin: 0;
            flex: 0 0 auto;
        }
        .end-image-btn .count-badge {
            display: block;
            width: 100%;
            margin: 0;
            text-align: center;
            line-height: 1.25;
        }

        .bell-image-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
            margin-top: 7px;
        }
        .bell-image-btn {
            width: 100%;
            border: 1px solid var(--sep);
            border-radius: 8px;
            background: var(--s3);
            padding: 6px;
            color: #fff;
            font-weight: 900;
            min-height: 104px;
            flex-direction: column;
            gap: 5px;
        }
        .bell-image-label {
            display: block;
            width: 100%;
            text-align: center;
            font-size: 0.82rem;
            line-height: 1.15;
        }
        .bell-image-btn img {
            display: block;
            width: 100%;
            height: 82px;
            object-fit: cover;
            border-radius: 6px;
            margin: 0;
        }

        .cz-flow-main {
            width: 100%;
            background: var(--s3);
            border: 0.5px solid rgba(255, 255, 255, 0.1);
        }
        .cz-flow-stack {
            width: 100%;
            display: grid;
            grid-template-rows: 1fr 1fr;
            gap: 6px;
        }
        .cz-input-layout .cz-flow-stack {
            height: 100%;
            min-height: 102px;
        }
        .cz-flow-stack button {
            min-height: 48px;
            padding: 7px 2px;
            font-size: 0.78rem;
            line-height: 1.12;
            font-weight: 900;
            flex-direction: column;
            gap: 2px;
            border-width: 0.5px;
        }
        .cz-flow-stack span { display: block; }
        .cz-flow-stack.cz-mu button {
            background: rgba(255, 98, 98, 0.10);
            border-color: rgba(255, 98, 98, 0.28);
        }
        .cz-flow-stack.cz-ik button {
            background: rgba(50, 201, 133, 0.10);
            border-color: rgba(50, 201, 133, 0.28);
        }
        .cz-flow-stack.cz-bi button {
            background: rgba(191, 90, 242, 0.10);
            border-color: rgba(191, 90, 242, 0.28);
        }

        .cz-input-layout .cz-flow-main {
            height: 100%;
            min-height: 102px;
            flex-direction: column;
            gap: 2px;
            padding: 8px 2px;
            line-height: 1.1;
        }
        .cz-flow-main span { display: block; }
        .cz-flow-fail { background: rgba(255, 98, 98, 0.10); border-color: rgba(255, 98, 98, 0.34); color: var(--red); }
        .cz-flow-hit { background: rgba(50, 201, 133, 0.10); border-color: rgba(50, 201, 133, 0.34); color: var(--green); }
        .cz-flow-special { background: rgba(50, 201, 133, 0.10); border-color: rgba(50, 201, 133, 0.34); color: var(--green); }

        .stat-row {
            display: grid;
            grid-template-columns: 42px 1fr;
            align-items: center;
            font-size: 0.85rem;
            height: 20px;
            column-gap: 4px;
        }

        .stat-values {
            display: grid;
            grid-template-columns: 48px 50px;
            gap: 4px;
            justify-content: end;
            align-items: baseline;
            font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
            font-variant-numeric: tabular-nums;
            text-align: right;
            white-space: nowrap;
        }

        .stat-values span:first-child,
        .stat-values span:last-child {
            display: inline-block;
            text-align: right;
        }

        .zone-stat-box {
            display: flex;
            flex-direction: column;
            align-items: center;
            background: rgba(255, 255, 255, 0.035);
            padding: 5px 0;
            border-radius: 8px;
        }

        #log-area {
            margin-top: 16px;
            font-size: 0.85rem;
            line-height: 1.5;
        }

        .log-section-label {
            margin: 16px 2px 7px;
            color: var(--t3);
            font-size: 0.72rem;
            font-weight: 900;
        }

        .log-empty {
            color: var(--t3);
            font-size: 0.82rem;
            padding: 8px 2px;
        }

        .log-row {
            display: grid;
            grid-template-columns: 42px 1fr;
            gap: 8px;
            align-items: flex-start;
            border-bottom: 0.5px solid var(--sep);
            padding: 8px 0;
        }

        .log-text { font-weight: 500; white-space: pre-wrap; min-width: 0; }
        .log-time {
            color: var(--t3);
            font-size: 0.75rem;
            white-space: nowrap;
            margin-top: 1px;
            font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
            font-variant-numeric: tabular-nums;
        }

        .summary-card {
            border: 0.5px solid var(--sep);
            border-left: 3px solid var(--gold);
            background: var(--s1);
            color: var(--t1);
            border-radius: 8px;
            margin-bottom: 10px;
            overflow: hidden;
        }

        .summary-card-head {
            display: grid;
            grid-template-columns: auto 1fr auto auto auto;
            align-items: center;
            gap: 5px;
            padding: 7px 8px;
            color: var(--t1);
            font-weight: 800;
            cursor: pointer;
        }

        .summary-date {
            width: 116px;
            color: var(--t1);
            font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
            font-size: 0.76rem;
            font-variant-numeric: tabular-nums;
            white-space: nowrap;
        }

        .summary-head-meta {
            color: var(--t3);
            font-size: 0.72rem;
            font-weight: 800;
            min-width: 0;
        }

        .summary-delete {
            min-width: 32px;
            min-height: 28px;
            padding: 4px 8px;
            border-radius: 6px;
            background: rgba(255,255,255,0.06);
            color: var(--t2);
            border: 0.5px solid rgba(255,255,255,0.08);
            font-size: 0.8rem;
            font-weight: 800;
        }

        .summary-delete.confirm {
            color: var(--red);
            background: rgba(255,98,98,0.10);
            border-color: rgba(255,98,98,0.34);
            min-width: 48px;
        }

        .summary-cancel {
            min-width: 52px;
            min-height: 28px;
            padding: 4px 8px;
            border-radius: 6px;
            background: rgba(255,255,255,0.06);
            color: var(--t2);
            border: none;
            font-size: 0.8rem;
        }

        .summary-body {
            display: none;
            padding: 0 7px 8px;
            border-top: 0.5px solid var(--sep);
            color: var(--t1);
        }

        .summary-card.open .summary-body { display: block; }
        .summary-card.open .summary-arrow { transform: rotate(180deg); }
        .summary-arrow { color: var(--t2); transition: transform .2s ease; }
        .summary-metric {
            background: rgba(255,255,255,0.035);
            border-radius: 8px;
            padding: 6px;
            margin-top: 6px;
        }

        .summary-bell-compact { display: flex; align-items: center; justify-content: flex-start; padding: 5px 6px; }
        .summary-combo-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 6px;
        }
        .summary-metric-title {
            display: flex;
            align-items: center;
            justify-content: flex-start;
            color: var(--t2);
            font-size: 0.72rem;
            font-weight: 800;
            margin-bottom: 4px;
        }

        .summary-bell-value {
            font-size: 0.78rem;
            color: var(--t1);
            font-weight: 900;
            font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
            font-variant-numeric: tabular-nums;
            line-height: 1.2;
            text-align: left;
        }

        .summary-value {
            display: grid;
            grid-template-columns: 2.5ch 0.5ch 1ch 1ch 4.8ch;
            justify-content: end;
            align-items: baseline;
            column-gap: 0;
            width: 96px;
            font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
            font-variant-numeric: tabular-nums;
            text-align: right;
            white-space: nowrap;
        }

        .summary-value .count {
            color: var(--t2);
            font-size: 0.66rem;
            text-align: right;
            padding-left: 3px;
        }

        .summary-stat-line {
            display: grid;
            grid-template-columns: 34px 1fr;
            align-items: center;
            gap: 4px;
            font-size: 0.74rem;
            padding: 2px 0;
            color: var(--t1);
        }

        .summary-stat-line > .summary-value {
            width: 96px;
        }

        .summary-stat-label.label-mu { color: var(--red); }
        .summary-stat-label.label-ik { color: var(--green); }
        .summary-stat-label.label-bi { color: var(--purple); }
        .summary-stat-label.label-total { color: var(--t1); }
        .summary-zone-grid {
            display: grid;
            grid-template-columns: repeat(5, 1fr);
            gap: 4px;
        }
        .summary-card .zone-stat-box {
            background: rgba(0,0,0,0.24);
            color: var(--t1);
            padding: 3px 0;
        }
        .summary-card .zone-stat-box div:first-child,
        .summary-card .zone-stat-box div:last-child { color: var(--t2) !important; }
        .summary-detail { margin-top: 8px; }
        .summary-detail summary {
            color: var(--t2);
            cursor: pointer;
            font-size: 0.75rem;
            font-weight: 800;
        }
        .summary-detail-list {
            color: var(--t2);
            font-size: 0.72rem;
            white-space: pre-wrap;
            margin-top: 6px;
            line-height: 1.45;
        }

        #bottom-bar {
            position: fixed;
            bottom: 0;
            left: 50%;
            transform: translateX(-50%);
            width: min(100%, 420px);
            background: rgba(17, 18, 21, .96);
            backdrop-filter: blur(16px);
            border-top: 0.5px solid rgba(255,255,255,0.18);
            display: grid;
            grid-template-columns: 1fr 1.2fr 1fr;
            gap: 8px;
            padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
            z-index: 1000;
        }

        #bottom-bar button {
            min-height: 52px;
            font-size: 0.84rem;
            padding: 8px 0;
            border: 0.5px solid var(--sep);
        }

        #btn-bell-nav {
            background: var(--gold);
            color: #0e0d08;
            font-weight: 900;
            font-size: 1rem !important;
            border: none !important;
        }
        #btn-reset { color: var(--gold); border-color: rgba(244,197,66,0.4) !important; }

