/* =========================================================
   FAX送信アプリ  画面デザイン（案A：ブランド）
   e-NAQUESTのロゴの「黒」と「シアン」だけで組む。
   ・地は白。区切りは細い線で、箱を並べない
   ・黒は「送る」に関わる強い操作（送信バー・主要ボタン）
   ・シアンは「いま選んでいるもの」と入力中の印
   ・書体は BIZ UDPゴシック（数字の読み間違いを防ぐ）
   ========================================================= */
:root {
  --ink: #000;            /* ロゴの黒 */
  --text: #23272b;
  --muted: #687076;
  --faint: #9aa1a7;
  --line: #e3e7ea;
  --surface: #f2f4f5;     /* 入力欄・押せる面 */
  --card: #fff;
  --cyan: #00a0e9;        /* ロゴのシアン */
  --cyan-ink: #0072a8;    /* 白地に置く文字用（読みやすい濃さ） */
  --cyan-wash: #e5f5fc;
  --ok: #1a7f4b;  --ok-bg: #e4f4ea;
  --ng: #c42b2b;  --ng-bg: #fdeaea;
  --warn: #8a5a00; --warn-bg: #fff3d6;
  --r-s: 10px; --r-m: 14px; --r-l: 20px;
  --tap: 48px;
  --font: "BIZ UDPGothic", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  /* 古い部品との互換 */
  --bg: #fff; --primary: var(--ink); --accent: var(--cyan); --radius: var(--r-m);
  font-family: var(--font);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: #fff; }
body { font-size: 16px; line-height: 1.65; padding-bottom: calc(72px + env(safe-area-inset-bottom)); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1 { font-size: 24px; line-height: 1.35; margin: 0 0 6px; font-weight: 700; color: var(--ink); }
h2 { font-size: 17px; line-height: 1.4; margin: 0 0 14px; font-weight: 700; color: var(--ink); }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 8px 0 0; }
.error { color: var(--ng); font-size: 14px; min-height: 1.4em; margin: 6px 0; }
.req { font-style: normal; font-size: 11px; font-weight: 700; color: var(--ng); margin-left: 6px; vertical-align: 1px; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }

/* ---------- ブランドの印（ロゴの輪をかたどったもの） ---------- */
.mark { width: 26px; height: 26px; border-radius: 50%; flex: none; border: 6px solid var(--ink); box-shadow: inset 0 0 0 5px var(--cyan); }

/* ---------- 上部 ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(255,255,255,.94); -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line); padding: calc(14px + env(safe-area-inset-top)) 20px 12px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 700; color: var(--ink); letter-spacing: .02em; }
#app { max-width: 640px; margin: 0 auto; padding: 4px 20px 24px; }

/* 区切り：箱ではなく線で分ける */
.card { background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 22px 0; margin: 0; }
.view > .card:last-of-type { border-bottom: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }

/* ---------- 入力 ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
input[type=text], input:not([type]), input[type=password], input[inputmode], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--surface);
  border: 1.5px solid transparent; border-radius: var(--r-s); padding: 11px 14px; min-height: var(--tap);
  transition: background-color .15s, border-color .15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
select { appearance: none; -webkit-appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center; }
textarea { resize: vertical; line-height: 1.7; }
input:focus, select:focus, textarea:focus { outline: none; background-color: #fff; border-color: var(--cyan); }
.row2 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 520px) { .row2 { grid-template-columns: 1fr 1fr; } }
.check, .switch { display: flex; align-items: center; gap: 10px; min-height: var(--tap); font-size: 15px; cursor: pointer; }
.check input, .switch input, .pick input { width: 22px; height: 22px; accent-color: var(--cyan); }
/* スイッチ */
.switch input { appearance: none; -webkit-appearance: none; width: 46px; height: 28px; border-radius: 999px; background: #cfd5da; position: relative; flex: none; cursor: pointer; transition: background-color .2s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked { background: var(--cyan); }
.switch input:checked::after { transform: translateX(18px); }

/* ---------- ボタン ---------- */
.btn { font: inherit; font-size: 15px; font-weight: 700; min-height: var(--tap); padding: 8px 20px; border-radius: 999px; border: 1.5px solid #d6dbdf; background: #fff; color: var(--ink);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; white-space: nowrap; transition: background-color .15s, border-color .15s, transform .1s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.danger { color: var(--ng); border-color: #f1c9c9; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small { min-height: 38px; padding: 4px 14px; font-size: 14px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .4; }
.btn.on { background: var(--cyan); color: #fff; border-color: var(--cyan); }
.ico { width: 22px; height: 22px; flex: none; color: var(--cyan); }
.ico svg { width: 100%; height: 100%; display: block; }

.badge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--cyan-wash); color: var(--cyan-ink); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.ng { background: var(--ng-bg); color: var(--ng); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- 選択肢（送信元など） ---------- */
.seg { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 14px; }
.seg label { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1.5px solid transparent; border-radius: var(--r-m); padding: 12px 16px; min-height: 54px; cursor: pointer; font-size: 15px; transition: border-color .15s, background-color .15s; }
.seg input { width: 20px; height: 20px; accent-color: var(--cyan); flex: none; }
.seg label:has(input:checked) { background: #fff; border-color: var(--cyan); font-weight: 700; color: var(--ink); }

/* 送り方の切り替え（書類を送る／表紙だけ送る） */
.mode-seg { grid-template-columns: 1fr 1fr !important; background: var(--surface); border-radius: 999px; padding: 4px; gap: 4px !important; margin: 16px 0 6px; }
.mode-seg label { justify-content: center; min-height: 44px; border-radius: 999px; padding: 8px; background: transparent; border: 0; color: var(--muted); font-weight: 700; }
.mode-seg label:has(input:checked) { background: var(--ink); color: #fff; }
.mode-seg input { position: absolute; opacity: 0; pointer-events: none; }
.mode-seg label:has(input:focus-visible) { outline: 3px solid var(--cyan); outline-offset: 2px; }

/* 書類の追加ボタン */
.add-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 6px; }
.add-buttons .btn { white-space: normal; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 14px; min-height: 96px; padding: 14px 16px; border-radius: var(--r-m);
  background: var(--surface); border-color: transparent; text-align: left; font-size: 14px; line-height: 1.4; }
.add-buttons .btn .ico { width: 26px; height: 26px; }

/* ---------- 書類の一覧 ---------- */
.pages { list-style: none; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.pages li { border-radius: var(--r-m); padding: 0; background: transparent; }
.pages .thumb { width: 100%; aspect-ratio: 210 / 297; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 8px; display: block; cursor: zoom-in; box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.pages .cap { font-size: 13px; color: var(--text); font-weight: 700; margin: 8px 2px 6px; display: flex; justify-content: space-between; gap: 6px; }
.pages .cap span:last-child { color: var(--muted); font-weight: 400; flex: none; }
.pages .ops { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.pages .ops button { min-height: 36px; padding: 0; font-size: 13px; border-radius: 8px; background: var(--surface); border-color: transparent; }
.pages .ops button.danger { background: var(--ng-bg); }

/* ---------- 送信バー（画面で一番目立つ要素） ---------- */
.sendbar { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 5; margin-top: 18px; background: var(--ink); color: #fff; border-radius: var(--r-l);
  padding: 10px 10px 10px 22px; display: flex; align-items: center; justify-content: space-between; gap: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.22); }
.sendbar .muted { color: #9aa3aa; font-size: 13px; }
.sendbar strong { font-size: 28px; line-height: 1; letter-spacing: .01em; }
.sendbar .btn.primary { background: var(--cyan); border-color: var(--cyan); min-height: 52px; padding: 0 22px; font-size: 16px; }

/* ---------- 下のメニュー ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(3, 1fr); background: rgba(255,255,255,.96);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { font: inherit; font-size: 12px; font-weight: 700; background: none; border: 0; min-height: 62px; color: var(--faint); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; position: relative; }
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button.active { color: var(--ink); }
.tabbar button.active::before { content: ""; position: absolute; top: -1px; left: 50%; width: 28px; height: 3px; margin-left: -14px; border-radius: 0 0 3px 3px; background: var(--cyan); }

/* ---------- 宛先 ---------- */
.recips { list-style: none; padding: 0; margin: 0 0 12px; background: var(--surface); border-radius: var(--r-m); }
.recips li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 8px 12px 16px; border-top: 1px solid #e4e8eb; }
.recips li:first-child { border-top: 0; }
.r-name { font-weight: 700; color: var(--ink); }
.l-sub { font-size: 13px; color: var(--muted); }
.manual { margin-top: 14px; }
.manual > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; min-height: var(--tap); font-size: 14px; font-weight: 700; color: var(--muted); }
.manual > summary::-webkit-details-marker { display: none; }
.manual > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; margin: 0 4px 0 2px; }
.manual[open] > summary::before { transform: rotate(45deg); }
.manual[open] > summary { margin-bottom: 6px; }
#btn-pick-contacts { border-style: dashed; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.chip { font: inherit; font-size: 14px; font-weight: 700; min-height: 38px; padding: 4px 16px; border-radius: 999px; border: 0; background: var(--surface); color: var(--text); cursor: pointer; }
.chip.on { background: var(--ink); color: #fff; }
.pick-list { list-style: none; padding: 0; margin: 0; }
.pick-list li { border-top: 1px solid var(--line); }
.pick { display: flex; align-items: center; gap: 14px; padding: 12px 0; min-height: 56px; cursor: pointer; }
.pick input { flex: none; }
.pick .l-main { display: flex; flex-direction: column; }
.recip-mini { margin: 6px 0 0; padding-left: 1.4em; font-weight: 400; font-size: 14px; max-height: 180px; overflow: auto; }

/* ---------- 履歴・一覧 ---------- */
.history, .list { list-style: none; padding: 0; margin: 0; }
.history li, .list li { border-top: 1px solid var(--line); padding: 16px 0; }
.history li:first-child, .list li:first-child { border-top: 0; }
.h-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.h-to { font-weight: 700; color: var(--ink); }
.h-meta { font-size: 13px; color: var(--muted); margin-top: 2px; word-break: keep-all; overflow-wrap: anywhere; }
.h-ops { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.h-detail { font-size: 12px; color: var(--muted); background: var(--surface); border-radius: var(--r-s); padding: 8px 12px; margin-top: 8px; word-break: break-all; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.list .l-main { min-width: 0; }

/* ---------- 作業画面（全画面） ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; background: #0c0d0e; color: #fff; display: flex; flex-direction: column; }
.sheet.light { background: #fff; color: var(--text); }
.sheet-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; background: transparent; border-bottom: 1px solid rgba(255,255,255,.12); }
.sheet.light .sheet-head { border-bottom-color: var(--line); }
.sheet-head h2 { margin: 0; font-size: 16px; text-align: center; color: inherit; }
.sheet-head .btn.ghost { color: inherit; border-color: transparent; padding-left: 8px; }
.sheet-head .btn.ghost::before { content: ""; width: 9px; height: 9px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin-right: 2px; }
.sheet-head .btn.primary { background: var(--cyan); border-color: var(--cyan); color: #fff; }
.sheet-body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 16px; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
.sheet.light .sheet-body { max-width: 640px; width: 100%; margin: 0 auto; }
.sheet.light .sheet-body > div > .card:first-child { padding-top: 4px; }

.stage { position: relative; margin: 0 auto; touch-action: none; user-select: none; -webkit-user-select: none; }
.stage canvas { display: block; width: 100%; height: auto; background: #fff; border-radius: 4px; }
.handle { position: absolute; width: 38px; height: 38px; margin: -19px 0 0 -19px; border-radius: 50%; border: 3px solid #fff; background: var(--cyan); box-shadow: 0 2px 8px rgba(0,0,0,.45); touch-action: none; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 12px 0; }
.tools .btn { min-width: 60px; }
.sheet:not(.light) .tools .btn:not(.on) { background: #1f2225; color: #fff; border-color: #2e3236; }
.slider { display: flex; align-items: center; gap: 12px; max-width: 520px; margin: 10px auto; font-size: 14px; }
.slider input[type=range] { flex: 1; accent-color: var(--cyan); }
.slider input[type=text] { flex: 1; }
.tip { text-align: center; font-size: 13px; color: #aab2b9; margin: 8px 0; }
.sheet.light .tip { color: var(--muted); }
.page-view { max-width: 600px; margin: 0 auto; }
.page-view img, .page-view canvas { width: 100%; height: auto; background: #fff; border: 1px solid var(--line); border-radius: 6px; display: block; margin-bottom: 14px; box-shadow: 0 4px 18px rgba(0,0,0,.07); }

.summary { width: 100%; border-collapse: collapse; font-size: 15px; margin-bottom: 14px; }
.summary th { text-align: left; color: var(--muted); font-weight: 400; width: 6.5em; vertical-align: top; padding: 10px 0; border-bottom: 1px solid var(--line); }
.summary td { padding: 10px 0; font-weight: 700; color: var(--ink); word-break: break-all; border-bottom: 1px solid var(--line); }
.thumbs { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 10px; }
.thumbs img { height: 150px; border: 1px solid var(--line); border-radius: 6px; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.08); cursor: zoom-in; }
.notice { background: var(--warn-bg); color: var(--warn); border-radius: var(--r-m); padding: 12px 16px; font-size: 14px; margin-bottom: 14px; }
.done { text-align: center; padding: 28px 8px 20px; }
.done .big { font-size: 22px; font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.done .big::before { content: ""; display: block; width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 50%; background: var(--cyan-wash)
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='%230072a8' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center no-repeat; }

.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 100; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: var(--r-m); font-size: 14px; max-width: 90vw; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.ng { background: var(--ng); }

.busy { position: fixed; inset: 0; z-index: 200; background: rgba(255,255,255,.7); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; }
.busy span { display: flex; align-items: center; gap: 12px; background: var(--ink); color: #fff; padding: 16px 24px; border-radius: var(--r-m); font-size: 15px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.busy span::before { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); border-top-color: var(--cyan); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- ログイン ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; border: 0; padding: 0; }
.login-card .mark { width: 44px; height: 44px; border-width: 10px; box-shadow: inset 0 0 0 8px var(--cyan); margin-bottom: 22px; }
.login-card h1 { font-size: 28px; }
.login-card .muted { margin: 0 0 26px; }
.login-card .btn { min-height: 54px; font-size: 16px; }

/* ---------- 自由レイアウト ---------- */
.lay-editor .tools { margin: 8px 0; }
.lay-editor select { width: auto; min-height: 38px; padding: 4px 36px 4px 14px; font-size: 14px; border-radius: 999px; background-position: right 12px center; }
.lay-stage { border: 1px solid var(--line); background: #fff; border-radius: 6px; box-shadow: 0 4px 18px rgba(0,0,0,.07); }
.sel-box { position: absolute; border: 2px dashed var(--cyan); border-radius: 4px; pointer-events: none; }
.rs-handle { position: absolute; width: 32px; height: 32px; margin: -16px 0 0 -16px; border-radius: 50%; background: var(--cyan); border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); touch-action: none; cursor: nwse-resize; }
.lay-panel { background: var(--surface); border-radius: var(--r-m); padding: 14px 16px; margin-bottom: 12px; }
.lay-panel textarea { background: #fff; }
.lay-panel .slider { max-width: none; }
.lay-panel .num { min-width: 2.5em; text-align: right; font-weight: 700; }
.mini-seg { display: inline-flex; gap: 4px; }

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