/* 名刺フォロー 画面の見た目（docs/UI_SPEC.md 5章・6章）
   色はすべて :root の変数で持つ（ここ以外に色を直書きしない）。文字は 16px（1rem）より小さくしない。 */

:root {
  color-scheme: light;
  /* 地と文字 */
  --c-bg:          #F4F5F7;
  --c-surface:     #FFFFFF;
  --c-text:        #1A1D21;
  --c-text-sub:    #4A5260;
  --c-line:        #7A8494;
  --c-line-soft:   #DCE0E5;
  /* 主色（青） */
  --c-primary:     #0B5FCC;
  --c-primary-press: #094FA8;
  --c-focus:       #0B5FCC;
  --c-on-color:    #FFFFFF; /* 色の地の上の白文字 */
  /* 赤 */
  --c-danger:      #B42318;
  --c-danger-bg:   #FDECEA;
  --c-danger-text: #8A1C12;
  /* 黄 */
  --c-warn:        #6B4A00;
  --c-warn-bg:     #FFF4D6;
  --c-warn-line:   #B07A00;
  /* 段階の札 */
  --c-neutral-bg:  #EEF0F3;
  --c-accent:      #0B5FCC;
  --c-accent-bg:   #E8F0FC;
  --c-ok:          #1E6B38;
  --c-ok-bg:       #E6F4EA;
  --c-purple:      #5B3E96;
  --c-purple-bg:   #F0EBFA;
  --c-ok-strong:   #1E6B38;
  /* 押せない見た目 */
  --c-disabled-bg: #E3E6EA;
  --c-disabled-text: #4A5260;
  /* 撮る画面・写真の全画面・小窓 */
  --c-camera-bg:   #000000;
  --c-frame:       #2ECC71;
  --c-shade:       rgba(0, 0, 0, 0.45);
  --c-backdrop:    rgba(0, 0, 0, 0.4);
  --c-sheet-shadow: rgba(0, 0, 0, 0.18);

  /* 余白（4px 刻み） */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;
  --sp-8: 32px;

  --fade: 150ms;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-tap-highlight-color: transparent;
}

h1, h2, p, ul, ol, dl { margin: 0; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* 見えないが読み上げ・押す対象には残す */
.vh {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.nums { font-variant-numeric: tabular-nums; }

/* ---------- 画面の骨組み ---------- */

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  animation: fade var(--fade) ease-out;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  :root { --fade: 0ms; }
  .screen { animation: none; }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: calc(52px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(var(--sp-2), env(safe-area-inset-right)) 0 max(var(--sp-2), env(safe-area-inset-left));
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-line-soft);
}

.title {
  flex: 1;
  min-width: 0;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
}
.title-left { text-align: left; padding-left: var(--sp-2); }
.title:focus { outline: none; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-space { min-width: 76px; }

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: var(--sp-4) max(var(--sp-4), env(safe-area-inset-right)) calc(56px + var(--sp-4) + env(safe-area-inset-bottom)) max(var(--sp-4), env(safe-area-inset-left));
}

.bottombar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-2) max(var(--sp-4), env(safe-area-inset-right)) calc(var(--sp-2) + env(safe-area-inset-bottom)) max(var(--sp-4), env(safe-area-inset-left));
  background: var(--c-surface);
  border-top: 1px solid var(--c-line-soft);
}
.bottombar-two { flex-direction: row; }
.bottombar-two .btn { flex: 1; }

.bar-note { font-size: 1rem; font-weight: 600; color: var(--c-text-sub); }
.bar-danger { color: var(--c-danger); }

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

button, input, textarea, select, summary { font: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: var(--sp-2) var(--sp-4);
  border-radius: 10px;
  border: 2px solid var(--c-primary);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.btn-main {
  width: 100%;
  min-height: 56px;
  background: var(--c-primary);
  color: var(--c-on-color);
  font-size: 1.125rem;
}
.btn-sub {
  background: var(--c-surface);
  color: var(--c-primary);
}
.btn:active, .textbtn:active, .rowlink:active { filter: brightness(0.92); }
.btn-main[aria-disabled="true"], .btn:disabled {
  background: var(--c-disabled-bg);
  border-color: var(--c-disabled-bg);
  color: var(--c-disabled-text);
}
.btn:disabled { cursor: not-allowed; }
.btn-sub.btn-on {
  background: var(--c-disabled-bg);
  border-color: var(--c-disabled-bg);
  color: var(--c-disabled-text);
}

.textbtn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
  padding: var(--sp-2) var(--sp-3);
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--c-primary);
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.back { white-space: nowrap; }
.chip {
  border: 1px solid var(--c-line);
  border-radius: 999px;
  background: var(--c-surface);
}

:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 2px; }

.btnrow { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

.filebtn { width: 100%; }

/* ---------- 文字 ---------- */

.sub { font-size: 1rem; color: var(--c-text-sub); }
.big { font-size: 1.125rem; font-weight: 700; line-height: 1.4; }
.danger-text { color: var(--c-danger); font-weight: 600; }
.warn-text { color: var(--c-warn); background: var(--c-warn-bg); padding: var(--sp-3) var(--sp-4); border-radius: 12px; font-weight: 600; }
.saved { color: var(--c-ok); font-weight: 600; min-height: 1.5em; }

/* ---------- 注意の帯 ---------- */

.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  min-height: 48px;
  padding: var(--sp-3);
  border-radius: 12px;
  font-size: 1rem;
}
.notice-danger { background: var(--c-danger); color: var(--c-on-color); }
.notice-warn { background: var(--c-warn-bg); color: var(--c-warn); border: 1px solid var(--c-warn-line); }
.notice-icon { flex: none; width: 24px; height: 24px; margin-top: 2px; }
.notice-text, .notice-body { flex: 1; min-width: 0; }
.notice-body { display: flex; flex-direction: column; gap: var(--sp-2); }
.notice-btn {
  flex: none;
  min-height: 44px;
  min-width: 44px;
  padding: var(--sp-2) var(--sp-3);
  border-radius: 10px;
  border: 2px solid currentColor;
  background: transparent;
  color: inherit;
  font-weight: 600;
  cursor: pointer;
}
.notice-details summary { display: inline-flex; align-items: center; list-style: none; }
.notice-details summary::-webkit-details-marker { display: none; }
.steps { margin-top: var(--sp-2); padding-left: 1.5em; }

/* ---------- 一覧 ---------- */

.toast {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border-radius: 12px;
  background: var(--c-ok-bg);
  color: var(--c-ok);
}
.toast-text { flex: 1; font-weight: 600; }

.count { color: var(--c-text-sub); font-variant-numeric: tabular-nums; }

.subhead { font-size: 1.125rem; font-weight: 700; }
.subhead-due {
  color: var(--c-danger);
  border-left: 4px solid var(--c-danger);
  padding-left: var(--sp-2);
}

.rows { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-2); }

.row {
  background: var(--c-surface);
  border: 1px solid var(--c-line-soft);
  border-radius: 12px;
  overflow: hidden;
}
.row-due { background: var(--c-danger-bg); border-left: 4px solid var(--c-danger); }

.rowlink {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  width: 100%;
  min-height: 72px;
  padding: var(--sp-3) var(--sp-4);
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.line1, .line2 { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.rname { font-size: 1.125rem; font-weight: 700; line-height: 1.4; min-width: 0; overflow-wrap: anywhere; }
.rcompany { color: var(--c-text-sub); min-width: 0; overflow-wrap: anywhere; }
.rnext { flex: none; color: var(--c-text-sub); font-variant-numeric: tabular-nums; }
.rnext-due { color: var(--c-danger); font-weight: 700; }

.rowact { display: flex; flex-wrap: wrap; gap: var(--sp-2); padding: 0 var(--sp-4) var(--sp-3); }
.rowact .btn { flex: 1; }
.undo-btn { flex: none; }

.badge {
  display: inline-flex;
  align-items: center;
  flex: none;
  padding: var(--sp-1) var(--sp-3);
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--c-text-sub);
  background: var(--c-neutral-bg);
}
.badge-s1 { color: var(--c-accent); background: var(--c-accent-bg); }
.badge-s2 { color: var(--c-ok); background: var(--c-ok-bg); }
.badge-s3 { color: var(--c-purple); background: var(--c-purple-bg); }
.badge-s4 { color: var(--c-on-color); background: var(--c-ok-strong); }

.empty { text-align: center; padding: var(--sp-8) var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2); }
.empty-head { font-size: 1.125rem; font-weight: 700; }

/* ---------- 撮る ---------- */

.segment { display: flex; flex: none; }
.seg {
  min-height: 44px;
  min-width: 56px;
  padding: var(--sp-1) var(--sp-2);
  border: 2px solid var(--c-primary);
  background: var(--c-surface);
  color: var(--c-primary);
  font-weight: 600;
  cursor: pointer;
}
.seg:first-child { border-radius: 10px 0 0 10px; }
.seg:last-child { border-radius: 0 10px 10px 0; border-left: 0; }
.seg[aria-pressed="true"] { background: var(--c-primary); color: var(--c-on-color); }

.ready { font-weight: 600; }
.ready-ok { color: var(--c-ok); }
.failbox { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3); border: 2px solid var(--c-danger); border-radius: 12px; background: var(--c-danger-bg); }

.stage {
  position: relative;
  width: 100%;
  min-height: 120px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--c-camera-bg);
}
.video { display: block; width: 100%; height: auto; }
.frame {
  position: absolute;
  border: 3px solid var(--c-frame);
  border-radius: 6px;
  box-shadow: 0 0 0 9999px var(--c-shade);
  pointer-events: none;
}
.hint { font-weight: 600; text-align: center; }

.reading { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-4); border-radius: 12px; background: var(--c-surface); border: 1px solid var(--c-line-soft); }
.reading-text { font-size: 1.25rem; font-weight: 700; }
.bar { width: 100%; height: 8px; accent-color: var(--c-primary); }

/* ---------- 貼る ---------- */

.guide {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4);
  border: 1px solid var(--c-line);
  border-radius: 12px;
  background: var(--c-surface);
}
.guide-head { font-weight: 700; }
.guide-steps { padding-left: 1.5em; display: flex; flex-direction: column; gap: var(--sp-1); }

/* ---------- 入力欄 ---------- */

.field { display: flex; flex-direction: column; gap: var(--sp-2); }
.label { font-size: 1rem; font-weight: 600; }
.input {
  width: 100%;
  min-height: 48px;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--c-line);
  border-radius: 10px;
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 1rem;
  line-height: 1.5;
}
textarea.input { resize: vertical; }
.input-bad { border: 2px solid var(--c-danger); }
.fieldnote { color: var(--c-danger); font-weight: 600; }

.checkline { display: flex; gap: var(--sp-2); align-items: stretch; }
.checkline .input { flex: 1; min-width: 0; }
.check {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 112px;
  min-height: 48px;
  padding: var(--sp-1) var(--sp-2);
  border: 2px solid var(--c-warn-line);
  border-radius: 10px;
  background: var(--c-surface);
  color: var(--c-warn);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.check-on { border-color: var(--c-ok); background: var(--c-ok-bg); color: var(--c-ok); }
.check-input:focus-visible + .check { outline: 3px solid var(--c-focus); outline-offset: 2px; }

.rawbox summary { list-style: none; }

/* ---------- 写真 ---------- */

.photo-wrap { display: flex; flex-direction: column; gap: var(--sp-2); }
.photo-btn {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--c-line-soft);
  border-radius: 12px;
  overflow: hidden;
  background: var(--c-neutral-bg);
  cursor: zoom-in;
}
.photo { display: block; width: 100%; max-height: 200px; object-fit: contain; }
.photo-tag {
  position: absolute;
  right: var(--sp-2);
  bottom: var(--sp-2);
  padding: var(--sp-1) var(--sp-2);
  border-radius: 999px;
  background: var(--c-surface);
  color: var(--c-text);
  font-weight: 600;
}
.nophoto {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 96px;
  border-radius: 12px;
  background: var(--c-neutral-bg);
  color: var(--c-text-sub);
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: var(--c-camera-bg);
}
.viewer-scroll { flex: 1; overflow: auto; touch-action: pinch-zoom pan-x pan-y; }
.viewer-img { display: block; max-width: none; }
.viewer-close {
  position: absolute;
  top: calc(var(--sp-2) + env(safe-area-inset-top));
  right: max(var(--sp-2), env(safe-area-inset-right));
  z-index: 1;
  min-height: 44px;
  min-width: 44px;
  padding: var(--sp-2) var(--sp-3);
  border: 0;
  border-radius: 10px;
  background: var(--c-surface);
  color: var(--c-text);
  font-weight: 600;
}
.viewer-bar { padding: var(--sp-2) var(--sp-4) calc(var(--sp-2) + env(safe-area-inset-bottom)); }
.viewer-close-wide {
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 10px;
  background: var(--c-surface);
  color: var(--c-text);
  font-weight: 600;
}

/* ---------- 詳細 ---------- */

.stagebig { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.nextbig { font-size: 1.125rem; font-weight: 700; }
.box {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: 1px solid var(--c-line-soft);
  border-radius: 12px;
  background: var(--c-surface);
}
.boxhead { font-size: 1.125rem; font-weight: 700; }
.checkrow {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 52px;
  border-bottom: 1px solid var(--c-line-soft);
}
.checkrow input { width: 24px; height: 24px; flex: none; accent-color: var(--c-ok); }
.checkrow label { flex: 1; min-height: 52px; display: flex; align-items: center; cursor: pointer; }

.quick { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.quick .btn { flex: 1 1 8rem; }

.info { display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-2) var(--sp-3); }
.info dt { color: var(--c-text-sub); font-weight: 600; }
.info dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; user-select: text; }

.danger-zone { margin-top: var(--sp-8); }
.linelist { padding-left: 1.25em; display: flex; flex-direction: column; gap: var(--sp-1); }
.divider { width: 100%; border: 0; border-top: 1px solid var(--c-line-soft); margin: var(--sp-4) 0; }

/* ---------- 小窓 ---------- */

.sheet-back {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  background: var(--c-backdrop);
}
.sheet {
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-6) max(var(--sp-4), env(safe-area-inset-right)) calc(var(--sp-4) + env(safe-area-inset-bottom)) max(var(--sp-4), env(safe-area-inset-left));
  border-radius: 16px 16px 0 0;
  background: var(--c-surface);
  box-shadow: 0 -4px 16px var(--c-sheet-shadow);
}
.sheet-title { font-size: 1.25rem; font-weight: 700; }
.sheet-title:focus, .big:focus { outline: none; }
.compare { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.compare th, .compare td { padding: var(--sp-2); border-bottom: 1px solid var(--c-line-soft); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.compare th[scope="row"] { color: var(--c-text-sub); white-space: nowrap; }
.diff { font-weight: 700; }
.btn-danger { background: var(--c-danger); border-color: var(--c-danger); color: var(--c-on-color); }
