/* 消雪AI制御システム - 共通スタイル */
/* Phase 3: tokens.css からデザイントークンを読み込み */
@import url('tokens.css');

  * { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { height: 100%; }
  body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-mono);
    overflow-x: hidden;
  }

  /* ── ヘッダー（2段構成: メインヘッダー + ステータスバー）── */
  header {
    background: var(--panel);
    border-bottom: none;
    padding: 6px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 101;
  }
  header h1 { font-size: 13px; letter-spacing: 2px; color: var(--accent); white-space: nowrap; }

  /* ステータスサブバー */
  .status-bar {
    position: fixed;
    top: 38px;  /* JSで上書きされる。フォールバック値 */
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 4px 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .status-bar::-webkit-scrollbar { display: none; }
  .sb-chip {
    font-family: var(--mono);
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 3px;
    border: 1px solid var(--border);
    background: rgba(0,0,0,0.15);
    color: var(--muted);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
  }
  .sb-chip .dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
  /* テキストラベル（広い画面で表示、狭い画面で非表示） */
  .sb-chip .lbl { }

  /* ── メインレイアウト ── */
  main { display: flex; flex-direction: column; gap: 12px; padding: 12px 8px; padding-top: 90px; max-width: 1200px; margin: 0 auto; }

  /* ── カード ── */
  .card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
  }
  .card-title {
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--muted);
    margin-bottom: 8px;
    text-transform: uppercase;
  }

  /* ── パネル（メインコンテンツカード）── */
  .panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 14px;
  }
  .panel-title {
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--muted);
    text-transform: uppercase;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  /* ── ステータスグリッド ── */
  .status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 10px;
  }
  .stat-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 14px 12px;
    text-align: center;
  }
  .stat-label {
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--muted);
    text-transform: uppercase;
    margin-bottom: 8px;
  }
  .stat-value {
    font-size: 28px;
    font-weight: bold;
    line-height: 1.1;
    letter-spacing: 1px;
    margin-bottom: 2px;
  }
  .stat-unit {
    font-size: 11px;
    color: var(--muted);
    letter-spacing: 1px;
  }

  /* ── ポンプ状態ドット ── */
  .pump-status { display: flex; align-items: center; justify-content: center; gap: 8px; }
  .pump-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
  }
  .pump-dot.on  { background: var(--green); box-shadow: 0 0 8px rgba(74,222,128,0.6); }
  .pump-dot.off { background: var(--muted); }

  /* ── ポンプアニメーション ── */
  .pump-anim {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
  }

  /* 稼働中: 水滴が落ちる */
  .pump-anim.on {
    background: rgba(96,165,250,0.12);
    border: 1px solid rgba(96,165,250,0.35);
    box-shadow: 0 0 12px rgba(96,165,250,0.25);
  }
  .pump-anim.on .drop {
    display: block;
    position: absolute;
    width: 7px;
    height: 9px;
    background: #60a5fa;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    top: 0;
    opacity: 0;
    animation: pump-drop 1.4s ease-in infinite;
  }
  .pump-anim.on .d1 { left: 7px;  animation-delay: 0s; }
  .pump-anim.on .d2 { left: 19px; animation-delay: 0.46s; }
  .pump-anim.on .d3 { left: 31px; animation-delay: 0.92s; }

  @keyframes pump-drop {
    0%   { top: 2px;  opacity: 0;   transform: scaleX(0.8); }
    15%  { opacity: 1; }
    85%  { opacity: 0.9; }
    100% { top: 34px; opacity: 0;   transform: scaleX(1.1); }
  }

  .pump-anim.on .ice-crystal { display: none; }

  /* 停止中: 雪の結晶が呼吸 */
  .pump-anim.off {
    background: rgba(148,163,184,0.08);
    border: 1px solid rgba(148,163,184,0.2);
  }
  .pump-anim.off .drop { display: none; }
  .pump-anim.off .ice-crystal {
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 26px;
    color: #94a3b8;
    animation: ice-breathe 3s ease-in-out infinite;
    user-select: none;
  }

  @keyframes ice-breathe {
    0%, 100% { opacity: 0.4; transform: translate(-50%,-50%) scale(0.92); }
    50%       { opacity: 0.9; transform: translate(-50%,-50%) scale(1.08); }
  }

  /* ── 積雪層ビジュアル（機能1） ── */
  .snow-layer-wrap {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    border-radius: inherit;
  }
  .snow-layer {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, rgba(200,220,255,0.22), rgba(200,220,255,0.06));
    border-top: 1px solid rgba(200,220,255,0.3);
    transition: height 1.2s cubic-bezier(0.4,0,0.2,1);
    height: 0%;
  }
  .snow-layer-bump {
    position: absolute;
    top: -5px; left: 0; right: 0;
    height: 10px;
    background: rgba(200,220,255,0.15);
    border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  }
  #card-a, #card-b { position: relative; overflow: hidden; }

  /* ── 温度計（機能2） ── */
  .thermo-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }
  .thermo-svg { flex-shrink: 0; }
  .thermo-mercury {
    transition: height 1s ease, y 1s ease, fill 1s ease;
  }

  /* ── 霜エフェクト（機能2） ── */
  .frost-corner {
    position: fixed;
    width: 200px;
    height: 200px;
    pointer-events: none;
    z-index: 9989;
    opacity: 0;
    transition: opacity 3s ease, transform 3s ease;
  }
  .frost-tl { top: 0;    left: 0;    transform-origin: top left;     transform: scale(0.4); }
  .frost-tr { top: 0;    right: 0;   transform-origin: top right;    transform: scale(0.4); }
  .frost-bl { bottom: 0; left: 0;    transform-origin: bottom left;  transform: scale(0.4); }
  .frost-br { bottom: 0; right: 0;   transform-origin: bottom right; transform: scale(0.4); }
  .frost-corner.frost-active {
    opacity: 1;
    transform: scale(1);
  }
  .frost-corner.frost-mid {
    opacity: 0.6;
    transform: scale(0.75);
  }
  .frost-corner.frost-light {
    opacity: 0.3;
    transform: scale(0.5);
  }

  /* ── ポンプフラッシュ（機能4） ── */
  #pump-flash {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
  }
  #pump-flash.flash-on {
    animation: flash-on 0.7s ease-out forwards;
  }
  #pump-flash.flash-off {
    animation: flash-off 0.7s ease-out forwards;
  }
  @keyframes flash-on {
    0%   { background: rgba(74,222,128,0.35); opacity: 1; }
    100% { background: rgba(74,222,128,0);    opacity: 0; }
  }
  @keyframes flash-off {
    0%   { background: rgba(96,165,250,0.3); opacity: 1; }
    100% { background: rgba(96,165,250,0);   opacity: 0; }
  }

  /* ── 雪パーティクル（機能5） ── */
  .snow-particle {
    position: fixed;
    top: -30px;
    pointer-events: none;
    z-index: 9998;
    font-size: 18px;
    color: rgba(200,230,255,0.9);
    animation: snow-fall linear forwards;
    user-select: none;
  }
  @keyframes snow-fall {
    0%   { transform: translateY(0)   rotate(0deg);   opacity: 0.9; }
    80%  { opacity: 0.7; }
    100% { transform: translateY(105vh) rotate(360deg); opacity: 0; }
  }

  /* ── 天気アイコンアニメーション（機能3） ── */
  .wx-snow  { display: inline-block; animation: wx-snow-sway 2s ease-in-out infinite; }
  .wx-rain  { display: inline-block; animation: wx-rain-fall 1s linear infinite; }
  .wx-sun   { display: inline-block; animation: wx-sun-spin 8s linear infinite; }
  .wx-cloud { display: inline-block; animation: wx-cloud-drift 4s ease-in-out infinite; }
  .wx-storm { display: inline-block; animation: wx-storm-shake 0.6s ease-in-out infinite; }

  @keyframes wx-snow-sway {
    0%,100% { transform: rotate(-8deg) translateY(0); }
    50%     { transform: rotate(8deg)  translateY(-3px); }
  }
  @keyframes wx-rain-fall {
    0%   { transform: translateY(-2px); }
    100% { transform: translateY(2px); }
  }
  @keyframes wx-sun-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
  }
  @keyframes wx-cloud-drift {
    0%,100% { transform: translateX(-3px); }
    50%     { transform: translateX(3px); }
  }
  @keyframes wx-storm-shake {
    0%,100% { transform: rotate(-5deg); }
    50%     { transform: rotate(5deg); }
  }

  /* ── 手動制御エリア ── */
  .control-area {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
  }
  .control-msg {
    text-align: center;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 1px;
    margin-top: 10px;
  }
  .btn-on  { border-color: var(--green) !important; color: var(--green) !important; }
  .btn-off { border-color: var(--red)   !important; color: var(--red)   !important; }
  .btn-on:not(:disabled):hover  { background: rgba(74,222,128,0.15) !important; box-shadow: 0 0 16px rgba(74,222,128,0.25) !important; }
  .btn-off:not(:disabled):hover { background: rgba(248,113,113,0.15) !important; box-shadow: 0 0 16px rgba(248,113,113,0.25) !important; }
  .btn-on:disabled, .btn-off:disabled {
    opacity: 0.25;
    cursor: not-allowed;
    box-shadow: none;
  }

  /* ── 月次統計グリッド ── */
  .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    max-width: 640px;
    margin: 0 auto;
  }
  .stats-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 14px 12px;
    text-align: center;
  }
  .stats-card .label {
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--muted);
    text-transform: uppercase;
    margin-bottom: 8px;
  }
  .stats-card .value {
    font-family: var(--mono);
    font-size: 22px;
    color: var(--accent);
    line-height: 1.1;
    margin-bottom: 2px;
  }
  .stats-card .unit {
    font-size: 11px;
    color: var(--muted);
    letter-spacing: 1px;
  }

  /* ── グラフタブ ── */
  .tab-row {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    flex-wrap: wrap;
  }
  .tab {
    font-family: var(--mono);
    font-size: 11px;
    padding: 5px 14px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    letter-spacing: 1px;
    transition: all 0.15s;
  }
  .tab:hover  { border-color: var(--accent); color: var(--accent); }
  .tab.active { border-color: var(--accent); color: var(--accent); background: rgba(56,189,248,0.08); }

  /* ── グラフ ── */
  .chart-wrap { position: relative; height: 220px; }

  /* ── ログテーブル ── */
  .log-scroll { overflow-x: auto; }
  .log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    letter-spacing: 0.5px;
  }
  .log-table th {
    text-align: left;
    padding: 8px 10px;
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    white-space: nowrap;
  }
  .log-table td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(30,41,59,0.6);
    color: var(--text);
    white-space: nowrap;
  }
  .log-table tr:last-child td { border-bottom: none; }
  .log-table tr:hover td { background: rgba(56,189,248,0.03); }
  .badge-on     { color: var(--green);  }
  .badge-off    { color: var(--red);    }
  .badge-manual { color: var(--accent); font-style: italic; }

  /* ── 戻るリンク（共通）── */
  a.back {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 3px;
    padding: 4px 12px;
    text-decoration: none;
    letter-spacing: 1px;
    transition: background 0.2s, color 0.2s;
  }
  a.back:hover { background: var(--accent); color: var(--bg); }

  /* ── ボタン（統一デザイン）── */
  .btn {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 1px;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
  }
  .btn:hover, .btn.active { border-color: var(--accent); color: var(--accent); }
  .btn.danger, .btn.red    { border-color: var(--red);    color: var(--red); }
  .btn.primary, .btn.accent { border-color: var(--accent); color: var(--accent); }
  .btn.success, .btn.green  { border-color: var(--green);  color: var(--green); }
  .btn.yellow  { border-color: var(--yellow); color: var(--yellow); }
  .btn.danger:hover, .btn.red:hover    { background: rgba(248,113,113,0.1); }
  .btn.success:hover, .btn.green:hover { background: rgba(74,222,128,0.12); }
  .btn.yellow:hover  { background: rgba(251,191,36,0.1); }
  .btn:disabled { opacity: 0.3; cursor: not-allowed; }

  /* ── 天気予報 ── */
  .forecast-wrap { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
  .forecast-day {
    min-width: 52px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 5px;
    text-align: center;
    flex-shrink: 0;
  }
  .forecast-day .fc-date {
    font-size: 9px;
    color: var(--muted);
    margin-bottom: 3px;
  }
  .forecast-day .fc-icon { font-size: 28px; line-height: 1.2; margin-bottom: 4px; }
  .forecast-day .fc-weather {
    font-size: 11px;
    color: var(--text);
    margin-bottom: 6px;
    line-height: 1.4;
  }
  .forecast-day .fc-pop {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--accent);
    letter-spacing: 1px;
  }
  .forecast-day .fc-temp {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--muted);
    margin-top: 4px;
  }

  /* AMeDAS 地点観測パネル */
  .amedas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
  }
  .amedas-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px 12px;
    text-align: center;
  }
  .amedas-item .am-label {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--muted);
    letter-spacing: 1px;
    margin-bottom: 4px;
  }
  .amedas-item .am-value {
    font-family: var(--mono);
    font-size: 18px;
    font-weight: bold;
    color: var(--text);
    line-height: 1.3;
  }
  .amedas-item .am-unit {
    font-size: 11px;
    font-weight: normal;
    color: var(--muted);
  }
  .amedas-item.snow-highlight {
    border-color: rgba(96,165,250,0.4);
    background: rgba(96,165,250,0.04);
  }

  /* 天気概況テキスト */
  .overview-text {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
    line-height: 1.7;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-top: 10px;
    letter-spacing: 0.5px;
  }

  /* ── カメラバッジ ──────────────────────── */
  .cam-badge { transition: all 0.3s; }
  .cam-badge.snow { background: rgba(248,113,113,0.15); color: #f87171; border: 1px solid rgba(248,113,113,0.3); }
  .cam-badge.clear { background: rgba(74,222,128,0.1); color: #4ade80; border: 1px solid rgba(74,222,128,0.2); }

  /* ── 通知設定モーダル ──────────────────────── */
  .modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    padding: 20px;
  }
  .modal-overlay.open { display: flex; }
  .modal-box {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 100%;
    max-width: 640px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  }
  .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .modal-header h2 {
    font-family: var(--mono);
    font-size: 13px;
    letter-spacing: 3px;
    color: var(--accent);
    font-weight: 400;
  }
  .modal-close {
    background: none; border: 1px solid var(--border);
    color: var(--muted); font-size: 18px; cursor: pointer;
    width: 32px; height: 32px; border-radius: 3px;
    display: flex; align-items: center; justify-content: center;
    transition: color 0.2s, border-color 0.2s;
  }
  .modal-close:hover { color: var(--red); border-color: var(--red); }
  .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
  }
  .modal-body::-webkit-scrollbar { width: 4px; }
  .modal-body::-webkit-scrollbar-track { background: transparent; }
  .modal-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
  .modal-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
  }
  .modal-footer .btn {
    font-family: var(--mono); font-size: 11px; letter-spacing: 2px;
    padding: 10px 22px; border: 1px solid; border-radius: 3px;
    cursor: pointer; transition: all 0.2s; background: transparent;
  }
  .modal-footer .btn-save  { color: var(--green);  border-color: var(--green); }
  .modal-footer .btn-save:hover  { background: var(--green);  color: var(--bg); box-shadow: 0 0 12px rgba(74,222,128,0.3); }
  .modal-footer .btn-sub   { color: var(--accent); border-color: var(--accent); font-size: 10px; padding: 8px 14px; }
  .modal-footer .btn-sub:hover   { background: var(--accent); color: var(--bg); }
  .modal-footer .btn-muted { color: var(--muted);  border-color: var(--muted);  font-size: 10px; padding: 8px 14px; }
  .modal-footer .btn-muted:hover { background: var(--muted);  color: var(--bg); }
  #notify-save-msg {
    font-family: var(--mono); font-size: 11px; letter-spacing: 1px;
    margin-left: auto;
  }

  .notify-group { margin-bottom: 18px; }
  .notify-group-title {
    font-family: var(--mono); font-size: 10px; letter-spacing: 3px;
    color: var(--accent); text-transform: uppercase;
    margin-bottom: 8px;
  }
  .notify-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .notify-item {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 3px; padding: 9px 12px;
    cursor: pointer; transition: border-color 0.15s;
    font-family: var(--mono); font-size: 11px;
    color: var(--text); letter-spacing: 1px;
  }
  .notify-item:hover { border-color: var(--accent); }
  .notify-item.active { border-color: var(--accent); background: rgba(56,189,248,0.04); }
  .notify-item input[type=checkbox] {
    accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; flex-shrink: 0;
  }

  /* ── アラート表示 ────────────────────────── */
  .alert-list { display:flex; flex-direction:column; gap:6px; margin-top:4px; }
  .alert-item {
    display:flex; align-items:flex-start; gap:10px;
    background:var(--bg); border:1px solid var(--border); border-radius:3px;
    padding:9px 12px; font-family:var(--mono); font-size:11px;
  }
  .alert-item .al-time   { color:var(--muted); flex-shrink:0; letter-spacing:1px; }
  .alert-item .al-sep    { width:1px; background:var(--border); height:14px; flex-shrink:0; align-self:center; }
  .alert-item .al-label  { font-weight:bold; flex-shrink:0; letter-spacing:0.5px; }
  .alert-item .al-detail { color:var(--muted); letter-spacing:0.3px; word-break:break-all; line-height:1.5; }
  .alert-ok { font-family:var(--mono); font-size:12px; color:#4ade80; letter-spacing:1px; padding:8px 2px; margin-top:4px; }

  /* ── カメラグリッド（基本: 2カラム）── */
  .cam-pair-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  /* ── レスポンシブ ──────────────────────── */
  @media (max-width: 768px) {
    header { padding: 5px 12px; gap: 6px; }
    header h1 { font-size: 11px; letter-spacing: 1px; }
    #clock { font-size: 10px; }
    /* ステータスバー: テキストラベルを非表示、アイコン+数値のみ */
    .status-bar { padding: 3px 10px; gap: 4px; }
    .sb-chip { font-size: 10px; padding: 2px 5px; gap: 3px; }
    .sb-chip .lbl { display: none; }
    /* ヘッダーアイコンを縮小、一部非表示 */
    .hdr-icons .hdr-icon { width: 24px; height: 24px; font-size: 11px; }
    .hdr-icons .hdr-hide-mobile { display: none; }
    main { padding: 90px 8px 12px; gap: 10px; }
    .panel { padding: 14px 12px; }
    .panel-title { font-size: 10px; letter-spacing: 2px; margin-bottom: 10px; padding-bottom: 8px;
                   flex-wrap: wrap !important; gap: 6px; }
    .status-grid { gap: 8px; }
    .stat-card { padding: 12px 8px; }
    .stat-value { font-size: 22px; }
    .stat-label { font-size: 9px; letter-spacing: 1px; }
    .btn { padding: 10px 16px; font-size: 11px; letter-spacing: 1px; flex: 1; min-width: 100px; }
    .control-area { gap: 8px !important; display: grid !important; grid-template-columns: 1fr 1fr; justify-items: stretch; }
    .control-area .btn, .control-area button, .control-area a.btn { flex: unset !important; min-width: unset !important; width: 100%; box-sizing: border-box; text-align: center; }
    /* ポンプON/OFFは横並び1列目・2列目 */
    #btn-pump-on  { grid-column: 1; }
    #btn-pump-off { grid-column: 2; }
    /* 手動モードボタンは全幅 */
    #btn-manual-on, #btn-manual-off { grid-column: 1 / -1; }
    .chart-wrap { height: 200px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stats-card .value { font-size: 18px; }
    .tab-row { flex-wrap: wrap; }
    .tab { padding: 5px 10px; font-size: 10px; }
    .log-table th, .log-table td { padding: 6px 4px; font-size: 10px; }
    div[style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
    .amedas-grid { grid-template-columns: repeat(3, 1fr); }
    .amedas-item .am-value { font-size: 16px; }
    .overview-text { font-size: 10px; }
    .modal-overlay { padding: 10px; }
    .modal-box { max-height: 90vh; }
    .modal-body { padding: 14px; }
    .notify-grid { grid-template-columns: 1fr; }
    .notify-item { font-size: 10px; padding: 8px 10px; }
  }

  /* タブレット横向き */
  @media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .status-grid { grid-template-columns: repeat(4, 1fr); }
    .chart-wrap { height: 220px; }
    main { padding: 90px 16px 14px; }
  }

  @media (max-width: 480px) {
    header h1 { font-size: 10px; letter-spacing: 1px; }
    .status-bar { padding: 2px 8px; gap: 3px; }
    .sb-chip { font-size: 9px; padding: 2px 4px; }
    main { padding: 90px 8px 12px; }
    .status-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
    .stat-value { font-size: 18px; }
    .btn { padding: 10px 12px; font-size: 10px; }
    .chart-wrap { height: 180px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .panel-title > div { flex-wrap: wrap; }
    .log-scroll { overflow-x: auto; }
    .log-table { min-width: 500px; }
    .modal-overlay { padding: 0; }
    .modal-box { max-height: 100vh; border-radius: 0; max-width: 100%; }
    .modal-header { padding: 12px 14px; }
    .modal-header h2 { font-size: 11px; letter-spacing: 2px; }
    .modal-footer { padding: 10px 14px; }
    /* カメラグリッド: 小画面は縦1列 */
    .cam-pair-grid { grid-template-columns: 1fr; gap: 16px; }
    /* パネル折りたたみボタン: タップ領域を拡大 */
    .panel-collapse-btn { min-width: 36px; min-height: 36px; display: flex; align-items: center; justify-content: center; padding: 4px; }
    /* 予約キャンセルボタン: 押しやすく */
    #rsv-cancel-btn { padding: 8px 0 !important; font-size: 11px !important; }
    /* カメラパネルヘッダーのミニボタン */
    .cam-header-btns a, .cam-header-btns button { padding: 5px 10px !important; font-size: 10px !important; min-height: 32px; }
    /* AI・カメラ管理: 8ボタンを2列グリッドに */
    #btn-gpu-shutdown, #btn-train-start { grid-column: 1 / -1; }
    .modal-footer .btn { padding: 8px 14px; font-size: 10px; }
  }
  /* ⑨ モバイル操作性向上 */
  @media (max-width: 480px) {
    /* ボタンタッチターゲットを44px以上に */
    .btn { min-height: 44px; }
    button[onclick] { min-height: 36px; }
    /* ログパネルの横スクロールを明示 */
    .log-scroll { -webkit-overflow-scrolling: touch; }
    /* 判定ログテーブルをコンパクトに */
    .det-log-table th, .det-log-table td { padding: 5px 3px; font-size: 9px; }
    .det-log-table { min-width: 420px; }
    /* 自動収集トグルを大きく */
    #auto-capture-toggle { min-height: 40px; font-size: 12px; padding: 8px 14px; }
  }
  /* 判定ログパネル */
  .det-log-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-height: 260px; overflow-y: auto; }
  .det-log-table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 11px; }
  .det-log-table th { padding: 7px 8px; text-align: left; color: var(--muted); font-size: 9px;
    letter-spacing: 1px; border-bottom: 1px solid var(--border); white-space: nowrap; }
  .det-log-table td { padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,0.03); white-space: nowrap; }
  .det-log-table tr:hover td { background: rgba(255,255,255,0.02); }
  /* 学習モーダル */
  .modal-bg{display:none;position:fixed;inset:0;background:rgba(0,0,0,0.75);z-index:1000;justify-content:center;align-items:center}
  .modal-bg.show{display:flex}

  /* 気温取得元バッジ */
  .temp-source-badge {
    font-size: 9px;
    letter-spacing: 0.5px;
    margin-top: 3px;
    padding: 1px 5px;
    border-radius: 3px;
    display: inline-block;
    opacity: 0.85;
  }
  .temp-source-badge.src-sensor   { color: var(--green);  border: 1px solid var(--green);  background: rgba(74,222,128,0.08); }
  .temp-source-badge.src-amedas   { color: #38bdf8;       border: 1px solid #38bdf8;       background: rgba(56,189,248,0.08); }
  .temp-source-badge.src-forecast { color: var(--yellow); border: 1px solid var(--yellow); background: rgba(251,191,36,0.08); }
  .temp-source-badge.src-unknown  { color: var(--muted);  border: 1px solid var(--border);  background: transparent; }

  /* ポンプ稼働時間ストップウォッチ */
  .pump-stopwatch {
    margin-top: 6px;
    text-align: center;
  }
  #pump-stopwatch-time {
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: bold;
    color: var(--green);
    letter-spacing: 2px;
    text-shadow: 0 0 8px rgba(74,222,128,0.6);
    animation: sw-pulse 1s ease-in-out infinite;
  }
  @keyframes sw-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
  }

  /* ── 予約カード ──────────────────────────────── */
  .rsv-badge {
    display: inline-block;
    font-size: 9px;
    letter-spacing: 1px;
    padding: 2px 7px;
    border-radius: 3px;
    margin-bottom: 8px;
  }
  .rsv-badge.pending  { color: var(--yellow); border: 1px solid var(--yellow); background: rgba(251,191,36,0.08); }
  .rsv-badge.active   { color: var(--green);  border: 1px solid var(--green);  background: rgba(74,222,128,0.1);
                        animation: rsv-active-pulse 2s ease-in-out infinite; }
  @keyframes rsv-active-pulse {
    0%, 100% { box-shadow: none; }
    50%       { box-shadow: 0 0 8px rgba(74,222,128,0.4); }
  }
  .rsv-time-line {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: bold;
    color: var(--text);
    margin-bottom: 3px;
  }
  .rsv-forecast-line {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted);
    margin-bottom: 10px;
    min-height: 14px;
  }
  .rsv-countdown-wrap {
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
    padding: 8px 10px;
    text-align: center;
    border: 1px solid var(--border);
  }
  .rsv-countdown-label {
    font-size: 9px;
    letter-spacing: 1.5px;
    color: var(--muted);
    margin-bottom: 4px;
  }
  .rsv-countdown {
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: bold;
    letter-spacing: 3px;
    color: var(--yellow);
  }
  .rsv-countdown.active {
    color: var(--green);
    text-shadow: 0 0 10px rgba(74,222,128,0.5);
    animation: rsv-cd-pulse 1s ease-in-out infinite;
  }
  @keyframes rsv-cd-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.75; }
  }
  .rsv-extra {
    margin-top: 8px;
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--muted);
    letter-spacing: 0.5px;
  }

  /* ── 機能1: 気温連動背景グラデーション ──────── */
  #temp-bg-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    transition: background 4s ease;
  }
  /* 各気温帯のグラデーション */
  #temp-bg-overlay.temp-polar   { background: radial-gradient(ellipse at 50% 0%, rgba(80,0,160,0.22) 0%, transparent 70%); }
  #temp-bg-overlay.temp-freeze  { background: radial-gradient(ellipse at 50% 0%, rgba(0,40,120,0.20) 0%, transparent 70%); }
  #temp-bg-overlay.temp-snow    { background: radial-gradient(ellipse at 50% 0%, rgba(56,189,248,0.10) 0%, transparent 65%); }
  #temp-bg-overlay.temp-neutral { background: none; }
  #temp-bg-overlay.temp-warm    { background: radial-gradient(ellipse at 50% 100%, rgba(0,100,40,0.10) 0%, transparent 65%); }

  /* ── 機能3: 積雪緊急アラート演出 ────────────── */
  .snow-alert-flake {
    position: fixed;
    top: -30px;
    font-size: 20px;
    pointer-events: none;
    z-index: 9999;
    animation: alert-flake-fall linear forwards;
    opacity: 0.9;
    filter: drop-shadow(0 0 4px #38bdf8);
  }
  @keyframes alert-flake-fall {
    0%   { transform: translateY(0) rotate(0deg);   opacity: 0.9; }
    80%  { opacity: 0.8; }
    100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
  }
  .snow-alert-card-flash {
    animation: card-alert-flash 0.6s ease-out 3;
  }
  @keyframes card-alert-flash {
    0%, 100% { border-color: var(--border); box-shadow: none; }
    50%       { border-color: #f87171 !important; box-shadow: 0 0 16px rgba(248,113,113,0.5); }
  }

  /* ── 機能5: 深夜モード ───────────────────────── */
  #night-stars {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transition: opacity 3s ease;
  }
  #night-stars.visible { opacity: 1; }
  .star {
    position: absolute;
    border-radius: 50%;
    background: white;
    animation: star-twinkle var(--dur, 3s) ease-in-out infinite;
    animation-delay: var(--delay, 0s);
  }
  @keyframes star-twinkle {
    0%, 100% { opacity: var(--min-op, 0.2); transform: scale(1); }
    50%       { opacity: var(--max-op, 0.8); transform: scale(1.4); }
  }
  /* 深夜モードインジケーター */
  #night-indicator {
    position: fixed;
    bottom: 12px;
    right: 14px;
    font-size: 10px;
    color: rgba(148,163,184,0.4);
    font-family: var(--font-mono);
    letter-spacing: 1px;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    transition: opacity 2s ease;
  }
  #night-indicator.visible { opacity: 1; }

  /* ── ボタンアニメーション ────────────────────── */

  /* リップルエフェクト */
  .btn { position: relative; overflow: hidden; }
  .btn-ripple-el {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    animation: btn-ripple 0.55s linear;
    pointer-events: none;
  }
  @keyframes btn-ripple {
    to { transform: scale(4); opacity: 0; }
  }

  /* ポンプ起動パーティクル */
  .pump-burst {
    position: fixed;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    pointer-events: none;
    z-index: 9999;
    animation: pump-burst-fly 0.7s ease-out forwards;
  }
  @keyframes pump-burst-fly {
    0%   { transform: translate(0,0) scale(1); opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
  }

  /* ポンプ停止波紋 */
  .pump-stop-ripple {
    position: fixed;
    border-radius: 50%;
    border: 2px solid var(--red);
    pointer-events: none;
    z-index: 9999;
    animation: stop-ripple 0.6s ease-out forwards;
  }
  @keyframes stop-ripple {
    0%   { width: 10px; height: 10px; opacity: 0.9; }
    100% { width: 80px; height: 80px; opacity: 0; margin-left: -35px; margin-top: -35px; }
  }

  /* 手動モード ON: 画面端グロー */
  #manual-screen-glow {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9998;
    box-shadow: inset 0 0 0 0 rgba(251,191,36,0);
    transition: box-shadow 0.4s ease;
  }
  #manual-screen-glow.active {
    box-shadow: inset 0 0 40px 8px rgba(251,191,36,0.25);
    animation: manual-glow-pulse 3s ease-in-out infinite;
  }
  @keyframes manual-glow-pulse {
    0%, 100% { box-shadow: inset 0 0 40px 8px rgba(251,191,36,0.20); }
    50%       { box-shadow: inset 0 0 60px 14px rgba(251,191,36,0.35); }
  }

  /* 絵文字フロート */
  .emoji-float {
    position: fixed;
    font-size: 22px;
    pointer-events: none;
    z-index: 9999;
    animation: emoji-rise 1.2s ease-out forwards;
  }
  @keyframes emoji-rise {
    0%   { transform: translateY(0) scale(1);   opacity: 1; }
    60%  { transform: translateY(-80px) scale(1.3); opacity: 1; }
    100% { transform: translateY(-130px) scale(0.8); opacity: 0; }
  }

  /* 手動モード解除フラッシュ */
  .manual-off-flash {
    position: fixed;
    inset: 0;
    background: rgba(251,191,36,0.12);
    pointer-events: none;
    z-index: 9997;
    animation: manual-off-fade 0.7s ease-out forwards;
  }
  @keyframes manual-off-fade {
    0%   { opacity: 1; }
    100% { opacity: 0; }
  }

  /* 温度不明時のスタイル */
  .temp-unknown {
    animation: temp-pulse 2s ease-in-out infinite;
  }
  @keyframes temp-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
  }
  .stat-card.temp-warn {
    border: 1px solid var(--yellow) !important;
    background: rgba(251,191,36,0.05) !important;
  }

  /* 学習モーダル・カードのボタンホバー効果 */
  #btn-train-exec:not(:disabled):hover { background: rgba(251,191,36,0.25) !important; }
  #btn-train-deploy:hover              { background: rgba(74,222,128,0.25)  !important; }
  #train-area-a:hover, #train-area-b:hover { filter: brightness(1.3); }

  /* ══ パネル折りたたみ ══ */
  .panel-title { display:flex; align-items:center; justify-content:space-between; }
  .panel-collapse-btn {
    background:none; border:none; color:var(--muted); cursor:pointer;
    font-size:14px; padding:0 2px; line-height:1; transition:transform 0.25s, color 0.15s;
    flex-shrink:0; margin-left:auto;
  }
  .panel-collapse-btn:hover { color:var(--text); }
  .panel.collapsed .panel-collapse-btn { transform:rotate(-90deg); }
  .panel.collapsed > *:not(.panel-title) { display:none !important; }

  /* ══ カメラライトボックス ══ */
  #cam-lightbox {
    display:none; position:fixed; inset:0; background:rgba(0,0,0,0.92);
    z-index:400; cursor:zoom-out; justify-content:center; align-items:center;
  }
  #cam-lightbox img {
    max-width:98%; max-height:92vh; object-fit:contain; border-radius:4px;
    cursor:default; box-shadow:0 0 40px rgba(0,0,0,0.8);
  }
  #cam-lightbox-close {
    position:absolute; top:14px; right:18px; background:transparent; border:none;
    color:rgba(255,255,255,0.45); font-size:28px; cursor:pointer; line-height:1;
    transition:color 0.15s;
  }
  #cam-lightbox-close:hover { color:#fff; }
  #cam-lightbox-label {
    position:absolute; bottom:20px; left:50%; transform:translateX(-50%);
    font-family:var(--mono); font-size:11px; color:rgba(255,255,255,0.4);
    letter-spacing:3px;
  }

  /* ══ 接続断バナー ══ */
  #conn-fail-banner {
    display:none; position:fixed; top:0; left:0; right:0; z-index:600;
    background:rgba(220,38,38,0.95); color:#fff; font-family:var(--mono);
    font-size:11px; letter-spacing:1px; padding:7px 16px; text-align:center;
    animation:banner-slide-in 0.3s ease;
  }
  @keyframes banner-slide-in { from{transform:translateY(-100%)} to{transform:translateY(0)} }

  /* ══ 手動モードタイムアウト警告 ══ */
  #manual-timeout-warn {
    display:none; position:fixed; inset:0; z-index:500;
    background:rgba(0,0,0,0.75); justify-content:center; align-items:center;
  }
  #manual-timeout-warn .warn-box {
    background:var(--panel); border:1px solid var(--yellow); border-radius:6px;
    padding:28px 32px; max-width:340px; width:90%; text-align:center;
    animation:warn-pop 0.25s cubic-bezier(0.34,1.56,0.64,1);
  }
  @keyframes warn-pop { from{transform:scale(0.85);opacity:0} to{transform:scale(1);opacity:1} }
  .manual-cd-display {
    font-family:var(--mono); font-size:11px; color:var(--muted);
    margin-top:6px; letter-spacing:1px; min-height:16px;
  }

  /* ══ ポンプON長押しプログレス ══ */
  #pump-hold-progress {
    position:absolute; left:0; top:0; bottom:0; width:0%;
    background:rgba(56,189,248,0.35); border-radius:inherit;
    transition:width 1s linear; pointer-events:none;
  }
  #btn-pump-on { position:relative; overflow:hidden; }

  /* ══ GPU状態チップ ══ */
  #hdr-gpu { display:none; }

  /* ══ 1時間予報 天気アニメーションアイコン ══ */
  .wx-anim {
    display: inline-block;
    font-size: 17px;
    vertical-align: middle;
    margin-right: 5px;
    line-height: 1;
  }
  .wx-sun   { animation: wx-rotate 14s linear infinite; transform-origin: center; }
  .wx-partly{ animation: wx-float  5s ease-in-out infinite; }
  .wx-cloud { animation: wx-float  4s ease-in-out infinite; }
  .wx-fog   { animation: wx-fade   3s ease-in-out infinite; }
  .wx-rain  { animation: wx-drip   1.4s ease-in-out infinite; }
  .wx-snow  { animation: wx-sway   2.8s ease-in-out infinite; }
  .wx-storm { animation: wx-flash  2.2s ease-in-out infinite; }

  @keyframes wx-rotate { to   { transform: rotate(360deg); } }
  @keyframes wx-float  { 0%,100% { transform: translateY(0);    } 50% { transform: translateY(-3px); } }
  @keyframes wx-fade   { 0%,100% { opacity: 0.45; } 50% { opacity: 1; } }
  @keyframes wx-drip   { 0%,100% { transform: translateY(0);    } 60% { transform: translateY(4px); } }
  @keyframes wx-sway   { 0%,100% { transform: rotate(-14deg);   } 50% { transform: rotate(14deg);  } }
  @keyframes wx-flash  { 0%,88%,100% { opacity: 1; } 92% { opacity: 0.15; } }

  /* ══ 凍結防止モード ポンプアニメーション ══ */
  .pump-anim.freeze {
    background: rgba(147,210,255,0.1);
    border: 1px solid rgba(147,210,255,0.5);
    animation: freeze-pulse 2.4s ease-in-out infinite;
  }
  .pump-anim.freeze .drop { display: none; }
  .pump-anim.freeze .ice-crystal {
    display: block;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    font-size: 26px;
    color: #93d2ff;
    animation: freeze-spin 6s linear infinite;
    user-select: none;
  }
  @keyframes freeze-pulse {
    0%,100% { box-shadow: 0 0 6px rgba(147,210,255,0.3); }
    50%     { box-shadow: 0 0 18px rgba(147,210,255,0.8); }
  }
  @keyframes freeze-spin {
    0%,100% { transform: translate(-50%,-50%) scale(0.9) rotate(0deg);   opacity:0.6; }
    50%     { transform: translate(-50%,-50%) scale(1.1) rotate(180deg); opacity:1.0; }
  }
  .pump-freeze-mode {
    border-color: rgba(147,210,255,0.4) !important;
    background: rgba(147,210,255,0.04) !important;
  }

  /* ══ 積雪検知 カメラ枠パルス ══ */
  .cam-snow-pulse img {
    border-color: var(--red) !important;
    animation: cam-pulse 1.8s ease-in-out infinite;
  }
  @keyframes cam-pulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(248,113,113,0); }
    50%     { box-shadow: 0 0 12px 4px rgba(248,113,113,0.5); }
  }

  /* ══ レンズ汚れ警告オーバーレイ ══ */
  .cam-lens-dirty { position: relative; }
  .cam-lens-dirty::after {
    content: "⚠ レンズ汚れ";
    position: absolute;
    top: 8px; right: 8px;
    background: rgba(251,191,36,0.15);
    border: 1px solid var(--yellow);
    color: var(--yellow);
    font-size: 10px;
    font-family: var(--mono);
    letter-spacing: 1px;
    padding: 2px 8px;
    border-radius: 3px;
    pointer-events: none;
    z-index: 10;
  }

  /* ══ 稼働タイムライン ══ */
  .timeline-wrap {
    margin-top: 14px;
    padding: 10px 0 4px;
    border-top: 1px solid var(--border);
  }
  .timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
  }
  .timeline-title {
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--muted);
  }
  .timeline-summary {
    font-size: 10px;
    font-family: var(--mono);
    color: var(--accent);
    letter-spacing: 1px;
  }
  .timeline-bar {
    position: relative;
    height: 12px;
    background: var(--border);
    border-radius: 6px;
    overflow: hidden;
  }
  .tl-seg {
    position: absolute;
    top: 0; bottom: 0;
    border-radius: 2px;
  }
  .tl-seg.on  { background: var(--accent); }
  .tl-seg.off { background: transparent; }
  .timeline-ticks {
    display: flex;
    justify-content: space-between;
    margin-top: 3px;
    font-size: 9px;
    color: var(--muted);
    font-family: var(--mono);
  }

  /* ══ 気温スパークライン（カード背景に絶対配置）══ */
  #card-temp {
    position: relative;
    overflow: hidden;
  }
  .temp-sparkline {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    opacity: 0.12;
    pointer-events: none;
  }
