/* S18〜S20 と本文の中の添付（担当F）。値は tokens.css の変数だけを使う（直書きしない。ui-design 16-6.11）。
   例外: 手書きの描く色（js/screens/attach/draw.js の INKS）は絵の中身として PNG に書き込む色なので、要素の --ink で受ける。 */

/* ---------- 本文の中の写真 ---------- */
.has-att .att-photo {
  position: relative;
  display: block;
  width: 100%;
  min-height: calc(var(--sp-7) * 2);
  margin: var(--sp-2) 0;
  padding: 0;
  border: 0;
  border-radius: var(--r-m);
  background: var(--surface);
  overflow: hidden;
  cursor: zoom-in;
}
.has-att .att-photo:not(.is-loading):not(.is-missing) { min-height: 0; background: transparent; }
.att-photo-img { display: block; width: 100%; height: auto; }
.att-photo.is-loading .att-photo-img:not([src]) { display: none; }
.att-photo:active .att-photo-img { opacity: 0.72; }
.att-photo:active { background: var(--press); }
.att-photo-note {
  display: block;
  padding: var(--sp-4);
  color: var(--text-2);
  font-size: var(--fs-small);
  line-height: var(--lh-small);
  text-align: left;
}
.att-photo.is-missing { box-shadow: inset 0 0 0 1px var(--line-strong); }

/* 設定「本文の中の写真」が小さく: 3つずつ横に並べる（押すと大きく見る） */
.has-att[data-photo-size="small"] .att-photos { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.has-att[data-photo-size="small"] .att-photos > br { display: none; }
.has-att[data-photo-size="small"] .att-photo {
  display: inline-block;
  width: calc((100% - 2 * var(--sp-2)) / 3);
  min-height: 0;
  aspect-ratio: 1;
  margin: 0;
  vertical-align: top;
  background: var(--surface);
}
.has-att[data-photo-size="small"] .att-photo-img { width: 100%; height: 100%; object-fit: cover; }
.has-att[data-photo-size="small"] .att-photo-note { padding: var(--sp-2); font-size: var(--fs-caption); line-height: var(--lh-ui); }

/* ---------- 本文の中のファイルと PDF ---------- */
.att-file {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: var(--hit);
  margin: var(--sp-2) 0;
  padding: var(--sp-2) var(--sp-3);
  border: 0;
  border-radius: var(--r-m);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--text);
  text-align: left;
}
.att-file:active { background: var(--press); }
.att-file-icon { flex: none; color: var(--accent); }
.att-file-text { display: flex; flex-direction: column; min-width: 0; }
.att-file-name { font-size: var(--fs-body); line-height: var(--lh-ui); overflow-wrap: anywhere; }
.att-file-kind { color: var(--text-3); font-size: var(--fs-small); line-height: var(--lh-small); }

.att-pdf {
  display: block;
  width: 100%;
  margin: var(--sp-2) 0;
  padding: 0;
  border: 0;
  border-radius: var(--r-m);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
  color: var(--text);
  text-align: left;
}
.att-pdf:active { background: var(--press); }
.att-pdf:active .att-pdf-img { opacity: 0.72; }
.att-pdf-page { display: block; max-height: calc(var(--sp-7) * 8); overflow: hidden; background: var(--press-bg); }
.att-pdf.is-loading .att-pdf-page { min-height: calc(var(--sp-7) * 2); }
.att-pdf.is-bad .att-pdf-page { display: none; }
.att-pdf-img { display: block; width: 100%; height: auto; }
.att-pdf-img:not([src]) { display: none; }
.att-pdf-cap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1) var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-small);
  line-height: var(--lh-small);
}
.att-pdf-name { flex: 1 1 auto; min-width: 0; font-weight: var(--fw-bold); overflow-wrap: anywhere; }
.att-pdf-pages { color: var(--text-3); font-variant-numeric: tabular-nums; }

/* 種類の札（PDF・重要・済み）。色に頼らず言葉で示す */
.att-badge {
  display: inline-block;
  margin-right: var(--sp-1);
  padding: 0 var(--sp-1);
  border: 1px solid currentColor;
  border-radius: var(--r-s);
  color: var(--text-2);
  font-size: var(--fs-caption);
  font-weight: var(--fw-bold);
  line-height: 1.5;
  vertical-align: 1px;
}

/* ---------- 小さな四角の札（表の欄・写真の一覧） ---------- */
.att-thumb {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  width: calc(var(--sp-7) + var(--sp-5));
  height: calc(var(--sp-7) + var(--sp-5));
  padding: 0;
  border: 0;
  border-radius: var(--r-m);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
  color: var(--text-2);
}
.att-thumb:active { background: var(--press); }
.att-thumb img { width: 100%; height: 100%; object-fit: cover; }
.att-thumb img:not([src]) { display: none; }
.att-thumb .att-badge { position: absolute; left: var(--sp-1); bottom: var(--sp-1); background: var(--surface); }
.att-thumb-icon { color: var(--accent); }
.att-thumb-name { padding: 0 var(--sp-1); font-size: var(--fs-caption); line-height: var(--lh-ui); text-align: center; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- S18 添付を見る ---------- */
.screen-viewer .viewer-body {
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
}
.viewer-stage { display: flex; align-items: center; justify-content: center; min-width: 100%; min-height: 100%; width: max-content; }
.viewer-img { display: block; max-width: none; user-select: none; -webkit-user-select: none; }
.viewer-pages { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); width: max-content; min-width: 100%; padding: var(--sp-2); }
.viewer-page { position: relative; background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.viewer-page canvas { display: block; width: 100%; height: 100%; }
.viewer-page-error { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--text-3); font-size: var(--fs-small); }
.viewer-tools {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
  min-height: calc(var(--hit) + var(--sp-4));
  padding: var(--sp-2) var(--gutter) calc(var(--sp-2) + var(--safe-b));
  background: var(--bar);
  box-shadow: 0 -0.5px 0 var(--line);
}
.viewer-tools:empty { display: none; }
.viewer-tools .btn { min-height: var(--hit); }
.viewer-count { flex: 1; margin: 0; color: var(--text-2); font-size: var(--fs-small); font-variant-numeric: tabular-nums; }
.viewer-file { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); padding: var(--sp-7) var(--gutter); text-align: center; }
.viewer-file-icon { color: var(--text-2); }
.viewer-file-name { margin: 0; font-size: var(--fs-headline); font-weight: var(--fw-bold); line-height: var(--lh-ui); overflow-wrap: anywhere; }
.viewer-file-meta { margin: 0; color: var(--text-3); font-size: var(--fs-small); }
.ocr-text { margin: 0; white-space: pre-wrap; font-size: var(--fs-body); line-height: var(--lh-body); user-select: text; -webkit-user-select: text; }

/* ---------- S19 手書き・描き足す ---------- */
.draw-main { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-2) var(--gutter); }
.draw-note { margin: 0; color: var(--text-2); font-size: var(--fs-small); line-height: var(--lh-small); }
.draw-paper { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.draw-canvas { display: block; touch-action: none; border-radius: var(--r-s); box-shadow: 0 0 0 1px var(--line-strong); cursor: crosshair; }
.draw-tools {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--gutter) calc(var(--sp-2) + var(--safe-b));
  background: var(--bar);
  box-shadow: 0 -0.5px 0 var(--line);
}
.draw-inks { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--sp-2); }
.ink {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  min-height: var(--hit);
  padding: var(--sp-1) 0;
  border: 0;
  border-radius: var(--r-m);
  background: transparent;
  color: var(--text-2);
}
.ink:active { background: var(--press-bg); }
.ink[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 2px var(--accent); }
.ink[aria-checked="true"] .ink-name { font-weight: var(--fw-bold); }
.ink-swatch { width: 24px; height: 24px; border-radius: var(--r-pill); background: var(--ink); box-shadow: 0 0 0 1px var(--line-strong); }
.ink.is-eraser .ink-swatch { background: var(--surface); box-shadow: inset 0 0 0 2px var(--line-strong); border-radius: var(--r-s); }
.ink-name { font-size: var(--fs-caption); line-height: 1.2; white-space: nowrap; }
.draw-row { display: flex; align-items: center; gap: var(--sp-3); }
.draw-row .seg { flex: 1; }
.draw-row .btn { flex: none; min-height: var(--hit); }

/* ---------- S20 置き場の手順・写真の置き場と使っている量 ---------- */
.attach-page { padding-bottom: var(--sp-7); }
.guide-lead { margin: 0 0 var(--sp-3); font-size: var(--fs-body); line-height: var(--lh-body); }
.guide-legend { margin: 0 0 var(--sp-2); color: var(--text-2); font-size: var(--fs-small); line-height: var(--lh-small); }
.guide-step-title { display: flex; align-items: center; gap: var(--sp-3); margin: var(--sp-5) 0 var(--sp-2); font-size: var(--fs-headline); font-weight: var(--fw-bold); line-height: var(--lh-ui); }
.guide-no {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-pill);
  box-shadow: inset 0 0 0 1.5px var(--text);
  font-size: var(--fs-small);
  font-weight: var(--fw-heavy);
  font-variant-numeric: tabular-nums;
}
.guide-card { padding: var(--sp-3) var(--cell-x); }
.guide-action .btn { width: 100%; }
.guide-open { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.guide-list { margin: var(--sp-3) 0 0; padding-left: 1.4em; }
.guide-item { margin: var(--sp-3) 0 0; }
.guide-item::marker { font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.guide-text { margin: 0; font-size: var(--fs-body); line-height: var(--lh-body); overflow-wrap: anywhere; }
.guide-key { font-weight: var(--fw-heavy); }
.guide-shot { display: block; width: 100%; margin: var(--sp-2) 0 0; padding: 0; border: 0; border-radius: var(--r-m); background: transparent; box-shadow: 0 0 0 1px var(--line); overflow: hidden; cursor: zoom-in; }
.guide-shot:active { opacity: 0.72; }
.guide-shot img { display: block; width: 100%; height: auto; }
.guide-status { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-3) var(--cell-x); }
.guide-status.is-busy { opacity: 0.6; }
.guide-status .btn { width: 100%; }
.guide-status-text { margin: 0; font-size: var(--fs-body); line-height: var(--lh-body); }

.info-row { position: relative; padding: var(--row-pad) var(--cell-x); background: var(--surface); }
.info-row + .info-row::before { content: ""; position: absolute; top: 0; left: var(--cell-x); right: 0; height: 1px; transform: scaleY(0.5); background: var(--line); }
.info-main { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); }
.info-label { min-width: 0; font-size: var(--fs-body); line-height: var(--lh-ui); overflow-wrap: anywhere; }
.info-value { flex: none; max-width: 60%; color: var(--text-2); font-size: var(--fs-body); line-height: var(--lh-ui); text-align: right; font-variant-numeric: tabular-nums; }
.info-sub { margin: var(--sp-1) 0 0; color: var(--text-3); font-size: var(--fs-small); line-height: var(--lh-small); }
.usage-meter { margin-top: var(--sp-2); }
.usage-bar { position: relative; height: 8px; border-radius: var(--r-pill); background: var(--press); }
.usage-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: var(--r-pill); background: var(--text-2); }
.usage-bar.is-warn .usage-fill, .usage-bar.is-over .usage-fill { background: var(--text); }
.usage-tick { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--text); }
.usage-scale { margin: var(--sp-1) 0 0; color: var(--text-3); font-size: var(--fs-caption); line-height: var(--lh-small); }
.storage-alert {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin: var(--sp-2) 0 0;
  padding: var(--sp-3) var(--cell-x);
  border-radius: var(--r-m);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.storage-alert-text { margin: 0; font-size: var(--fs-small); line-height: var(--lh-small); }
.storage-alert .btn { width: 100%; }
.storage-note { margin: var(--sp-2) 0 0; padding: 0 var(--cell-x); color: var(--text-3); font-size: var(--fs-small); line-height: var(--lh-small); }
.storage-action { width: 100%; margin-top: var(--sp-3); }
