/* Chameleon Insight — 明るいアーカイブ調
   白い一覧の面に、両脇を紙の灰色の棚（絞り込み・詳細）で挟む。
   色は墨と罫線が基本。アクセントの常磐色は「選んでいるもの」だけに使う。 */

:root {
    --sheet: #ffffff;
    --paper: #f3f3ef;
    --paper-deep: #e9e9e3;
    --ink: #1f2226;
    --ink-2: #545960;
    --ink-3: #868b91;
    --rule: #dcddd7;
    --rule-strong: #c3c5be;
    --accent: #1d6b52;
    --accent-ink: #154f3c;
    --accent-wash: #e3eee8;
    --accent-wash-2: #cfe2d8;
    --danger: #a23a2a;

    --font-ui: 'IBM Plex Sans JP', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
    --font-title: 'Zen Old Mincho', 'Hiragino Mincho ProN', 'Yu Mincho', serif;

    --filters-w: 248px;
    --inspector-w: 432px;
    --radius: 4px;
    --gutter: 28px;

    color-scheme: light;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--sheet);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'palt' 0;
}

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

button {
    cursor: pointer;
}

svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

[hidden] {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

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

/* ---------- 骨組み（3列） ---------- */

.app {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--inspector-w);
    height: 100vh;
    height: 100dvh;
}

.app.has-filters {
    grid-template-columns: var(--filters-w) minmax(0, 1fr) var(--inspector-w);
}

.filters,
.browse,
.inspector {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* ---------- 左：絞り込み ---------- */

.filters {
    background: var(--paper);
    border-right: 1px solid var(--rule);
    padding: 20px 0 40px;
}

.filters-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 20px 14px;
}

.filters-title {
    flex: 1;
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.filters .filters-close {
    display: none;
}

.fgroup {
    border-top: 1px solid var(--rule);
}

.fgroup-head {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 12px 20px 10px;
    background: none;
    border: 0;
    text-align: left;
}

.fgroup-label {
    font-size: 14px;
    font-weight: 600;
}

.fgroup-hint {
    grid-column: 1 / -1;
    margin-top: -2px;
    font-size: 11.5px;
    color: var(--ink-3);
    line-height: 1.5;
}

.fgroup-selected {
    min-width: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.fgroup-head .chevron {
    width: 16px;
    height: 16px;
    color: var(--ink-3);
    transition: transform 0.15s ease;
}

.fgroup-head[aria-expanded='false'] .chevron {
    transform: rotate(-90deg);
}

.fgroup-body {
    padding: 0 12px 14px;
}

.fsection + .fsection {
    margin-top: 6px;
}

.fsection-title {
    margin: 6px 8px 2px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--ink-3);
}

.fopt {
    display: grid;
    grid-template-columns: 16px 1fr auto;
    align-items: center;
    gap: 9px;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1.45;
}

.fopt:hover {
    background: var(--paper-deep);
}

.fopt input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.fopt-box {
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--rule-strong);
    border-radius: 2px;
    background: var(--sheet);
    display: grid;
    place-items: center;
}

.fopt-box svg {
    width: 10px;
    height: 10px;
    stroke: #fff;
    stroke-width: 3;
    opacity: 0;
}

.fopt input:checked + .fopt-box {
    background: var(--accent);
    border-color: var(--accent);
}

.fopt input:checked + .fopt-box svg {
    opacity: 1;
}

.fopt input:focus-visible + .fopt-box {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.fopt input:checked ~ .fopt-label {
    color: var(--accent-ink);
    font-weight: 500;
}

.fopt-count {
    font-size: 11.5px;
    color: var(--ink-3);
    font-variant-numeric: tabular-nums;
}

.fopt.is-empty {
    color: var(--ink-3);
}

.fopt.is-empty .fopt-box {
    border-color: var(--rule);
}

.fmore {
    margin: 4px 8px 0;
}

/* ---------- 中央：検索と一覧 ---------- */

.browse {
    background: var(--sheet);
    padding: 0 var(--gutter) 64px;
    position: relative;
}

.masthead {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 24px;
    margin: 0 calc(var(--gutter) * -1);
    padding: 14px var(--gutter);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--rule);
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-shrink: 0;
}

.brand-mark {
    width: 26px;
    height: 26px;
    stroke: var(--accent);
    stroke-width: 2.4;
}

.brand-mark circle {
    fill: var(--accent);
    stroke: none;
}

.brand-name {
    font-family: var(--font-title);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.brand-env {
    padding: 1px 7px;
    border: 1px solid var(--rule-strong);
    border-radius: 3px;
    font-size: 11px;
    color: var(--ink-2);
}

.brand-env.is-dev {
    border-color: var(--danger);
    color: var(--danger);
}

.search {
    flex: 1;
    display: flex;
    gap: 8px;
    min-width: 0;
    max-width: 760px;
}

.search-field,
.select-field {
    position: relative;
    display: flex;
    align-items: center;
}

.search-field {
    flex: 1;
    min-width: 0;
}

.search-icon {
    position: absolute;
    left: 11px;
    width: 18px;
    height: 18px;
    color: var(--ink-3);
    pointer-events: none;
}

.search-input,
.channel-select {
    height: 38px;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    background: var(--sheet);
    font-size: 14px;
}

.search-input {
    width: 100%;
    padding: 0 12px 0 36px;
}

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

.search-input:focus,
.channel-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-wash);
}

.select-field {
    width: 188px;
    flex-shrink: 0;
}

.channel-select {
    width: 100%;
    padding: 0 32px 0 12px;
    appearance: none;
    text-overflow: ellipsis;
}

.select-icon {
    position: absolute;
    right: 9px;
    width: 18px;
    height: 18px;
    color: var(--ink-3);
    pointer-events: none;
}

.search-btn {
    height: 38px;
    padding: 0 18px;
    border: 0;
    border-radius: var(--radius);
    background: var(--ink);
    color: #fff;
    font-weight: 500;
    flex-shrink: 0;
}

.search-btn:hover {
    background: #34383e;
}

.search-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.results-bar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding: 28px 0 14px;
}

.results-heading {
    display: flex;
    align-items: baseline;
    gap: 14px;
    flex-wrap: wrap;
    min-width: 0;
}

.results-title {
    margin: 0;
    font-family: var(--font-title);
    font-size: 26px;
    font-weight: 700;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.results-count {
    margin: 0;
    font-size: 13px;
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}

.filter-toggle {
    display: none;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    background: var(--sheet);
    font-size: 13px;
    flex-shrink: 0;
}

.filter-toggle svg {
    width: 16px;
    height: 16px;
}

.filter-toggle-count:not(:empty) {
    margin-left: 2px;
    padding: 0 6px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    line-height: 17px;
}

.active-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding-bottom: 16px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 28px;
    padding: 0 6px 0 10px;
    border: 1px solid var(--accent-wash-2);
    border-radius: 3px;
    background: var(--accent-wash);
    color: var(--accent-ink);
    font-size: 12.5px;
}

.chip-group {
    color: var(--accent);
    opacity: 0.75;
    font-size: 11.5px;
}

.chip svg {
    width: 14px;
    height: 14px;
}

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

.progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    overflow: hidden;
}

.progress span {
    display: block;
    width: 30%;
    height: 100%;
    background: var(--accent);
    animation: progress 1.1s ease-in-out infinite;
}

@keyframes progress {
    from { transform: translateX(-100%); }
    to { transform: translateX(340%); }
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
    gap: 30px 22px;
    transition: opacity 0.15s ease;
}

.grid.is-loading {
    opacity: 0.45;
    pointer-events: none;
}

/* 一覧の終わりの目印（ここが見えそうになったら続きを読む） */
.grid-end {
    height: 1px;
}

.load-more {
    display: flex;
    gap: 12px;
    align-items: baseline;
    justify-content: center;
    padding: 28px 0 40px;
}

.load-more[hidden] {
    display: none;
}

.load-more-text {
    margin: 0;
    font-size: 13px;
    color: var(--ink-3);
}

.card {
    display: block;
    align-self: start;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    text-align: left;
}

.card:focus-visible {
    outline: none;
}

.thumb,
.card-body,
.card-tags {
    display: block;
}

.thumb {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: 3px;
    overflow: hidden;
    background: var(--paper-deep);
}

.thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: filter 0.15s ease;
}

.thumb.no-image::after {
    content: '画像なし';
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 12px;
    color: var(--ink-3);
}

.card:hover .thumb img {
    filter: brightness(0.92);
}

.card.selected .thumb,
.card:focus-visible .thumb {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.thumb-duration {
    position: absolute;
    right: 6px;
    bottom: 6px;
    padding: 1px 6px;
    border-radius: 2px;
    background: rgba(20, 22, 25, 0.82);
    color: #fff;
    font-size: 11.5px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.thumb-source {
    position: absolute;
    left: 6px;
    top: 6px;
    padding: 0 5px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--ink-2);
    font-size: 10.5px;
}

.card-body {
    padding-top: 11px;
}

.card-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.55;
}

.card.selected .card-title {
    color: var(--accent-ink);
}

.card-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 5px;
    font-size: 12px;
    color: var(--ink-2);
}

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

.card-date {
    flex-shrink: 0;
    color: var(--ink-3);
    font-variant-numeric: tabular-nums;
}

.card-tags {
    margin-top: 6px;
    font-size: 12px;
    color: var(--accent-ink);
    line-height: 1.5;
}

.card-tags .sep {
    margin: 0 0.3em;
    color: var(--rule-strong);
    font-weight: 300;
}

.notice {
    padding: 56px 0;
    max-width: 34em;
}

.notice-text {
    margin: 0 0 12px;
    font-size: 15px;
    color: var(--ink-2);
}

.notice.is-error .notice-text {
    color: var(--danger);
}

.text-btn {
    padding: 2px 0;
    border: 0;
    background: none;
    color: var(--accent);
    font-size: 13px;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: var(--accent-wash-2);
}

.text-btn:hover {
    text-decoration-color: currentColor;
}

.text-btn:disabled {
    color: var(--ink-3);
    text-decoration: none;
    cursor: default;
}

.icon-btn {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: var(--radius);
    background: none;
    color: var(--ink-2);
}

.icon-btn:hover {
    background: var(--paper-deep);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

/* ---------- 右：詳細 ---------- */

.inspector {
    position: relative;
    background: var(--paper);
    border-left: 1px solid var(--rule);
}

.inspector-close {
    display: none;
}

.inspector-scroll {
    padding: 26px 26px 48px;
}

.inspector-empty {
    margin: 40px 0;
    color: var(--ink-3);
}

.detail-title {
    margin: 0;
    font-family: var(--font-title);
    font-size: 20px;
    font-weight: 700;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.detail-channel {
    display: inline-block;
    margin-top: 6px;
    color: var(--ink-2);
    font-size: 13px;
    text-decoration: none;
}

.detail-channel:hover {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.detail-meta {
    display: flex;
    gap: 28px;
    margin: 14px 0 18px;
}

.detail-meta dt {
    font-size: 11.5px;
    color: var(--ink-3);
}

.detail-meta dd {
    margin: 0;
    font-size: 13.5px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.player {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius);
    overflow: hidden;
    background: #16181b;
}

.player video,
.player iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    object-fit: contain;
}

.player-source {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 0 6px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--ink-2);
    font-size: 10.5px;
    pointer-events: none;
}

.detail-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}

.btn-outline {
    border: 1px solid var(--rule-strong);
    background: var(--sheet);
    color: var(--ink);
}

.btn-outline:hover {
    border-color: var(--ink-2);
}

.btn-ink {
    border: 1px solid var(--ink);
    background: var(--ink);
    color: #fff;
}

.btn-ink:hover {
    background: #34383e;
}

.btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.action-message {
    margin: 8px 0 0;
    font-size: 12.5px;
    color: var(--danger);
}

.detail-section {
    margin-top: 26px;
    padding-top: 16px;
    border-top: 1px solid var(--rule);
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.section-head h3,
.description summary h3 {
    margin: 0;
    font-size: 13.5px;
    font-weight: 600;
}

.section-note {
    font-size: 11.5px;
    color: var(--ink-3);
    text-align: right;
}

/* 尺割り：CMの組み立てを秒の長さどおりに並べた帯 */

.conte-timeline {
    margin-bottom: 14px;
}

.conte-strip {
    display: flex;
    gap: 2px;
    height: 44px;
}

.conte-seg {
    position: relative;
    min-width: 6px;
    padding: 0 5px;
    border: 0;
    border-radius: 2px;
    background: var(--accent-wash-2);
    color: var(--accent-ink);
    font-size: 11.5px;
    font-weight: 500;
    line-height: 44px;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
    transition: background 0.12s ease, color 0.12s ease;
}

.conte-seg:nth-child(even) {
    background: var(--accent-wash);
}

.conte-seg.is-narrow {
    color: transparent;
}

/* 絵コンテに書かれていない時間（尺より手前で絵コンテが終わっているとき） */
.conte-gap {
    border: 1px dashed var(--rule-strong);
    border-radius: 2px;
}

.conte-row.is-outside {
    color: var(--ink-3);
}

.conte-row.is-outside:hover {
    border-left-color: transparent;
    background: none;
}

.conte-outside-note {
    display: block;
    margin-top: 2px;
    font-size: 11.5px;
}

.conte-seg:hover,
.conte-seg.is-active {
    background: var(--accent);
    color: #fff;
}

.conte-ruler {
    position: relative;
    height: 20px;
    margin-top: 4px;
    border-top: 1px solid var(--rule-strong);
}

.conte-tick {
    position: absolute;
    top: -1px;
    width: 1px;
    height: 5px;
    background: var(--rule-strong);
}

.conte-tick.is-major {
    height: 8px;
    background: var(--ink-3);
}

.conte-tick-label {
    position: absolute;
    top: 7px;
    white-space: nowrap;
    transform: translateX(-50%);
    font-size: 10.5px;
    color: var(--ink-3);
    font-variant-numeric: tabular-nums;
}

.conte-tick-label.is-end {
    transform: translateX(-100%);
}

.conte-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.conte-row {
    display: grid;
    grid-template-columns: 74px 1fr;
    gap: 10px;
    width: 100%;
    padding: 8px 8px 8px 6px;
    border: 0;
    border-left: 2px solid transparent;
    border-radius: 0 3px 3px 0;
    background: none;
    text-align: left;
    font-size: 13px;
    line-height: 1.6;
}

.conte-row:hover,
.conte-row.is-active {
    border-left-color: var(--accent);
    background: var(--sheet);
}

.conte-time {
    color: var(--ink-3);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    padding-top: 1px;
}

.conte-beat {
    font-weight: 600;
    margin-right: 0.5em;
}

/* タグ */

.tag-table {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 8px 12px;
    margin: 0;
}

.tag-table dt {
    font-size: 12px;
    color: var(--ink-3);
    padding-top: 3px;
}

.tag-table dd {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: baseline;
}

.tag-btn {
    padding: 2px 8px;
    border: 1px solid var(--rule-strong);
    border-radius: 3px;
    background: var(--sheet);
    font-size: 12.5px;
    line-height: 1.5;
}

button.tag-btn:hover {
    border-color: var(--accent);
    color: var(--accent-ink);
}

.tag-btn.is-on {
    border-color: var(--accent);
    background: var(--accent-wash);
    color: var(--accent-ink);
}

.tag-sub {
    font-size: 12px;
    color: var(--ink-2);
}

.tag-empty {
    font-size: 12.5px;
    color: var(--ink-3);
}

/* 総評・構造分析 */

.summary-text {
    margin: 0;
    font-size: 14px;
    line-height: 1.85;
}

.analysis-block + .analysis-block {
    margin-top: 16px;
}

.analysis-block h4 {
    margin: 0 0 6px;
    font-size: 13px;
    font-weight: 600;
}

.analysis-row {
    display: grid;
    grid-template-columns: 34px 1fr;
    gap: 8px;
    font-size: 13px;
    line-height: 1.75;
}

.analysis-row + .analysis-row {
    margin-top: 6px;
}

.analysis-kind {
    font-size: 11.5px;
    color: var(--ink-3);
    padding-top: 2px;
}

.analysis-row p {
    margin: 0;
    color: var(--ink);
}

.analysis-row.is-hypothesis p {
    color: var(--ink-2);
}

/* 出演者 */

.cast-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.cast-item + .cast-item {
    margin-top: 10px;
}

.cast-name {
    font-weight: 600;
    font-size: 13.5px;
}

.cast-confidence {
    margin-left: 8px;
    font-size: 11.5px;
    color: var(--ink-3);
}

.cast-confidence.is-high {
    color: var(--accent);
}

.cast-role {
    margin: 2px 0 0;
    font-size: 12.5px;
    color: var(--ink-2);
    line-height: 1.6;
}

/* YouTubeでの反応：数値は YouTube の値、枠つきの「Chameleonの記録」は自前の記録 */

.tracking > :not(.section-head) {
    transition: opacity 0.15s;
}

.tracking.is-loading > :not(.section-head) {
    opacity: 0.45;
}

.tracking-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    font-size: 13.5px;
    font-weight: 500;
}

.status-dot {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.is-on {
    background: var(--ink);
}

.status-dot.is-off {
    border: 1.5px solid var(--ink-3);
}

.stat-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 16px;
}

.stat-row > div {
    padding: 8px 10px;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--sheet);
}

.stat-row dt {
    font-size: 11.5px;
    color: var(--ink-3);
}

.stat-row dd {
    margin: 2px 0 0;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.stat-row dd.is-none {
    font-weight: 400;
    color: var(--ink-3);
    cursor: help;
}

.views-chart {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 8px;
    margin: 0 0 16px;
}

.chart-caption {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 10px;
    font-size: 12px;
    color: var(--ink-2);
}

.chart-caption span {
    font-size: 11px;
    color: var(--ink-3);
}

.chart-area {
    display: contents;
}

.chart-yaxis {
    position: relative;
    font-size: 10.5px;
    color: var(--ink-3);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.chart-yaxis span {
    position: absolute;
    right: 0;
    transform: translateY(-50%);
    white-space: nowrap;
}

.chart-yaxis .chart-yaxis-sizer {
    position: static;
    display: block;
    height: 0;
    visibility: hidden;
    transform: none;
}

.chart-plot {
    position: relative;
    height: 72px;
    margin-right: 5px;
    cursor: crosshair;
    touch-action: pan-y;
}

.chart-plot svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.chart-grid {
    stroke: var(--rule-strong);
    stroke-width: 1;
    stroke-dasharray: 2 3;
    vector-effect: non-scaling-stroke;
}

.chart-line {
    fill: none;
    stroke: var(--ink);
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
}

.chart-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    margin: -4px 0 0 -4px;
    border-radius: 50%;
    background: var(--ink);
    box-shadow: 0 0 0 2px var(--paper);
    pointer-events: none;
}

.chart-cross {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--rule-strong);
    pointer-events: none;
}

.chart-tip {
    position: absolute;
    bottom: calc(100% + 6px);
    display: flex;
    gap: 6px;
    padding: 3px 8px;
    border-radius: 3px;
    background: var(--ink);
    color: #fff;
    font-size: 11.5px;
    white-space: nowrap;
    transform: translateX(-50%);
    pointer-events: none;
}

.chart-tip.is-right {
    transform: translateX(-100%);
}

.chart-tip.is-left {
    transform: none;
}

.chart-tip strong {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.chart-xaxis {
    grid-column: 2;
    display: flex;
    justify-content: space-between;
    margin: 4px 0 0;
    font-size: 10.5px;
    color: var(--ink-3);
}

.tracking-record {
    margin: 0 0 12px;
    padding: 8px 10px;
    border: 1px dashed var(--rule-strong);
    border-radius: var(--radius);
    font-size: 12.5px;
    color: var(--ink-2);
}

.record-tag {
    display: block;
    margin-bottom: 2px;
    font-size: 11px;
    font-weight: 600;
    color: var(--ink-3);
}

.tracking-record p {
    margin: 0;
    line-height: 1.7;
}

.tracking-days summary {
    font-size: 12.5px;
    color: var(--ink-2);
    cursor: pointer;
}

.days-table {
    width: 100%;
    margin-top: 8px;
    border-collapse: collapse;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
}

.days-table th,
.days-table td {
    padding: 4px 6px;
    border-bottom: 1px solid var(--rule);
    text-align: right;
}

.days-table th:first-child {
    text-align: left;
    font-weight: 400;
}

.days-table thead th {
    font-size: 11px;
    font-weight: 400;
    color: var(--ink-3);
}

.days-table tr.is-missing td {
    text-align: left;
    color: var(--ink-3);
}

/* 概要欄 */

.description summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    list-style: none;
}

.description summary::-webkit-details-marker {
    display: none;
}

.description .chevron {
    width: 16px;
    height: 16px;
    color: var(--ink-3);
    transform: rotate(-90deg);
    transition: transform 0.15s ease;
}

.description[open] .chevron {
    transform: none;
}

.description-text {
    margin: 12px 0 0;
    font-size: 12.5px;
    color: var(--ink-2);
    line-height: 1.8;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.download-spinner {
    width: 13px;
    height: 13px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.scrim {
    display: none;
}

/* ---------- 狭い画面 ---------- */

/* 詳細を右から重ねる */
@media (max-width: 1240px) {
    .app,
    .app.has-filters {
        grid-template-columns: minmax(0, 1fr);
    }

    .app.has-filters {
        grid-template-columns: var(--filters-w) minmax(0, 1fr);
    }

    .inspector {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 30;
        width: min(var(--inspector-w), 100vw);
        transform: translateX(100%);
        transition: transform 0.2s ease;
    }

    .app.inspector-open .inspector {
        transform: none;
        box-shadow: -12px 0 32px rgba(31, 34, 38, 0.14);
    }

    .inspector-close {
        display: grid;
        position: sticky;
        top: 10px;
        float: right;
        margin: 10px 10px 0 0;
        z-index: 2;
        background: var(--paper);
    }

    .inspector-scroll {
        padding-top: 14px;
    }

    .app.inspector-open .scrim,
    .app.filters-open .scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 20;
        background: rgba(31, 34, 38, 0.28);
    }
}

/* 絞り込みを左から重ねる */
@media (max-width: 900px) {
    :root {
        --gutter: 16px;
    }

    .app.has-filters {
        grid-template-columns: minmax(0, 1fr);
    }

    .filters {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 30;
        width: min(300px, 88vw);
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    .app.filters-open .filters {
        transform: none;
        box-shadow: 12px 0 32px rgba(31, 34, 38, 0.14);
    }

    .filters .filters-close {
        display: grid;
    }

    .filter-toggle {
        display: inline-flex;
    }

    .masthead {
        position: relative;
        flex-wrap: wrap;
        gap: 10px;
    }

    .search {
        flex-basis: 100%;
        flex-wrap: wrap;
    }

    .search-field {
        flex-basis: 100%;
    }

    .select-field {
        flex: 1;
        width: auto;
        min-width: 0;
    }

    .results-title {
        font-size: 22px;
    }

    .grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 22px 14px;
    }
}

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

/* ---------- ログイン（auth.js。ログインが要る環境だけ） ---------- */

/* ログインが済むまで一覧は出さない */
.auth-on:not(.auth-ok) .app {
    display: none;
}

.auth {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 40px 16px;
    background: var(--paper);
}

.auth[hidden] {
    display: none;
}

.auth-panel {
    width: 100%;
    max-width: 400px;
    padding: 32px 32px 28px;
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: 6px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 28px;
}

.auth-title {
    margin: 0 0 10px;
    font-family: var(--font-title);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.auth-lead {
    margin: 0 0 20px;
    font-size: 13.5px;
    line-height: 1.75;
    color: var(--ink-2);
    overflow-wrap: anywhere;
}

.auth-lead strong {
    font-weight: 600;
    color: var(--ink);
}

.auth form {
    display: grid;
    gap: 16px;
    margin-top: 22px;
}

.auth-lead + form {
    margin-top: 0;
}

.auth-field {
    display: grid;
    gap: 6px;
}

.auth-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-2);
}

.auth-input {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    background: var(--sheet);
    font-size: 16px; /* 16px より小さいと iPhone で拡大される */
}

.auth-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-wash);
}

.auth-code {
    font-size: 20px;
    letter-spacing: 0.3em;
    font-variant-numeric: tabular-nums;
}

.auth-pass {
    position: relative;
    display: block;
}

.auth-pass .auth-input {
    padding-right: 64px;
}

.auth-reveal {
    position: absolute;
    top: 50%;
    right: 6px;
    height: 32px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--radius);
    background: none;
    color: var(--ink-2);
    font-size: 12.5px;
    transform: translateY(-50%);
}

.auth-reveal:hover {
    background: var(--paper);
}

.auth-hint {
    font-size: 12px;
    color: var(--ink-3);
}

.auth-submit {
    height: 46px;
    margin-top: 4px;
    border: 0;
    border-radius: var(--radius);
    background: var(--ink);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
}

.auth-submit:hover {
    background: #34383e;
}

.auth-submit:disabled {
    opacity: 0.6;
    cursor: default;
}

.auth-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 16px;
    margin-top: 20px;
    font-size: 13px;
    color: var(--ink-2);
}

.auth-message {
    margin: 16px 0 0;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: var(--accent-wash);
    color: var(--accent-ink);
    font-size: 13px;
    line-height: 1.6;
}

.auth-message.is-error {
    background: #f6e7e4;
    color: var(--danger);
}

.auth-note {
    margin: 16px 0 0;
    font-size: 12px;
    line-height: 1.7;
    color: var(--ink-3);
}

.auth-foot {
    margin: 0;
    font-size: 12px;
    color: var(--ink-3);
    text-align: center;
}

/* 上の帯のアカウント。帯が狭いとき（詳細を開いているときなど）はメールアドレスを出さない */
.masthead {
    container-type: inline-size;
}

.account {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: 10px;
    margin-left: auto;
    font-size: 12.5px;
    color: var(--ink-2);
}

@container (max-width: 1080px) {
    .account-email,
    .account-admin {
        display: none;
    }

    /* 検索の欄に幅を回す（狭い画面の 1 行目・2 行目の並びでは flex で決まるので効かない） */
    .select-field {
        width: 150px;
    }
}

.account[hidden] {
    display: none;
}

.account-email {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-admin {
    flex-shrink: 0;
    padding: 1px 7px;
    border: 1px solid var(--accent);
    border-radius: 3px;
    color: var(--accent);
    font-size: 11px;
}

.account .text-btn {
    flex-shrink: 0;
    font-size: 12.5px;
}

@media (max-width: 900px) {
    /* 狭い画面では、ロゴとアカウントを1行目、検索を2行目に */
    .masthead .account {
        order: 1;
    }

    .masthead .search {
        order: 2;
    }
}

@media (max-width: 520px) {
    .auth {
        justify-content: flex-start;
        padding-top: 24px;
    }

    .auth-panel {
        padding: 24px 20px;
    }
}
