/* てもと — 共通デザインシステム
   Apple HIG を参考に、装飾より構造で情報を伝える。影は最小限、境界線で階層を作る。 */

:root {
  color-scheme: light dark;

  /* 色（ライト） */
  --bg: #fbfaf9;
  --surface: #ffffff;
  --surface-sunken: #f4f2f0;
  --border: #e3dfda;
  --border-strong: #cfc9c2;
  --text: #1b1917;
  --text-muted: #6c665f;
  --accent: #0f6d5f;
  --accent-hover: #0c5a4e;
  --accent-soft: #e6f2ef;
  --warn: #8a5220;
  --warn-soft: #fbf1e6;
  --danger: #a03328;

  /* 余白（4pxグリッド） */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  --radius: 10px;
  --radius-lg: 14px;

  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", "Yu Gothic", Meiryo, system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --maxw: 760px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161512;
    --surface: #201e1b;
    --surface-sunken: #1a1815;
    --border: #35312c;
    --border-strong: #4a453e;
    --text: #f2efea;
    --text-muted: #a49d94;
    --accent: #4fb9a3;
    --accent-hover: #63c8b3;
    --accent-soft: #16302b;
    --warn: #d9a066;
    --warn-soft: #2c2216;
    --danger: #e08074;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
}

/* キーボード操作を常に見えるように */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }

/* ---------- レイアウト ---------- */

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--sp-5);
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  z-index: 100;
}
.skip:focus { left: var(--sp-4); top: var(--sp-4); }

/* ---------- ヘッダー ---------- */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-height: 60px;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}
.brand:hover { color: var(--text); }

.brand-tag {
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  margin-left: var(--sp-3);
}

@media (max-width: 560px) {
  .brand-tag { display: none; }
}

/* ---------- 通信モニター ---------- */

.netmon {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px var(--sp-3);
  text-decoration: none;
  white-space: nowrap;
}
.netmon:hover { color: var(--text); border-color: var(--border-strong); }

.netmon-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.netmon[data-state="leaked"] .netmon-dot { background: var(--danger); }
.netmon[data-state="leaked"] { color: var(--danger); border-color: var(--danger); }

/* ---------- 見出し・本文 ---------- */

h1 {
  font-size: 30px;
  line-height: 1.4;
  letter-spacing: 0.005em;
  margin: 0 0 var(--sp-3);
  font-weight: 700;
}

h2 {
  font-size: 19px;
  line-height: 1.5;
  margin: var(--sp-7) 0 var(--sp-3);
  font-weight: 700;
}

h3 {
  font-size: 15px;
  margin: var(--sp-5) 0 var(--sp-2);
  font-weight: 700;
}

p { margin: 0 0 var(--sp-4); }

.lead {
  font-size: 17px;
  color: var(--text-muted);
  margin-bottom: var(--sp-6);
}

.muted { color: var(--text-muted); }
.small { font-size: 13px; line-height: 1.7; }

main { padding: var(--sp-7) 0 var(--sp-8); }

/* ---------- カード ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  margin-bottom: var(--sp-4);
}

/* ---------- ドロップゾーン ---------- */

.drop {
  display: block;
  width: 100%;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: var(--sp-7) var(--sp-5);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.drop.is-over { border-color: var(--accent); background: var(--accent-soft); border-style: solid; }

.drop-title { display: block; font-weight: 700; margin-bottom: var(--sp-1); }
.drop-hint { display: block; font-size: 13px; color: var(--text-muted); }

/* タッチ端末ではドラッグできないため、案内を出さない */
@media (hover: none) and (pointer: coarse) {
  .drop-hint { display: none; }
}

.drop-icon { color: var(--text-muted); margin-bottom: var(--sp-3); display: block; }
.drop:hover .drop-icon, .drop.is-over .drop-icon { color: var(--accent); }

/* ---------- ファイル一覧 ---------- */

.filelist { list-style: none; margin: var(--sp-4) 0 0; padding: 0; }

.fileitem {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
}
.fileitem:last-child { border-bottom: none; }

.fileitem-body { flex: 1; min-width: 0; }

.fileitem-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fileitem-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.fileitem-actions { display: flex; gap: var(--sp-2); flex-shrink: 0; }

/* ---------- ボタン ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  padding: 13px var(--sp-5);
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}
.btn:hover { background: var(--accent-hover); color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-block { width: 100%; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-sunken); color: var(--text); }

.btn-sm { font-size: 13px; padding: 8px var(--sp-3); }

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--sp-2);
  border-radius: 6px;
  display: inline-flex;
  line-height: 0;
}
.btn-icon:hover { background: var(--surface-sunken); color: var(--text); }
.btn-icon:disabled { opacity: .3; cursor: not-allowed; }

/* ---------- フォーム ---------- */

.field { margin-bottom: var(--sp-4); }
.field:last-child { margin-bottom: 0; }

.field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: var(--sp-2);
}

.field-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: var(--sp-2);
  line-height: 1.6;
}

input[type="text"], select {
  width: 100%;
  font-family: inherit;
  font-size: 16px; /* 16px未満だとiOS Safariが自動ズームする */
  padding: 11px var(--sp-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

input[type="range"] { width: 100%; accent-color: var(--accent); }

/* ラジオをセグメント風に */
.segmented { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

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

.segmented label {
  flex: 1;
  min-width: 90px;
  margin: 0;
  text-align: center;
  padding: var(--sp-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  background: var(--surface);
  transition: background .15s, border-color .15s;
}
.segmented label:hover { background: var(--surface-sunken); }

.segmented input:checked + label {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.segmented input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }

.segmented .seg-sub {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: var(--font-mono);
}
.segmented input:checked + label .seg-sub { color: var(--accent); }

/* ---------- 進捗 ---------- */

.progress { margin-top: var(--sp-4); }

.progress-bar {
  height: 6px;
  background: var(--surface-sunken);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0;
  transition: width .2s ease;
}

.progress-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: var(--sp-2);
  font-variant-numeric: tabular-nums;
}

/* ---------- 結果 ---------- */

.result {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  margin-top: var(--sp-4);
}

.result-stat {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}

.result-size {
  font-size: 26px;
  font-weight: 700;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.result-delta { font-size: 14px; color: var(--text-muted); }

.result-was { text-decoration: line-through; }

/* ---------- 注意書き ---------- */

.notice {
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  background: var(--warn-soft);
  border-radius: var(--radius);
  padding: var(--sp-4);
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: var(--sp-4);
}
.notice strong { display: block; margin-bottom: var(--sp-1); }
.notice p:last-child { margin-bottom: 0; }

.error {
  border: 1px solid var(--danger);
  border-left-width: 3px;
  border-radius: var(--radius);
  padding: var(--sp-4);
  font-size: 14px;
  color: var(--danger);
  margin-top: var(--sp-4);
}

/* ---------- ツール一覧 ---------- */

.tools { display: grid; gap: var(--sp-3); grid-template-columns: 1fr 1fr; margin: var(--sp-5) 0; }

@media (max-width: 560px) { .tools { grid-template-columns: 1fr; } }

.tool {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  transition: border-color .15s, background .15s;
}
.tool:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }

.tool-name { font-weight: 700; font-size: 16px; margin-bottom: 2px; display: flex; align-items: center; gap: var(--sp-2); }
.tool-desc { font-size: 13px; color: var(--text-muted); line-height: 1.6; }
.tool svg { color: var(--accent); flex-shrink: 0; }

/* ---------- 検証手順 ---------- */

.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }

.steps li {
  counter-increment: s;
  position: relative;
  padding-left: var(--sp-6);
  margin-bottom: var(--sp-3);
  font-size: 14px;
  line-height: 1.7;
}

.steps li::before {
  content: counter(s);
  position: absolute;
  left: 0;
  top: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
}

/* ---------- FAQ ---------- */

details {
  border-bottom: 1px solid var(--border);
  padding: var(--sp-4) 0;
}
details:first-of-type { border-top: 1px solid var(--border); }

summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  align-items: center;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform .2s;
  flex-shrink: 0;
  margin-right: 4px;
}
details[open] summary::after { transform: rotate(-135deg); }

details .detail-body { padding-top: var(--sp-3); font-size: 14px; color: var(--text-muted); }
details .detail-body p:last-child { margin-bottom: 0; }

/* ---------- フッター ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: var(--sp-6) 0;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface);
}
.site-footer nav { display: flex; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-3); }

/* ---------- 汎用 ---------- */

.hidden { display: none !important; }

.row { display: flex; gap: var(--sp-3); flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }

table.spec {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-bottom: var(--sp-4);
}
table.spec th, table.spec td {
  text-align: left;
  padding: var(--sp-3);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.spec th { font-weight: 600; width: 34%; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* セクション先頭のフィールドは、上のブロックとの間隔を広くとる */
.field-spaced { margin-top: var(--sp-5); }

/* 一覧の下に置く実行ボタン */
.filelist + .btn { margin-top: var(--sp-5); }
