/* 閲覧者画面（選択チェーン）スタイル
   ログイン・現場選択・サイネージ選択を一つのデザイン言語（管理画面＝vsel 準拠）に統一し、
   テーマ（system / light / dark）で切り替える。濃色ヘッダーは両テーマ共通の意匠として固定。
   全画面プレイヤー（vplay / display-grid / slideshow / widget-*）は常時黒のためテーマ不変。 */

:root {
    --btn-radius:  6px;
    --btn-padding: 0.65rem 1.4rem;
    /* 外観トークン（ライト既定。ダークは :root[data-theme="dark"] で上書き） */
    --v-bg:       #f6f7f9;
    --v-surface:  #ffffff;
    --v-border:   #e6e8ec;
    --v-text:     #11151c;
    --v-text-1:   #1c2128;
    --v-muted:    #6b727e;
    --v-faint:    #9aa1ab;
    --v-code-bg:  #eef0f3;
    --v-code-fg:  #3d434d;
}
:root[data-theme="dark"] {
    --v-bg:       #14181e;
    --v-surface:  #1b212b;
    --v-border:   #2d3540;
    --v-text:     #e8ecf2;
    --v-text-1:   #dce1e8;
    --v-muted:    #98a0ab;
    --v-faint:    #6c7682;
    --v-code-bg:  #2b323d;
    --v-code-fg:  #aab2bd;
}

html, body { height: 100%; }
body { font-family: system-ui, -apple-system, sans-serif; background: var(--v-bg); color: var(--v-text); }

/* ヘッダー（統一: 濃色バー・両テーマ共通） */
.viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #0f1318;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid #1d232c;
    height: 52px;
}
.viewer-header-compact { height: 48px; padding: 0.5rem 1rem; }
.header-title { font-size: 1rem; font-weight: 700; color: #fff; }
.header-back  { color: #90cdf4; text-decoration: none; font-size: 0.9rem; background: none; border: none; cursor: pointer; }
.header-back:hover { color: #63b3ed; }
.viewer-header-right { display: flex; align-items: center; gap: 12px; }
.btn-logout {
    background: transparent;
    border: 1px solid #2b3440;
    color: #aab0ba;
    padding: 0.3rem 0.8rem;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.875rem;
}
.btn-logout:hover { border-color: #3a4350; color: #fff; background: #1a212b; }

/* ライト時の上部ヘッダー帯は真っ黒を避けグレー基調に和らげる（ダークは黒のまま背景に馴染ませる）。
   段差色（利用者チップ・ログアウト hover・境界）も地に合わせて持ち上げる。 */
:root[data-theme="light"] .viewer-header,
:root[data-theme="light"] .vsel-header { background: #383e48; }
:root[data-theme="light"] .viewer-header { border-bottom-color: #474e59; }
:root[data-theme="light"] .vsel-user { background: #434a55; }
:root[data-theme="light"] .btn-logout,
:root[data-theme="light"] .vsel-logout { border-color: #4a515c; }
:root[data-theme="light"] .btn-logout:hover,
:root[data-theme="light"] .vsel-logout:hover { background: #464d58; }

/* 全画面ボタン（濃色文脈で使用） */
.btn-fullscreen {
    background: transparent;
    border: 1px solid #4a5568;
    color: #a0aec0;
    padding: 0.25rem 0.6rem;
    cursor: pointer;
    border-radius: 4px;
    font-size: 1.1rem;
    line-height: 1;
}
.btn-fullscreen:hover { border-color: #718096; color: #e2e8f0; }

/* オフライン警告バナー（警告色・テーマ不変） */
.offline-banner {
    background: #7b341e;
    color: #fbd38d;
    text-align: center;
    padding: 0.4rem 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid #c05621;
}

/* ページ共通 */
.page-content { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }
.section-title { font-size: 1.25rem; font-weight: 600; margin-bottom: 1.25rem; color: var(--v-text); }
.loading-text, .empty-text { color: var(--v-faint); padding: 2rem 0; text-align: center; }
.error-msg { color: #e5484d; font-size: 0.9rem; padding: 0.5rem 0; }
.success-msg { color: #2f9e6a; font-size: 0.9rem; padding: 0.5rem 0.75rem; background: rgba(47, 158, 106, .12); border-radius: 4px; margin-bottom: 1rem; }
.loading-screen, .error-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: calc(100vh - 52px);
    font-size: 1.1rem;
    color: var(--v-muted);
}

/* 検索入力 */
.search-input {
    width: 100%;
    max-width: 400px;
    padding: 0.6rem 1rem;
    background: var(--v-surface);
    border: 1px solid var(--v-border);
    border-radius: 8px;
    color: var(--v-text);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}
.search-input:focus { outline: none; border-color: var(--color-primary); }

/* 工事現場グリッド */
.site-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}
.site-card {
    display: block;
    background: var(--v-surface);
    border: 1px solid var(--v-border);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    text-decoration: none;
    transition: border-color 0.15s, transform 0.1s;
    cursor: pointer;
}
.site-card:hover { border-color: var(--color-primary); transform: translateY(-2px); }
.site-card-name { font-size: 1.05rem; font-weight: 600; color: var(--v-text); margin-bottom: 0.4rem; }
.site-card-meta { font-size: 0.85rem; color: var(--v-faint); }

/* サイネージグリッド */
.signage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}
.signage-card {
    display: block;
    background: var(--v-surface);
    border: 1px solid var(--v-border);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    text-decoration: none;
    transition: border-color 0.15s, transform 0.1s;
    cursor: pointer;
}
.signage-card:hover { border-color: var(--color-primary); transform: translateY(-2px); }
.signage-card-name { font-size: 1rem; font-weight: 600; color: var(--v-text); margin-bottom: 0.4rem; }
.signage-card-meta { font-size: 0.8rem; color: var(--v-faint); }

/* ログインフォーム */
.login-step-hint  { margin-bottom: 1rem; font-size: .875rem; color: var(--v-muted); }
.form-submit-area { margin-top: 1.5rem; }
.login-wrap { display: flex; justify-content: center; align-items: center; min-height: 100vh; }
.login-card {
    background: var(--v-surface);
    border: 1px solid var(--v-border);
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .12);
}
.login-title { font-size: 1.6rem; font-weight: 700; text-align: center; margin-bottom: 2rem; color: var(--v-text); }
.form-group { margin-bottom: 1.1rem; }
.form-label { display: block; font-size: 0.875rem; margin-bottom: 0.4rem; color: var(--v-muted); }
.form-input {
    width: 100%;
    padding: 0.65rem 0.9rem;
    background: var(--v-surface);
    border: 1px solid var(--v-border);
    border-radius: 6px;
    color: var(--v-text);
    font-size: 1rem;
    box-sizing: border-box;
}
.form-input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(74, 111, 165, .25); }
/* ログイン画面右上のテーマトグル（ヘッダーが無いため固定配置） */
.login-theme { position: fixed; top: 16px; right: 16px; z-index: 10; }

/* ============================================================
   テーマ切替トグル（濃色ヘッダー上。ログインのみサーフェス調に上書き）
   ============================================================ */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border-radius: 9px;
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .12);
}
.theme-seg {
    width: 28px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    border: none;
    border-radius: 7px;
    background: none;
    color: #9aa1ab;
    cursor: pointer;
}
.theme-seg:hover { color: #fff; }
.theme-seg.active { background: rgba(255, 255, 255, .16); color: #fff; }
.theme-seg-ic { width: 16px; height: 16px; display: block; }
/* ログイン（本文上）のトグルは中立面＋サーフェスの押下調 */
.login-theme .theme-toggle { background: var(--v-code-bg); border: 1px solid var(--v-border); }
.login-theme .theme-seg { color: var(--v-faint); }
.login-theme .theme-seg:hover { color: var(--v-text); }
.login-theme .theme-seg.active { background: var(--v-surface); color: var(--v-text); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }

/* ============================================================
   サイネージ表示レイアウト＋スライドショー（全画面プレイヤー）
   ※ ここから下はプレイヤー（vplay-root）専用＝常時黒のためテーマ不変。
   ============================================================ */
.display-grid {
    display: grid;
    height: calc(100vh - 48px);
    gap: 2px;
    background: #2d3748; /* gap がペイン境界線として見える */
}
.display-grid.single              { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.display-grid.two_pane_vertical   { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
.display-grid.two_pane_horizontal { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
.display-pane {
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #0f0f1a;
}

/* スライドショー */
.slideshow-panel { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; touch-action: none; }
.slideshow-container { flex: 1; overflow: hidden; position: relative; }
.slideshow-img,
.slideshow-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: #0f0f1a;
}
.slideshow-indicator {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 0.5rem;
    background: #0f0f1a;
}
.slideshow-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: #4a5568;
}
.dot        { width: 8px; height: 8px; border-radius: 50%; background: #4a5568; cursor: pointer; }
.dot:hover  { background: #718096; }
.dot-active { background: var(--color-primary); }

/* 動的ウィジェット（アラート） */
.slideshow-widget { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.5rem; padding: 4vw; box-sizing: border-box; text-align: center; }
.widget-alert { color: #fff; }
.widget-alert-info { background: #2f6fd0; }
.widget-alert-warn { background: #d99211; }
.widget-alert-critical { background: #d9483b; }
.widget-alert-title { font-size: 6vw; font-weight: 800; line-height: 1.2; }
.widget-alert-body { font-size: 3.5vw; font-weight: 500; line-height: 1.4; }

/* 天気ウィジェット */
.widget-weather { background: linear-gradient(160deg, #1e3a5f, #2f6fd0); color: #fff; }
.widget-weather-head { font-size: 4vw; font-weight: 800; }
.widget-weather-today { font-size: 5vw; font-weight: 600; }
.widget-weather-obs { display: flex; gap: 2.5vw; font-size: 3vw; opacity: .92; }
.widget-weather-temp { font-weight: 800; }
.widget-weather-fallback { font-size: 3vw; opacity: .85; }

/* 工程ウィジェット */
.widget-progress { background: linear-gradient(160deg, #0f3d36, #1f9e8a); color: #fff; }
.widget-progress-head { font-size: 4vw; font-weight: 800; }
.widget-progress-status { font-size: 3.5vw; font-weight: 600; }
.widget-progress-bar { width: 70%; height: 3vw; background: rgba(255,255,255,.25); border-radius: 1.5vw; overflow: hidden; }
.widget-progress-fill { height: 100%; background: #fff; }
.widget-progress-pct { font-size: 5vw; font-weight: 800; }
.widget-progress-period { font-size: 2.5vw; opacity: .85; }


/* ============================================================
   ビューアー サイネージ選択（単一ページ・Claude Design モック準拠）
   濃色ヘッダー＋トークン化した本文。テーマ追従。
   ============================================================ */
.vsel-root { position: fixed; inset: 0; background: var(--v-bg); display: flex; flex-direction: column; overflow: hidden; color: var(--v-text); }
.vsel-header { flex: none; height: 60px; background: #0f1318; display: flex; align-items: center; gap: 14px; padding: 0 22px; color: #fff; }
.vsel-brand-ic { width: 20px; height: 20px; color: #fff; flex: none; display: inline-flex; }
.vsel-brand { line-height: 1.2; }
.vsel-brand-name { font-size: 14px; font-weight: 700; color: #fff; }
.vsel-brand-sub { font-size: 10.5px; color: #727b88; font-family: 'IBM Plex Mono', monospace; letter-spacing: .05em; }
.vsel-header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.vsel-user { display: flex; flex-direction: column; background: #161c24; border-radius: 9px; padding: 6px 11px; line-height: 1.25; }
.vsel-user-name { font-size: 11.5px; font-weight: 600; color: #e7eaef; }
.vsel-user-role { font-size: 9.5px; color: #7c8593; }
.vsel-logout { border: 1px solid #2b3440; background: transparent; color: #aab0ba; border-radius: 8px; font-family: inherit; font-size: 11.5px; font-weight: 600; padding: 8px 13px; cursor: pointer; transition: background .12s, color .12s; }
.vsel-logout:hover { background: #1a212b; color: #fff; }

.vsel-body { flex: 1; overflow-y: auto; padding: 30px 26px; }
.vsel-inner { max-width: 1080px; margin: 0 auto; }
.vsel-head { margin-bottom: 24px; }
.vsel-title { font-size: 22px; font-weight: 700; color: var(--v-text); }
.vsel-sub { font-size: 13px; color: var(--v-muted); margin-top: 4px; }
.vsel-state { text-align: center; color: var(--v-muted); padding: 48px 0; font-size: 13px; }

.vsel-section { margin-bottom: 26px; }
.vsel-section-head { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; flex-wrap: wrap; }
.vsel-code { font-family: 'IBM Plex Mono', monospace; font-size: 10px; font-weight: 600; color: var(--v-code-fg); background: var(--v-code-bg); border-radius: 6px; padding: 3px 7px; }
.vsel-site-name { font-size: 14px; font-weight: 700; color: var(--v-text); }
.vsel-access { font-size: 10.5px; font-weight: 600; border-radius: 20px; padding: 3px 9px; }
.vsel-access-public { color: #d99211; background: #fbf3e1; }
.vsel-access-restricted { color: #2f6fd0; background: #eaf1fb; }
.vsel-addr { font-size: 11.5px; color: var(--v-faint); }
.vsel-section-empty { font-size: 12px; color: var(--v-faint); padding: 6px 2px 2px; }

.vsel-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 13px; }
.vsel-card { background: var(--v-surface); border: 1px solid var(--v-border); border-radius: 13px; padding: 14px 15px; cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.vsel-card:hover { border-color: var(--v-text); box-shadow: 0 6px 18px rgba(0, 0, 0, .12); }
.vsel-preview { height: 74px; border-radius: 9px; background: #0f1318; display: flex; align-items: center; justify-content: center; margin-bottom: 11px; }
.vsel-preview-ic { width: 22px; height: 22px; color: #3a434f; display: inline-flex; }
.vsel-card-name { font-size: 13px; font-weight: 700; color: var(--v-text-1); margin-bottom: 3px; }
.vsel-card-loc { font-size: 12px; color: var(--v-muted); margin-bottom: 8px; min-height: 15px; }
.vsel-card-foot { display: flex; align-items: center; justify-content: flex-end; padding-top: 9px; border-top: 1px solid var(--v-border); }
.vsel-show { font-size: 11px; font-weight: 600; color: var(--v-text); }

/* 選択ページのフォント（モック準拠・プレイヤーには影響させずスコープ） */
.vsel-root { font-family: "IBM Plex Sans JP", system-ui, -apple-system, sans-serif; }

/* 閲覧レベルのティント（淡色）はダークでは沈ませ、前景は読める明度に上げる */
:root[data-theme="dark"] .vsel-access-public { background: rgba(217, 146, 17, .18); color: #e0a64a; }
:root[data-theme="dark"] .vsel-access-restricted { background: rgba(47, 111, 208, .20); color: #74aaf0; }

/* ============================================================
   プレイヤー（全画面再生）— Claude Design モック準拠の黒背景＋フロストオーバーレイ
   ※ 常時黒のためテーマ不変。
   ============================================================ */
.vplay-root { position: fixed; inset: 0; background: #000; overflow: hidden; }
.vplay-root .display-grid { position: absolute; inset: 0; }
.vplay-root .loading-screen, .vplay-root .error-screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.vplay-root .offline-banner { position: absolute; top: 78px; left: 50%; transform: translateX(-50%); z-index: 4; }

/* 上オーバーレイ: コンテナは pointer-events:none、ボックスのみ auto（コンテンツのジェスチャを殺さない） */
.vplay-top { position: absolute; top: 0; left: 0; right: 0; z-index: 3; display: flex; align-items: flex-start; justify-content: space-between; padding: 22px 26px; pointer-events: none; }

/* コンテンツ以外のオーバーレイ（上バー・下バッジ）の表示/非表示。
   全画面突入で隠し、シングルタップでトグルする。visibility:hidden で子孫
   （ボタン・ドット）の当たり判定も無効化し、タップが背面コンテンツへ抜けて
   再表示できるようにする。フェードアウト後に visibility を切る。 */
.vplay-top, .vplay-bottom { transition: opacity .28s ease, visibility 0s; }
.vplay-top.vplay-hidden, .vplay-bottom.vplay-hidden {
  opacity: 0; visibility: hidden; transition: opacity .28s ease, visibility 0s linear .28s;
}
.vplay-info, .vplay-ctrls > * { pointer-events: auto; }
.vplay-info { background: rgba(12, 15, 20, .55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-radius: 11px; padding: 10px 15px; line-height: 1.3; }
.vplay-name { font-size: 14px; font-weight: 700; color: #fff; }
.vplay-loc { font-size: 11.5px; color: rgba(255, 255, 255, .7); font-family: 'IBM Plex Mono', monospace; }
.vplay-ctrls { display: flex; align-items: center; gap: 10px; }
.vplay-status { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: #37d27e; background: rgba(12, 15, 20, .55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-radius: 11px; padding: 10px 13px; }
.vplay-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #37d27e; }
.vplay-clock { font-family: 'IBM Plex Mono', monospace; font-size: 15px; font-weight: 600; color: #fff; letter-spacing: .04em; background: rgba(12, 15, 20, .55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-radius: 11px; padding: 9px 13px; }
.vplay-btn { border: none; background: rgba(12, 15, 20, .55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); color: #fff; border-radius: 11px; font-family: inherit; font-size: 11.5px; font-weight: 600; padding: 11px 14px; cursor: pointer; transition: background .12s; }
.vplay-btn:hover { background: rgba(40, 46, 55, .8); }
.vplay-fs { font-size: 15px; line-height: 1; padding: 9px 12px; }

/* 下オーバーレイ: 種別バッジ＋位置＋ドット（slideshow-container 内に絶対配置） */
.vplay-bottom { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; display: flex; align-items: center; gap: 14px; padding: 16px 22px; background: linear-gradient(to top, rgba(0, 0, 0, .5), rgba(0, 0, 0, 0)); pointer-events: none; }
.vplay-type { font-family: 'IBM Plex Mono', monospace; font-size: 9.5px; font-weight: 600; padding: 3px 9px; border-radius: 6px; }
.vplay-pos { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: rgba(255, 255, 255, .75); }
.vplay-dots { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; pointer-events: auto; }
.vplay-dots .dot { width: 7px; height: 7px; background: rgba(255, 255, 255, .32); }
.vplay-dots .dot-active { width: 18px; border-radius: 20px; background: #fff; }
