/* 名刺管理アプリ — デザイントークンは design_reference の値をそのまま使用 */
:root {
  --bg: oklch(0.97 0.005 60);
  --bg-card-area: oklch(0.985 0.004 60);
  --text: oklch(0.25 0.01 60);
  --text-sub: oklch(0.5 0.01 60);
  --text-aux: oklch(0.55 0.01 60);
  --text-aux2: oklch(0.6 0.01 60);
  --accent: #E8590C;
  --red: #C92A2A;
  --red-badge-bg: oklch(0.93 0.06 30);
  --red-border: #F1A9A9;
  --chip-ind-bg: oklch(0.95 0.03 40); --chip-ind-fg: oklch(0.4 0.1 40);
  --chip-tag-bg: oklch(0.95 0.02 250); --chip-tag-fg: oklch(0.4 0.1 250);
  --chip-evt-bg: oklch(0.95 0.02 160); --chip-evt-fg: oklch(0.4 0.1 160);
  --border: oklch(0.93 0.005 60);
  --border-input: oklch(0.9 0.005 60);
  --inactive-bg: oklch(0.94 0.005 60);
  --inactive-icon: oklch(0.6 0.01 60);
  --tab-inactive: oklch(0.7 0.01 60);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  font-family: 'Hiragino Sans', 'Noto Sans JP', system-ui, sans-serif;
  color: var(--text);
}
#app {
  max-width: 480px; margin: 0 auto; height: 100dvh;
  background: var(--bg-card-area);
  display: flex; flex-direction: column; overflow: hidden; position: relative;
}
input, button { font-family: inherit; }
.screen { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ── 共通ヘッダ・サマリー ── */
.pgtitle { font-size: 22px; font-weight: 800; color: var(--text); }
.head-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 8px; }
.summary { padding: 0 18px 10px; font-size: 13px; color: var(--text-sub); }

/* ── ビュー切替ボタン ── */
.viewbtns { display: flex; gap: 8px; }
.viewbtn { width: 34px; height: 34px; border-radius: 10px; background: var(--inactive-bg); display: flex; align-items: center; justify-content: center; cursor: pointer; border: none; padding: 0; }
.viewbtn.active { background: var(--accent); }
.icon-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; width: 14px; height: 14px; }
.icon-grid div { background: var(--inactive-icon); border-radius: 2px; }
.viewbtn.active .icon-grid div { background: #fff; }
.icon-lines { display: flex; flex-direction: column; gap: 3px; width: 16px; }
.icon-lines div { height: 2px; background: var(--inactive-icon); border-radius: 1px; }
.viewbtn.active .icon-lines div { background: #fff; }

/* ── カードグリッド／リスト ── */
.cards-wrap { padding: 4px 18px 90px; }
.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ccard { background: #fff; border-radius: 16px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); border: 1px solid var(--border); cursor: pointer; position: relative; }
.badge-review { background: var(--red-badge-bg); color: var(--red); font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 6px; }
.ccard .badge-review { position: absolute; top: 10px; right: 10px; }
.avatar { border-radius: 10px; background: oklch(0.9 0.09 40); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.ccard .avatar { width: 34px; height: 34px; font-size: 14px; margin-bottom: 10px; }
.ccard .co { font-size: 14px; font-weight: 700; line-height: 1.3; }
.ccard .who { font-size: 12px; color: var(--text-sub); margin-top: 2px; }
.chip-ind { display: inline-block; font-size: 10px; color: var(--chip-ind-fg); background: var(--chip-ind-bg); padding: 3px 8px; border-radius: 6px; margin-top: 8px; }
.chips-mini { display: flex; flex-wrap: wrap; gap: 4px; }
.chips-mini .chip-ind { margin-top: 8px; margin-right: 0; }
.ccard .note { margin-top: 6px; font-size: 11px; color: var(--text-aux); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.list-col { display: flex; flex-direction: column; gap: 10px; }
.lrow { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 14px; padding: 12px 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); border: 1px solid var(--border); cursor: pointer; }
.lrow .avatar { width: 38px; height: 38px; font-size: 15px; }
.lrow .mid { flex: 1; min-width: 0; }
.lrow .co { font-size: 14px; font-weight: 700; }
.lrow .who { font-size: 12px; color: var(--text-sub); }
.lrow .note { font-size: 11px; color: var(--text-aux2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lrow .chev { color: oklch(0.75 0.01 60); font-size: 16px; }
.empty-msg { text-align: center; padding: 40px 0; color: var(--text-aux2); font-size: 13px; }

/* ── FAB ── */
.fab { position: absolute; bottom: 96px; right: 26px; width: 58px; height: 58px; border-radius: 29px; background: var(--accent); box-shadow: 0 6px 16px rgba(232,89,12,0.4); display: flex; align-items: center; justify-content: center; cursor: pointer; border: none; color: #fff; font-size: 28px; line-height: 1; z-index: 5; }

/* ── タブバー ── */
.tabbar { display: flex; border-top: 1px solid oklch(0.92 0.005 60); background: #fff; padding: 8px 0 22px; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; border: none; background: none; padding: 0; }
.tab .lbl { font-size: 10px; font-weight: 600; color: var(--tab-inactive); }
.tab.active .lbl { color: var(--accent); }
.ti-home { width: 20px; height: 20px; border-radius: 5px; background: var(--tab-inactive); }
.tab.active .ti-home { background: var(--accent); }
.ti-search { width: 16px; height: 16px; border: 2px solid var(--tab-inactive); border-radius: 50%; position: relative; }
.ti-search::after { content: ''; position: absolute; width: 2px; height: 6px; background: var(--tab-inactive); bottom: -5px; right: -2px; transform: rotate(45deg); }
.tab.active .ti-search { border-color: var(--accent); }
.tab.active .ti-search::after { background: var(--accent); }
.ti-cat { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; width: 16px; height: 16px; }
.ti-cat div { background: var(--tab-inactive); border-radius: 2px; }
.tab.active .ti-cat div { background: var(--accent); }
.ti-set { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--tab-inactive); }
.tab.active .ti-set { border-color: var(--accent); }

/* ── 検索 ── */
.searchbox { display: flex; align-items: center; gap: 8px; background: var(--inactive-bg); border-radius: 12px; padding: 10px 12px; margin: 6px 18px 12px; }
.searchbox input { border: none; outline: none; background: transparent; font-size: 14px; flex: 1; color: var(--text); }
.si { width: 14px; height: 14px; border: 2px solid var(--text-aux); border-radius: 50%; position: relative; flex-shrink: 0; }
.si::after { content: ''; position: absolute; width: 2px; height: 7px; background: var(--text-aux); bottom: -6px; right: -2px; transform: rotate(45deg); }
.chip-rows { padding: 0 18px 10px; display: flex; flex-direction: column; gap: 8px; }
.chip-row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.fchip { flex-shrink: 0; font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 20px; cursor: pointer; background: var(--inactive-bg); color: oklch(0.4 0.01 60); border: none; }
.fchip.on { background: var(--accent); color: #fff; }
.fchip.add-new { border: 1px dashed oklch(0.8 0.005 60); color: var(--text-sub); background: var(--inactive-bg); }

/* ── カテゴリ管理 ── */
.cat-group { padding: 16px 18px 4px; }
.cat-label { font-size: 13px; font-weight: 700; color: oklch(0.4 0.01 60); margin-bottom: 8px; }
.cat-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-pill { display: flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--border-input); border-radius: 20px; padding: 6px 8px 6px 12px; font-size: 12px; color: oklch(0.3 0.01 60); }
.cat-pill .cnt { color: var(--text-aux); font-size: 11px; }
.cat-pill .del { width: 16px; height: 16px; border-radius: 50%; background: oklch(0.93 0.005 60); display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--text-sub); cursor: pointer; border: none; padding: 0; }
.cat-addrow { display: flex; gap: 8px; margin-top: 10px; }
.tin { flex: 1; font-size: 13px; border: 1px solid var(--border-input); border-radius: 10px; padding: 8px 12px; outline: none; color: var(--text); background: #fff; }
.btn-acc { background: var(--accent); color: #fff; font-size: 13px; font-weight: 700; padding: 8px 16px; border-radius: 10px; cursor: pointer; border: none; }

/* ── 撮影 ── */
.capture { flex: 1; background: #1b1b1b; display: flex; flex-direction: column; position: relative; }
.cap-close { position: absolute; top: 16px; left: 16px; width: 34px; height: 34px; border-radius: 17px; background: rgba(255,255,255,0.15); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 16px; cursor: pointer; z-index: 2; border: none; }
.cap-mid { flex: 1; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 16px; }
.cap-guide { width: 88%; aspect-ratio: 1.6; border: 2px dashed rgba(255,255,255,0.6); border-radius: 16px; display: flex; align-items: center; justify-content: center; }
.cap-guide div { color: rgba(255,255,255,0.6); font-size: 12px; letter-spacing: 0.05em; }
.cap-err { color: #FF8787; font-size: 12px; max-width: 80%; text-align: center; }
.cap-foot { padding-bottom: 34px; display: flex; justify-content: center; }
.shutter { width: 70px; height: 70px; border-radius: 35px; background: #fff; border: 4px solid rgba(255,255,255,0.4); cursor: pointer; display: block; }

/* ── 解析中 ── */
.processing { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: #fff; padding: 24px; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid oklch(0.93 0.03 40); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.processing .msg { font-size: 14px; color: oklch(0.45 0.01 60); }

/* ── 確認・編集 ── */
.confirm-head { padding: 14px 18px 4px; display: flex; align-items: center; justify-content: space-between; }
.confirm-head .t { font-size: 19px; font-weight: 800; }
.confirm-head .cancel { color: var(--text-aux); font-size: 14px; cursor: pointer; background: none; border: none; }
.warn-banner { margin: 8px 18px 0; padding: 10px 12px; background: oklch(0.96 0.04 30); border-radius: 10px; font-size: 12px; color: var(--red); font-weight: 600; }
.form-col { padding: 14px 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.fld-label-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.fld-label { font-size: 11px; font-weight: 700; color: var(--text-sub); }
.fld.low .fld-label { color: var(--red); }
.badge-mini { background: var(--red-badge-bg); color: var(--red); font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 5px; display: none; }
.fld.low .badge-mini { display: inline-block; }
.fld input { width: 100%; font-size: 14px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border-input); outline: none; color: var(--text); background: #fff; }
.fld.low input { border-color: var(--red-border); color: var(--red); }
.sec-label { margin-top: 6px; font-size: 11px; font-weight: 700; color: oklch(0.4 0.01 60); }
.axis-label { font-size: 11px; color: var(--text-sub); margin-bottom: 6px; }
.picker { display: flex; flex-wrap: wrap; gap: 6px; }
.inline-add { display: flex; gap: 8px; margin-top: 8px; }
.save-foot { padding: 12px 18px 22px; box-shadow: 0 -2px 8px rgba(0,0,0,0.04); background: var(--bg-card-area); }
.btn-save { width: 100%; background: var(--accent); color: #fff; text-align: center; font-size: 15px; font-weight: 700; padding: 13px; border-radius: 12px; cursor: pointer; border: none; }

/* ── 詳細 ── */
.detail-head { padding: 14px 18px 4px; display: flex; align-items: center; gap: 10px; }
.back { font-size: 20px; color: oklch(0.4 0.01 60); cursor: pointer; background: none; border: none; padding: 0 4px; }
.detail-head .t { font-size: 17px; font-weight: 800; flex: 1; }
.editlink { font-size: 13px; color: var(--accent); font-weight: 700; cursor: pointer; background: none; border: none; }
.dwrap { padding: 12px 18px 24px; }
.person { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.person .avatar { width: 48px; height: 48px; border-radius: 14px; font-size: 18px; }
.person .nm { font-size: 17px; font-weight: 800; }
.person .sub { font-size: 13px; color: var(--text-sub); }
.info-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.info-card .k { font-size: 11px; color: var(--text-sub); }
.info-card .v { font-size: 14px; font-weight: 600; word-break: break-all; }
.v.low, .nm.low { color: var(--red); }
.card-photo { margin-top: 14px; width: 100%; border-radius: 14px; border: 1px solid var(--border); }
.detail-chips { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.dchip { font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 20px; }
.dchip.ind { background: var(--chip-ind-bg); color: var(--chip-ind-fg); }
.dchip.tag { background: var(--chip-tag-bg); color: var(--chip-tag-fg); }
.dchip.evt { background: var(--chip-evt-bg); color: var(--chip-evt-fg); }
.del-link { margin-top: 24px; text-align: center; font-size: 13px; color: var(--text-aux2); cursor: pointer; background: none; border: none; width: 100%; }

/* ── 設定 ── */
.set-wrap { padding: 14px 18px 90px; }
.set-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; }
.member { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.member .avatar { width: 32px; height: 32px; font-size: 13px; background: oklch(0.9 0.02 250); color: oklch(0.4 0.1 250); }
.member .nm { font-size: 13px; font-weight: 600; }
.member .rl { font-size: 11px; color: var(--text-aux); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.toggle-row .tt { font-size: 13px; font-weight: 600; }
.toggle-row .td { font-size: 11px; color: var(--text-aux); margin-top: 2px; }
.switch { width: 44px; height: 26px; border-radius: 13px; background: oklch(0.88 0.005 60); position: relative; flex-shrink: 0; transition: background 0.15s; }
.switch.on { background: var(--accent); }
.switch .knob { width: 22px; height: 22px; border-radius: 11px; background: #fff; position: absolute; top: 2px; left: 2px; box-shadow: 0 1px 3px rgba(0,0,0,0.2); transition: left 0.15s; }
.switch.on .knob { left: 20px; }
.soon { font-size: 10px; font-weight: 700; color: var(--text-aux); background: var(--inactive-bg); border-radius: 5px; padding: 2px 6px; margin-left: 6px; vertical-align: middle; }
.logout { margin-top: 20px; text-align: center; font-size: 13px; color: var(--text-aux2); cursor: pointer; background: none; border: none; width: 100%; }

/* ── ログイン ── */
.login-wrap { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 32px 28px; gap: 14px; }
.login-logo { width: 64px; height: 64px; border-radius: 18px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: 800; margin: 0 auto 4px; }
.login-title { text-align: center; font-size: 20px; font-weight: 800; margin-bottom: 10px; }
.login-err { color: var(--red); font-size: 12px; text-align: center; min-height: 16px; }
.fld-l { font-size: 11px; font-weight: 700; color: var(--text-sub); margin-bottom: 4px; }
.login-wrap input { width: 100%; font-size: 15px; padding: 12px; border-radius: 10px; border: 1px solid var(--border-input); outline: none; background: #fff; }
.btn-login { width: 100%; background: var(--accent); color: #fff; font-size: 15px; font-weight: 700; padding: 13px; border-radius: 12px; border: none; cursor: pointer; margin-top: 8px; }

/* トースト */
#toast { position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); background: rgba(30,30,30,0.92); color: #fff; font-size: 13px; padding: 10px 18px; border-radius: 20px; opacity: 0; pointer-events: none; transition: opacity 0.25s; z-index: 50; max-width: 86%; text-align: center; }
#toast.show { opacity: 1; }
