:root {
  --bg: #f4f6f3; --panel: #fff; --text: #1d2330; --muted: #6b7280; --line: #dfe3dc;
  --accent: #2e7d32; --accent-text: #fff; --danger: #c62828; --warn-bg: #fff4e0; --warn: #8a5300;
  --chip: #eef3ec;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141714; --panel: #1e221e; --text: #e6e8ec; --muted: #9aa3b2; --line: #2e352e;
    --accent: #5fae63; --accent-text: #0d140d; --danger: #ef5350; --warn-bg: #3a2c12; --warn: #ffcc80;
    --chip: #263026;
  }
}
* { box-sizing: border-box; }
/* display を指定した要素でも hidden 属性で確実に隠す */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Segoe UI", sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
button, input { font: inherit; color: inherit; }
/* iPhone で入力欄をタップしたときに画面が拡大されないよう 16px 以上にする */
input { font-size: 16px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 14px; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: bold; }
button.wide { width: 100%; margin-top: 14px; padding: 12px; }
button.link { border: none; background: none; color: var(--accent); padding: 8px 0; margin-top: 8px; }
button:disabled { opacity: .5; cursor: default; }
label { display: block; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
h1 { font-size: 20px; margin: 0 0 12px; }
hr { border: none; border-top: 1px solid var(--line); margin: 20px 0 12px; }
.small { font-size: 13px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.error { color: var(--danger); font-size: 14px; white-space: pre-wrap; }
.warn { background: var(--warn-bg); color: var(--warn); padding: 10px 12px; border-radius: 8px; }

#env { padding: 4px 16px; font-size: 12px; font-weight: bold; color: #fff; background: #b26a00; text-align: center; }
#updateBar, #offlineBar { padding: 8px 16px; font-size: 13px; background: var(--chip); text-align: center; }
#updateBar button { margin-left: 8px; padding: 2px 10px; }

#shell { max-width: 560px; margin: 0 auto; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-top: 24px; }

.homeHead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.homeTitle { font-size: 20px; font-weight: bold; }
#menu { display: flex; flex-direction: column; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 12px; }
.tip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--chip); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px; }
.tip span { flex: 1 1 200px; }

.siteHead { font-size: 13px; color: var(--muted); margin: 16px 4px 6px; }
.drawing { display: block; width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; }
.drawing .name { font-weight: bold; font-size: 16px; }
.drawing .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.drawing .saved { color: var(--accent); }
.drawing:disabled { opacity: .45; }
.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: 12px; padding: 20px; color: var(--muted); font-size: 14px; }

.deviceOption { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
.deviceOption input { width: auto; margin-top: 5px; }
.deviceOption .when { font-size: 12px; color: var(--muted); }

#scrViewer { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); z-index: 10;
             padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }
#viewerBar { display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line); }
#viewerBar button { padding: 4px 10px; white-space: nowrap; }
#viewerTitle { font-weight: bold; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#viewerFrame { flex: 1; width: 100%; border: none; background: #fff; }

#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
         background: #222; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 20; max-width: 90vw; }
