:root {
  color-scheme: light;
  --bg: #f6efe3; --card: #fffaf2; --text: #4a3f35; --muted: #7a6b5b; --border: #e6dccb;
  --input-bg: #fffdf8; --input-border: #d9ccb6; --header-bg: #efe4d2;
  --primary: #a8643a; --primary-hover: #8f5230; --primary-text: #fff; --on-accent: #fff;
  --danger: #b3412f; --ok: #4d7c4f;
  --warn-bg: #f8e6c8; --warn-text: #7a4a12; --warn-border: #d9923f;
  --err-bg: #f6dcd6; --err-text: #8a2f25;
  --info-bg: #dde5ec; --info-text: #34506a;
  --parsed-bg: #e8e1ee; --parsed-text: #4f4268;
  --done-bg: #dde8d4; --done-text: #3f6b3a;
  --viewer-bg: #e9dfcf; --overlay-bg: rgba(60,45,30,.8); --overlay-btn: rgba(74,63,53,.82);
  --toast-bg: #4a3f35; --toast-text: #fffaf2; --backdrop: rgba(60,45,30,.45);
  --shadow: 0 4px 14px rgba(90,64,40,.14); --shadow-up: 0 -4px 14px rgba(90,64,40,.14);
  --shadow-sm: 0 1px 6px rgba(90,64,40,.08);
  --hover-tint: color-mix(in srgb, var(--primary) 12%, var(--card));
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 16px; background: var(--header-bg); border-bottom: 1px solid var(--input-border); box-shadow: var(--shadow-sm); }
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.topbar nav { display: flex; gap: 4px; align-items: center; }
.topbar nav a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--text); }
.topbar nav a.active { background: var(--primary); color: var(--primary-text); }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 6px 8px; }
.topbar nav a, .topbar nav .link-btn, .brand { white-space: nowrap; }
@media (max-width: 480px) {
  .topbar { padding: 8px 10px; gap: 4px; }
  .brand { font-size: 14px; }
  .topbar nav { gap: 0; }
  .topbar nav a { padding: 6px 8px; }
  .link-btn { padding: 6px 6px; font-size: 13px; }
}
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
h2 { margin: 0 0 12px; font-size: 18px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 16px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text); font: inherit; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.dropzone { border: 2px dashed var(--border); border-radius: 12px; padding: 32px 16px; text-align: center; color: var(--muted); }
.dropzone.over { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent); }
.desktop-only { display: block; }
.mobile-only { display: none; }
@media (max-width: 720px), (pointer: coarse) {
  .dropzone { display: none; }
  .mobile-only { display: flex; }
  .mobile-only .btn { flex: 1; min-height: 56px; font-size: 16px; }
}
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.progress > i { display: block; height: 100%; width: 0; background: var(--primary); transition: width .2s; }

.queue { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.queue li { display: flex; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }
.queue img, .thumb { width: 48px; height: 64px; object-fit: cover; border-radius: 6px; background: var(--border); flex: none; }
.queue .grow { flex: 1; min-width: 0; }
.queue .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--border); color: var(--text); }
.badge.Pending, .badge.Processing { background: var(--info-bg); color: var(--info-text); }
.badge.OcrNg, .badge.ParseNg { background: var(--err-bg); color: var(--err-text); }
.badge.NeedsReview { background: var(--warn-bg); color: var(--warn-text); }
.badge.Parsed { background: var(--parsed-bg); color: var(--parsed-text); }
.badge.Confirmed { background: var(--done-bg); color: var(--done-text); }
.spin::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 4px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -1px; }
@keyframes sp { to { transform: rotate(360deg); } }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tab { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--text); cursor: pointer; font: inherit; }
.tab.active { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.filters label { display: grid; gap: 2px; font-size: 12px; color: var(--muted); }
input[type=text], input[type=date], input[type=number], input[type=password], input[type=search], select {
  font: inherit; color: var(--text); background: var(--input-bg); border: 1px solid var(--input-border); border-radius: 8px; padding: 8px 10px; min-height: 40px; max-width: 100%; }
.summary { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.summary b { font-size: 18px; }

.rows { display: grid; gap: 8px; }
.row { display: grid; grid-template-columns: 48px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; background: var(--card);
  border: 1px solid var(--border); border-radius: 10px; text-decoration: none; color: var(--text); }
.row:hover { border-color: var(--primary); }
.row .main { min-width: 0; }
.row .l1 { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.row .store { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.row .l2 { font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.row .amount { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.row .warn { font-size: 12px; color: var(--warn-text); background: var(--warn-bg); border-radius: 6px; padding: 0 6px; display: inline-block; margin-top: 2px; }
.row .warn.err { color: var(--err-text); background: var(--err-bg); }

.detail { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 860px) { .detail { grid-template-columns: minmax(280px, 5fr) 6fr; align-items: start; } .detail .imgcol { position: sticky; top: 64px; } }

.band { padding: 10px 12px; border-radius: 10px; margin-bottom: 10px; font-size: 14px; }
.band.warn { background: var(--warn-bg); color: var(--warn-text); }
.band.err { background: var(--err-bg); color: var(--err-text); }
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--muted); }
.field input { width: 100%; min-width: 0; }
.field input[type=date] { -webkit-appearance: none; appearance: none; display: block; }
.field input[type=date]::-webkit-date-and-time-value { text-align: left; }
.evi { font-size: 11px; color: var(--muted); word-break: break-all; }
.evi:empty { display: none; }
.detail-nav { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 12px; align-items: center; flex-wrap: wrap; }
details { margin-top: 12px; }
details pre { white-space: pre-wrap; word-break: break-all; background: var(--bg); border-radius: 8px; padding: 10px; font-size: 12px; max-height: 300px; overflow: auto; }

.overlay { position: fixed; inset: 0; z-index: 50; background: var(--overlay-bg); overflow: auto; display: flex; }
.overlay img { margin: auto; max-width: 100%; max-height: 100%; cursor: zoom-in; touch-action: pan-x pan-y pinch-zoom; }
.overlay.full img { max-width: none; max-height: none; cursor: zoom-out; }
.overlay .close { position: fixed; top: 10px; right: 10px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--toast-bg); color: var(--toast-text); padding: 10px 16px; border-radius: 10px; z-index: 60; max-width: 90vw; }
.err { color: var(--danger); min-height: 1.4em; }
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 24px; width: 100%; max-width: 340px; display: grid; gap: 12px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; }
.login-card label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 32px 0; }

/* ---- 取り込み分レビュー / ビューア ---- */
.btn.big { width: 100%; min-height: 56px; font-size: 17px; margin-bottom: 12px; }
.queue .qlink { display: flex; gap: 10px; align-items: center; color: inherit; text-decoration: none; flex: 1; min-width: 0; }
.queue li:has(.qlink) { padding: 0; }
.queue .qlink { padding: 8px; }

.imgcol { --vh: var(--vvh, 100vh); }
.viewer { position: relative; overflow: hidden; height: calc(var(--vh) * .7); background: var(--viewer-bg); border-radius: 10px;
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.viewer:active { cursor: grabbing; }
.viewer img { position: absolute; left: 50%; top: 50%; max-width: none; max-height: none; width: auto; height: auto;
  transform-origin: center center; will-change: transform; pointer-events: none; }
.vtools { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; z-index: 2; }
.vtools button { background: var(--overlay-btn); color: var(--card); border: 0; border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.imgmeta { font-size: 12px; margin: 6px 0 0; }
.imgcol { background: var(--bg); }
@media (min-width: 860px) { .detail .imgcol { position: sticky; top: 64px; } }
@media (max-width: 859px) {
  .imgcol { position: sticky; top: 49px; z-index: 5; padding: 6px 0; margin-bottom: 8px; }
  .viewer { height: calc(var(--vh) * .4); }
  .imgmeta { display: none; }
}
input.warnfield { border-color: var(--warn-border); background: var(--warn-bg); }
button.evi { display: block; text-align: left; background: none; border: 0; padding: 2px 0; font: inherit; font-size: 11px; color: var(--muted); cursor: pointer; text-decoration: underline dotted; }

/* ---- 一覧のアコーディオン編集 ---- */
.rowwrap.gray { opacity: .5; }
.rowwrap .row { cursor: pointer; }
.rowwrap.open .row { border-color: var(--primary); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.editpanel { background: var(--card); border: 1px solid var(--primary); border-top: 0; border-radius: 0 0 10px 10px; padding: 12px; }
.pgrid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 860px) { .pgrid { grid-template-columns: minmax(280px, 5fr) 6fr; align-items: start; } }
.pviewer { position: relative; overflow: hidden; height: calc(var(--vvh, 100vh) * .45); background: var(--viewer-bg); border-radius: 10px; touch-action: none; user-select: none; cursor: grab; }
@media (min-width: 860px) { .pviewer { height: calc(var(--vvh, 100vh) * .6); } }
.pviewer img { position: absolute; left: 50%; top: 50%; max-width: none; max-height: none; transform-origin: center; pointer-events: none; }
.pband:empty { display: none; }

/* ---- プロフィール ---- */
.chip { flex: 0 1 auto; min-width: 0; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: auto; margin-left: 6px;
  padding: 3px 10px; border-radius: 999px; background: var(--pc, var(--primary)); color: var(--on-accent); font-size: 13px; font-weight: 600; text-decoration: none; }
.chip[hidden] { display: none; }
.pf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.pf-card { display: flex; flex-direction: column; background: var(--card); border: 2px solid var(--pc, var(--border)); border-radius: 14px; overflow: hidden; padding: 0; }
.pf-main { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; min-height: 96px; padding: 14px; background: color-mix(in srgb, var(--pc) 14%, var(--card));
  border: 0; color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.pf-name { font-size: 20px; font-weight: 700; }
.pf-badge { background: var(--pc); color: var(--on-accent); border-radius: 999px; padding: 1px 10px; font-size: 12px; font-weight: 600; }
.pf-card .link-btn { align-self: flex-end; }
.pf-add { align-items: center; justify-content: center; min-height: 96px; border-style: dashed; border-color: var(--border); color: var(--muted); font: inherit; font-size: 16px; cursor: pointer; }

/* ---- スマホ: ヘッダー2段 (1段目: ロゴ+プロフィール, 2段目: ナビ均等) ---- */
.chip::after { content: " \25BE"; }
@media (max-width: 480px) {
  .topbar { flex-wrap: wrap; row-gap: 4px; }
  .brand { order: 1; }
  .chip { order: 2; max-width: 9em; margin-left: auto; margin-right: 0; padding: 4px 10px; }
  .topbar nav { order: 3; width: 100%; }
  .topbar nav > * { flex: 1; text-align: center; }
  .topbar { top: 0; }
  .imgcol { top: 84px; }
}

/* ---- 店名オートコンプリート / 科目 / 店舗 ---- */
.field select { width: 100%; }
select.warnfield { border-color: var(--warn-border); background: var(--warn-bg); }
.ac-field { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: calc(100% - 2px); z-index: 20; max-height: 60vh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--primary); border-radius: 8px; box-shadow: var(--shadow); }
.ac-list[hidden] { display: none; }
.ac-item { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 10px 12px; min-height: 44px; cursor: pointer; border-bottom: 1px solid var(--border); }
.ac-item:last-child { border-bottom: 0; }
.ac-item.active, .ac-item:hover { background: var(--hover-tint); }
.ac-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-cat { color: var(--muted); font-size: 11px; white-space: nowrap; }
.row .catname { color: var(--text); background: var(--border); border-radius: 6px; padding: 0 6px; }
.catsum { margin: 0 0 8px; }
.fbox { margin: 0 0 12px; }
.fbox > summary { cursor: pointer; font-size: 14px; }
.fbox > summary .ic { width: 14px; height: 14px; margin-right: 4px; vertical-align: -0.15em; }
.fbox-active { margin-left: 6px; font-size: 12px; color: var(--primary); font-weight: 600; }
.fbox .filters { margin: 8px 0 0; }.catsum-row { display: grid; grid-template-columns: 1fr auto 7em; gap: 8px; padding: 2px 4px; font-size: 14px; }
.catsum-row b { text-align: right; font-variant-numeric: tabular-nums; }
.inline-form { display: flex; gap: 8px; padding: 10px; }
.inline-form input { flex: 1; min-width: 0; }
.catrow, .storerow { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.catrow.is-hidden { opacity: .6; }
.cmain { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; min-width: 0; flex: 1 1 12em; }
.cbtns { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cbtns select { min-height: 36px; padding: 4px 8px; max-width: 11em; }
.btn.sm { min-height: 36px; padding: 4px 10px; font-size: 14px; }
.dlg-back { position: fixed; inset: 0; z-index: 70; background: var(--backdrop); display: grid; place-items: center; padding: 16px; }
.dlg { background: var(--card); color: var(--text); border-radius: 14px; padding: 16px; width: 100%; max-width: 380px; max-height: 90vh; overflow: auto; }
.dlg h3 { margin: 0 0 8px; font-size: 17px; }
.dlg-label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.dlg-label input, .dlg-label select { width: 100%; }
.dlg-btns { margin-top: 12px; }
.dlg-btns .btn { flex: 1 1 auto; }

/* ---- 一括科目設定 ---- */
.selbox, .storesel { display: none; }
.selecting .selbox { display: inline-block; width: 20px; height: 20px; align-self: center; pointer-events: none; }
.storesel { display: flex; align-items: center; padding: 6px; }
.storesel input { width: 22px; height: 22px; }
.storerow .storesel { display: flex; }
.selinfo { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.inline-check { display: flex !important; align-items: center; gap: 6px; flex-direction: row; font-size: 13px !important; }
.selbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--card); border-top: 1px solid var(--primary);
  box-shadow: var(--shadow-up); padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); }
.selbar[hidden] { display: none; }
.selbar-in { max-width: 1100px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: end; }
.selbar-cat { display: grid; gap: 2px; font-size: 12px; color: var(--muted); flex: 1 1 10em; }
.selbar-cat select { width: 100%; }
.selbar-opt { flex: 1 1 100%; font-size: 13px; display: flex; gap: 6px; align-items: center; }
.selbar-opt.danger-note { color: var(--danger); font-weight: 600; }
.warn-note { margin: 0 0 6px; padding: 6px 10px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-text); font-size: 14px; }
body.selbar-on main { padding-bottom: 170px; }
body.selbar-on .toast { bottom: 190px; }

/* ---- アイコン (Lucide スプライト) ---- */
.ic { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
.btn .ic { width: 17px; height: 17px; vertical-align: 0; }
.btn.sm .ic { width: 15px; height: 15px; }
.topbar nav a, .topbar nav .link-btn { display: inline-flex; align-items: center; gap: 5px; }
.topbar nav .ic { width: 17px; height: 17px; }
.chip { display: inline-flex; align-items: center; gap: 5px; }
.chip > span { overflow: hidden; text-overflow: ellipsis; }
.chip .ic { width: 15px; height: 15px; }
.link-btn .ic { width: 15px; height: 15px; vertical-align: -3px; margin-right: 3px; }
.vtools button { display: inline-flex; align-items: center; gap: 4px; }
.vtools button[hidden] { display: none; }
.vtools .ic { width: 15px; height: 15px; }
.tabs .tab .ic { width: 15px; height: 15px; }
.ic.flip { transform: rotate(180deg); }
@media (max-width: 480px) {
  .topbar nav a, .topbar nav .link-btn { flex-direction: column; gap: 1px; font-size: 11px; line-height: 1.2; padding: 4px 4px; justify-content: center; }
  .topbar nav .ic { width: 20px; height: 20px; }
}
.pf-card .ic { width: 16px; height: 16px; }

/* ---- 科目アイコン (科目色の淡い丸背景 + 線画) ---- */
.cicon { --s: 30px; display: inline-grid; place-items: center; flex: none; width: var(--s); height: var(--s); border-radius: 50%;
  background: color-mix(in srgb, var(--cc, var(--muted)) 17%, var(--card)); color: var(--cc, var(--muted)); }
.cicon .ic { width: calc(var(--s) * .6); height: calc(var(--s) * .6); vertical-align: 0; }
.cicon.sm { --s: 26px; }
.cicon.xs { --s: 18px; }
.cicon.xs .ic { width: 12px; height: 12px; }
.row .catname { display: inline-flex; align-items: center; gap: 4px; padding-left: 2px; }
.catsum-name { display: inline-flex; align-items: center; gap: 6px; }
.ac-cat { display: inline-flex; align-items: center; gap: 4px; }
.cmain { align-items: center; }
.cmain .cicon { align-self: center; }
.selwrap { display: flex; align-items: center; gap: 6px; }
.selwrap select { flex: 1; min-width: 0; }
.selic:empty { display: none; }
.cbtns .selwrap select { max-width: 11em; }

/* ---- 科目チップ選択 ---- */
.catpick { border-radius: 10px; }
.catpick.warnfield { padding: 6px; background: var(--warn-bg); border: 1px solid var(--warn-border); }
.catgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
@media (min-width: 420px) { .catgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .catgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.catchip { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 8px; border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; text-align: left; min-width: 0; }
.catchip:hover:not([aria-disabled=true]) { background: var(--hover-tint); }
.catchip .cc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.catchip.on { border-color: var(--cc); background: color-mix(in srgb, var(--cc) 16%, var(--card)); font-weight: 600; }
.catchip.none:not(.on) { color: var(--muted); }
.catchip:focus-visible, .icbtn:focus-visible, .cobtn:focus-visible, .catdd-opt:focus-visible, .catdd-btn:focus-visible, .catmore:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.catchip[aria-disabled=true] { opacity: .55; cursor: default; }
.catmore { display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; padding: 6px 4px; background: none; border: 0; color: var(--primary); font: inherit; font-size: 13px; cursor: pointer; }

/* ---- 一括設定バーのカスタムドロップダウン ---- */
.catdd { position: relative; }
.catdd-btn { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; min-height: 40px; padding: 6px 10px; border: 1px solid var(--input-border);
  border-radius: 8px; background: var(--input-bg); color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.catdd-cur { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.catdd-pop { position: absolute; left: 0; right: 0; bottom: calc(100% + 4px); z-index: 40; max-height: 50vh; overflow-y: auto; min-width: 12em;
  background: var(--card); border: 1px solid var(--primary); border-radius: 10px; box-shadow: var(--shadow); padding: 4px; }
.catdd-pop[hidden] { display: none; }
.catdd-opt { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 4px 8px; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.catdd-opt:hover, .catdd-opt:focus { background: var(--hover-tint); }

/* ---- 科目のアイコン/色ピッカー ---- */
.stylepick { margin-top: 10px; }
.card > .stylepick, .cedit .stylepick { margin-top: 8px; }
.sp-label { font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.icongrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 4px; }
.icbtn { display: grid; place-items: center; height: 40px; border: 1.5px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text); cursor: pointer; padding: 0; }
.icbtn .ic { width: 22px; height: 22px; vertical-align: 0; }
.icbtn:hover { background: var(--hover-tint); }
.icbtn.on { border-color: var(--cc); background: color-mix(in srgb, var(--cc) 17%, var(--card)); color: var(--cc); }
.colorgrid { display: flex; flex-wrap: wrap; gap: 8px; }
.cobtn { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--card); background: var(--co); cursor: pointer; padding: 0; box-shadow: 0 0 0 1px var(--border); }
.cobtn.on { box-shadow: 0 0 0 2.5px var(--text); }
.catrow .cedit { flex: 1 1 100%; display: grid; gap: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
#catAdd .inline-form { padding: 0; }

/* ---- プロフィールバッジ: テーマになじませ、プロフィール色は丸ドットで示す ---- */
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--card); color: var(--text); border: 1px solid var(--input-border); }
.chip-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--pc, var(--primary)); }
.chip .chip-name { display: block; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip::after { flex: none; }

/* ---- 長い文字列(エラー文のURL等)を折り返す ---- */
.band, .warn, .row .main, .row .warn, .err { overflow-wrap: anywhere; word-break: break-word; }
.row .main { min-width: 0; }
.chip { min-width: 4.5em; }
.chip .chip-name { min-width: 1.5em; }
@media (min-width: 481px) and (max-width: 720px) {
  .topbar { flex-wrap: wrap; row-gap: 4px; }
  .topbar nav { order: 3; width: 100%; }
  .topbar nav > * { flex: 1; justify-content: center; }
  .chip { margin-left: auto; margin-right: 0; }
}

/* 処理一時停止の帯(クレジット切れ等) */
.pausebar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 16px; background: var(--warn-bg);
  color: var(--warn-text); border-bottom: 2px solid var(--warn-border); }
.pausebar[hidden] { display: none; }
/* Google Vision が使えず代替方式で処理中の控えめな注意帯 */
.visionbar { padding: 6px 16px; background: var(--info-bg); color: var(--info-text); font-size: 13px; }
.visionbar[hidden] { display: none; }
.visionbar .ic { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }
.usage-warn { color: var(--warn-text); font-weight: 700; }
.pausebar .msg { flex: 1 1 260px; font-weight: 600; }
.pausebar .msg small { display: block; font-weight: 400; }
.badge.Held { background: var(--warn-bg); color: var(--warn-text); border: 1px solid var(--warn-border); }

/* 処理状況 */
.qbadge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; background: var(--info-bg); color: var(--info-text);
  font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.qbadge[hidden] { display: none; }
.qbadge .ic { width: 14px; height: 14px; animation: qspin 2s linear infinite; }
@keyframes qspin { to { transform: rotate(360deg); } }
.qsum { font-size: 17px; font-weight: 700; }
.qlist { list-style: none; margin: 0; padding: 0; }
.qlist li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.qlist li:last-child { border-bottom: 0; }
.qlist .pos { min-width: 2.2em; color: var(--muted); font-variant-numeric: tabular-nums; }
.qlist .fn { flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; }
.qlist .meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.pdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; background: var(--muted); }
.qlist .errmsg { flex-basis: 100%; color: var(--err-text); font-size: 12px; }
.qlist .btn { padding: 2px 10px; font-size: 13px; }
@media (max-width: 520px) { .qbadge span { display: none; } .qbadge { padding: 3px 8px; } }

/* 注意(NeedsReview にしない補足) */
.vnote { margin: 0 0 10px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.vnote .ic { width: 14px; height: 14px; margin-right: 4px; vertical-align: -0.2em; }

.buildinfo { position: fixed; right: 12px; bottom: 8px; font-size: 11px; color: var(--muted); pointer-events: none; }
