:root {
  --bg: #FAFAFB; --panel: #fff; --ink: #0F2747; --soft: #6B7280; --line: #E5E7EB;
  --accent: #3B6BFF; --accent-ink: #fff; --danger: #c0392b; --ok: #2CC4A5; --radius: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 "Arimo", sans-serif; background: var(--bg); color: var(--ink); }
[hidden] { display: none !important; }
h2, h3 { margin: 0; }
h2 { font-size: 22px; letter-spacing: -.3px; }
h3 { font-size: 15px; margin-bottom: 14px; }
h3.mt { margin-top: 22px; }
.muted { color: var(--soft); }
.small-note { font-size: 12px; }

/* top bar */
.bar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.bar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
#who { color: var(--soft); margin-right: 4px; }

/* layout */
.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 20px 40px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; margin-top: 16px; }
.side { position: sticky; top: 72px; display: grid; gap: 16px; }
@media (max-width: 960px) { .layout { grid-template-columns: minmax(0, 1fr); } .side { position: static; } }
.row-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 0 0 16px; }
.side .panel { margin: 0; }
.panel.narrow { max-width: 380px; margin: 48px auto; }
.dirty { color: #b26a00; background: #fff4dc; border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 600; }

/* form */
label { display: block; margin: 0 0 12px; color: var(--soft); font-size: 12px; font-weight: 500; }
input, select, textarea {
  display: block; width: 100%; margin-top: 5px; padding: 10px 12px; font: inherit; font-size: 14px; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 9px; min-width: 0;
}
input:focus, select:focus, textarea:focus, button:focus-visible, .drop:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input.invalid { border-color: var(--danger); }
textarea { resize: vertical; }
.req { color: var(--danger); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 12px; }
.cols.c3 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.slug { display: flex; align-items: center; margin-top: 5px; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.slug span { padding: 0 0 0 12px; color: var(--soft); white-space: nowrap; font-size: 13px; }
.slug input { border: 0; margin: 0; border-radius: 0; padding-left: 2px; }
.slug:focus-within { outline: 2px solid var(--accent); }
.slug input:focus { outline: none; }

/* buttons */
button, .btn { font: inherit; font-size: 14px; cursor: pointer; border-radius: 9px; padding: 9px 14px; border: 1px solid var(--line); background: #fff; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
button:hover, .btn:hover { background: #EEF2FF; }
button.ghost { background: transparent; }
button.small { padding: 6px 12px; font-size: 13px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover { opacity: .9; background: var(--accent); }
button.primary:disabled { opacity: .5; cursor: progress; }
button.block { width: 100%; }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button.x { padding: 9px 0; width: 34px; color: var(--soft); font-size: 12px; }
button.x:disabled { opacity: .3; cursor: default; }
.ctrl { display: flex; gap: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.error { color: var(--danger); min-height: 1.2em; margin: 6px 0; font-size: 13px; }

/* sticky save bar */
.savebar { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 16px; background: rgba(255,255,255,.92); backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: var(--radius); margin-top: 4px; z-index: 10; }
.savebar .error { margin: 0 auto 0 0; }

/* uploads */
.uploads { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; }
@media (max-width: 560px) { .uploads { grid-template-columns: 1fr; } }
.drop { height: 140px; border: 2px dashed var(--line); border-radius: 12px; display: grid; place-items: center; cursor: pointer; overflow: hidden; background: #fafafb; text-align: center; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: #EEF2FF; }
.drop { position: relative; }
.drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 10px; }
#photoUpload .drop { border-radius: 50%; width: 140px; margin: 0 auto; }
#photoUpload .drop img { object-fit: cover; padding: 0; }
.hint { color: var(--soft); font-size: 13px; padding: 8px; }
.hint small { display: block; font-size: 11px; margin-top: 4px; }
.up-actions { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }
.status { text-align: center; font-size: 12px; margin: 6px 0 0; min-height: 1.1em; color: var(--soft); }
.status.err { color: var(--danger); }

/* list */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-top: 16px; }
.card-tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 14px; }
.tile-head { display: flex; gap: 14px; align-items: center; min-width: 0; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--bg); object-fit: cover; flex: none; display: grid; place-items: center; font-weight: 700; color: var(--soft); border: 1px solid var(--line); }
.tile-head h4 { margin: 0; font-size: 16px; }
.tile-head p { margin: 2px 0 0; color: var(--soft); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-head > div { min-width: 0; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: #eee; color: var(--soft); }
.badge.active { background: #e2f5ec; color: var(--ok); }
.tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

/* share panel */
#qrPreview { width: 100%; max-width: 240px; background: #fff; border: 1px solid var(--line); padding: 8px; border-radius: 12px; display: block; margin: 0 auto 12px; }
.linkrow { display: flex; gap: 8px; margin-bottom: 10px; }
.linkrow input { margin: 0; font-size: 12px; }
#stats { list-style: none; padding: 0; margin: 0; }
#stats li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
#preview { width: 100%; height: 520px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }

/* dialog + toast */
dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; width: min(380px, calc(100vw - 32px)); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog .actions { justify-content: flex-end; margin-top: 8px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; opacity: 0; pointer-events: none; transition: .25s; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); }

/* autocomplete popup */
.suggest { position: fixed; z-index: 40; margin: 0; padding: 4px; list-style: none; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 260px; overflow: auto; }
.suggest li { padding: 9px 10px; border-radius: 7px; cursor: pointer; font-size: 14px; }
.suggest li:hover, .suggest li.active { background: #EEF2FF; }

/* ---------- repeatable rows (grip | fields | controls) ---------- */
.item { display: grid; grid-template-columns: 16px 150px minmax(0, 1fr) auto; gap: 8px; margin-bottom: 8px; align-items: center; border-radius: 10px; }
.item input, .item select { margin: 0; }
.item.addr { grid-template-columns: 16px 110px minmax(0, 1fr) minmax(0, 1fr) auto; }
.item.addr .wide { grid-column: 3 / 5; display: grid; grid-template-columns: 1fr 1fr 110px; gap: 8px; }
.item.addr > .ctrl { grid-column: 5; grid-row: 1; }
.item.dragging { opacity: .5; background: #EEF2FF; }
.grip { color: #b4b4bd; cursor: grab; user-select: none; letter-spacing: -3px; font-size: 14px; text-align: center; }
.grip:active { cursor: grabbing; }
@media (max-width: 640px) {
  .item, .item.addr { grid-template-columns: 18px minmax(0, 1fr) auto; align-items: start; }
  .item > .grip { grid-column: 1; grid-row: 1 / span 4; align-self: center; }
  .item > select, .item > input { grid-column: 2; }
  .item > .ctrl { grid-column: 3; grid-row: 1 / span 4; align-self: center; flex-direction: column; }
  .item.addr .wide { grid-column: 2; grid-template-columns: 1fr; }
  .item.addr > .ctrl { grid-column: 3; grid-row: 1 / span 4; }
}

/* ---------- section chips ---------- */
.secnav { position: sticky; top: 53px; z-index: 15; display: flex; gap: 6px; overflow-x: auto; padding: 10px 0; margin: 12px 0 0; background: var(--bg); scrollbar-width: none; }
.secnav::-webkit-scrollbar { display: none; }
.secnav a { flex: none; padding: 6px 13px; border-radius: 999px; font-size: 13px; color: var(--soft); text-decoration: none; border: 1px solid transparent; }
.secnav a:hover { color: var(--ink); background: #fff; }
.secnav a.on { color: var(--accent-ink); background: var(--accent); }
.panel[id^="sec-"] { scroll-margin-top: 120px; }
.layout { margin-top: 4px; }
.side { top: 112px; }

/* ---------- list search + header actions ---------- */
.search { margin: 16px 0 0; max-width: 360px; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-head.tight { margin-bottom: 12px; } .row-head.tight h3 { margin: 0; }
select.mini { width: auto; margin: 0; padding: 5px 8px; font-size: 12px; }

/* ---------- analytics ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.tile-stat { background: var(--bg); border-radius: 10px; padding: 10px 8px; text-align: center; }
.tile-stat strong { display: block; font-size: 22px; line-height: 1.1; }
.tile-stat span { display: block; font-size: 11px; color: var(--soft); margin-top: 3px; }
.chart svg { width: 100%; height: 110px; display: block; }
.axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--soft); margin-top: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: var(--soft); margin-top: 10px; }
.legend i, .recent i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
h4.sub { margin: 16px 0 6px; font-size: 13px; }
.recent { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.recent li { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.recent time { color: var(--soft); font-size: 12px; white-space: nowrap; }

/* ---------- polish ---------- */
.panel { box-shadow: 0 1px 2px rgba(20,20,40,.04); }
.panel h3 { display: flex; align-items: center; gap: 8px; }
.card-tile { transition: box-shadow .15s, transform .15s; }
.card-tile:hover { box-shadow: 0 6px 20px rgba(20,20,40,.08); transform: translateY(-1px); }
input:hover, select:hover, textarea:hover { border-color: #c9c9d3; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.savebar { box-shadow: 0 -6px 18px rgba(20,20,40,.05); }

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  .bar { padding: 10px 14px; flex-wrap: wrap; row-gap: 6px; }
  .bar-right { gap: 6px; }
  #who { display: none; }
  .secnav { top: 49px; }
  .wrap { padding: 16px 12px 32px; }
  .panel { padding: 16px; border-radius: 12px; }
  h2 { font-size: 19px; }
  .row-head { align-items: flex-start; }
  .savebar { flex-wrap: wrap; padding: 10px 12px; }
  .savebar .error { flex: 1 1 100%; }
  .savebar button { flex: 1; min-height: 44px; }
  button, .btn, input, select { min-height: 40px; }
  button.small, .btn.small { min-height: 34px; }
  button.x { min-height: 34px; }
  .cards-grid { grid-template-columns: 1fr; }
  .tiles { gap: 6px; }
  #preview { height: 440px; }
  .search { max-width: none; }
}
.savebar .error:empty { display: none; }

/* ---------- top navigation ---------- */
.topnav { display: flex; gap: 4px; margin-left: 12px; }
.topnav button { border: 0; background: transparent; padding: 7px 14px; border-radius: 999px; color: var(--soft); font-weight: 500; }
.topnav button:hover { background: #EEF2FF; color: var(--ink); }
.topnav button.on { background: var(--accent); color: var(--accent-ink); }
@media (max-width: 640px) { .topnav { order: 3; width: 100%; margin: 0; overflow-x: auto; } .topnav button { min-height: 34px; } }

/* ---------- phone-style preview frame ---------- */
.phone { background: #1F2937; border-radius: 30px; padding: 10px; }
.phone iframe { display: block; width: 100%; height: 560px; border: 0; border-radius: 22px; background: #fff; }
#preview { border: 0; border-radius: 22px; height: 560px; }

/* ---------- themes ---------- */
.theme-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.theme-tile { display: grid; gap: 6px; text-align: left; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.theme-tile.on { outline: 2px solid var(--accent); }
.theme-tile .strip { display: flex; height: 26px; border-radius: 7px; overflow: hidden; border: 1px solid var(--line); }
.theme-tile .strip i { flex: 1; }
.theme-tile small { color: var(--soft); }
.swatches { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 14px; margin: 6px 0; }
.swatch-row { display: flex; gap: 8px; align-items: center; margin-top: 5px; }
.swatch-row input[type=color] { width: 44px; height: 38px; padding: 2px; margin: 0; cursor: pointer; flex: none; }
.swatch-row .hex { margin: 0; font-family: ui-monospace, monospace; text-transform: lowercase; }

/* ---------- lookups + tables ---------- */
.lk-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; margin-top: 12px; }
@media (max-width: 800px) { .lk-layout { grid-template-columns: 1fr; } }
.lk-nav { display: grid; gap: 2px; position: sticky; top: 72px; }
@media (max-width: 800px) { .lk-nav { grid-auto-flow: column; overflow-x: auto; position: static; } }
.lk-nav button { text-align: left; border: 0; background: transparent; padding: 8px 12px; border-radius: 8px; white-space: nowrap; color: var(--soft); }
.lk-nav button:hover { background: #fff; color: var(--ink); }
.lk-nav button.on { background: var(--accent); color: var(--accent-ink); }
.table-wrap { overflow-x: auto; }
.grid-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.grid-table th { text-align: left; padding: 8px; font-size: 12px; color: var(--soft); font-weight: 500; }
.grid-table td { padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
.grid-table td input[type=text], .grid-table td input[type=number], .grid-table td select { margin: 0; padding: 7px 9px; font-size: 13px; }
.grid-table td input[type=checkbox] { width: 18px; height: 18px; margin: 0; }
.grid-table .ro { color: var(--soft); font-size: 13px; }
.grid-table tr.new td { background: #fffbea; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions button { margin-left: 4px; }

/* ---------- dialogs ---------- */
label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 13px; }
label.check input { width: 18px; height: 18px; margin: 0; }
.brand-logo { height: 30px; width: auto; display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Chip Book: login + cards dashboard ---------- */
.chip { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: 0 1px 2px rgba(15,39,71,.05), 0 6px 14px -8px rgba(15,39,71,.16); }
.chip-body { padding: 18px 20px 20px; }

.login { min-height: calc(100vh - 62px); display: grid; place-items: center; padding: 32px 16px; }
.login-chip { width: min(400px, 100%); }
.chip-tab { display: flex; height: 10px; }
.chip-tab i { flex: 1; }
.chip-tab i:nth-child(1) { background: #2CC4A5; }
.chip-tab i:nth-child(2) { background: #3B6BFF; }
.chip-tab i:nth-child(3) { background: #7B5CF6; }
.login-chip .chip-body { padding: 32px 32px 34px; }
.login-logo { display: block; height: 44px; width: auto; margin: 0 0 26px; }
.login-chip h2 { font-size: 28px; letter-spacing: -.5px; }
.login-sub { margin: 6px 0 24px; font-size: 14px; }
.login-chip label { font-size: 13px; color: var(--ink); font-weight: 600; }
.login-chip input { padding: 12px 13px; font-weight: 400; }
.login-chip input:focus { outline-color: #2CC4A5; }
.login-chip button.primary { margin-top: 6px; padding: 12px 14px; min-height: 44px; }
.login-chip .error:empty { display: none; }
.login-chip .error { margin: 0 0 10px; }

.list-head { align-items: flex-end; margin-bottom: 4px; }
.list-head h2 { font-size: 28px; letter-spacing: -.6px; }
.list-head p { margin: 4px 0 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.list-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.list-tools .search { width: 300px; max-width: 100%; margin: 0; }

.cards-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; margin-top: 24px; }
.chip.card-tile { padding: 0; display: block; }
.chip-swatch { height: 64px; background: var(--line); position: relative; border-bottom: 1px solid rgba(15,39,71,.06); }
.chip-dot { position: absolute; right: 16px; bottom: -9px; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 3px solid var(--panel); box-sizing: content-box; }
.chip.card-tile .avatar { width: 48px; height: 48px; margin-top: -34px; border: 3px solid var(--panel); box-sizing: content-box; position: relative; }
.chip.card-tile .tile-head { align-items: flex-end; margin-bottom: 14px; }
.chip.card-tile .tile-head > div { padding-bottom: 2px; }
.chip.card-tile h4 { font-size: 17px; letter-spacing: -.2px; }
.chip.card-tile .tile-foot { padding-top: 14px; border-top: 1px solid var(--line); }
.chip.card-tile .muted { font-size: 12px; font-variant-numeric: tabular-nums; }
.chip.card-tile .actions { display: flex; gap: 6px; margin-left: auto; }
.badge.active { background: #E4F8F3; color: #12786a; }
.chip.card-tile:hover { box-shadow: 0 1px 2px rgba(15,39,71,.05), 0 14px 30px -14px rgba(15,39,71,.28); transform: translateY(-2px); }
@media (prefers-reduced-motion: reduce) { .chip.card-tile { transition: none; } .chip.card-tile:hover { transform: none; } }
@media (max-width: 640px) {
  .login { padding: 20px 12px; align-items: start; }
  .login-chip .chip-body { padding: 26px 22px 28px; }
  .list-tools { width: 100%; } .list-tools .search { width: 100%; flex: 1 1 100%; } .list-tools .primary { flex: 1; }
}
::selection { background: #3B6BFF; color: #fff; }
input { caret-color: #3B6BFF; }
.chip-swatch { display: flex; align-items: flex-end; gap: 10px; padding: 0 16px 10px; color: var(--ink); }
.chip-aa { font-size: 26px; line-height: 1; letter-spacing: -.5px; }
.chip-name { font-size: 12px; font-weight: 600; opacity: .8; padding-bottom: 2px; }

/* AA contrast for white text on the brand blue (#3B6BFF is 4.4:1) */
button.primary, button.primary:hover, .topnav button.on { background: #3360F2; border-color: #3360F2; }
.dirty { color: #7a4700; }

/* ---------- Chip Book: card data-entry form ---------- */
#editView.wrap { max-width: 1320px; }
.edit-layout { grid-template-columns: 184px minmax(0, 1fr) 320px; gap: 24px; margin-top: 18px; }
.edit-layout .secnav { position: sticky; top: 80px; z-index: 5; flex-direction: column; gap: 2px; overflow: visible; padding: 0; margin: 0; background: none; align-self: start; }
.edit-layout .secnav a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; font-size: 13.5px; font-weight: 500; color: var(--soft); border: 0; transition: background-color .15s ease-out, color .15s ease-out; }
.edit-layout .secnav a::before { content: ""; flex: none; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid #B6BCC8; background: transparent; transition: background-color .2s ease-out, border-color .2s ease-out; }
.edit-layout .secnav a.done::before { background: #2CC4A5; border-color: #2CC4A5; }
.edit-layout .secnav a:hover { background: #EEF2FF; color: var(--ink); }
.edit-layout .secnav a.on { background: var(--panel); color: var(--ink); font-weight: 700; box-shadow: 0 0 0 1px var(--line), 0 4px 10px -6px rgba(15,39,71,.2); }
.edit-layout .side { top: 80px; }

.sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 1px 2px rgba(15,39,71,.05), 0 6px 14px -8px rgba(15,39,71,.16); overflow: clip; }
.sheet::before { content: ""; display: block; height: 10px; background: linear-gradient(90deg, #2CC4A5 0 33.34%, #3B6BFF 33.34% 66.67%, #7B5CF6 66.67%); }
.sheet .panel { border: 0; border-radius: 0; box-shadow: none; margin: 0; padding: 26px 28px 22px; border-top: 1px solid var(--line); background: transparent; }
.sheet .panel:first-of-type { border-top: 0; }
.sheet .panel h3 { font-size: 17px; letter-spacing: -.2px; margin-bottom: 16px; }
.sheet .panel[id^="sec-"] { scroll-margin-top: 90px; }
.sheet label { color: var(--ink); font-weight: 600; font-size: 12.5px; }
.sheet label input, .sheet label select, .sheet label textarea { font-weight: 400; margin-top: 6px; }
.sheet .item input, .sheet .item select { margin: 0; }
.sheet .panel > button.ghost.small { margin-top: 4px; border-style: dashed; color: var(--soft); }
.sheet .panel > button.ghost.small:hover { color: var(--ink); border-color: var(--accent); background: #EEF2FF; }
.sheet .savebar { border-top: 1px solid var(--line); border-radius: 0; box-shadow: none; padding: 14px 28px; bottom: 0; }
.sheet .req { color: #c0392b; }

@media (max-width: 1100px) {
  .edit-layout { grid-template-columns: minmax(0, 1fr) 300px; }
  .edit-layout .secnav { grid-column: 1 / -1; position: sticky; top: 53px; flex-direction: row; gap: 6px; overflow-x: auto; padding: 10px 0; background: var(--bg); scrollbar-width: none; }
  .edit-layout .secnav a { flex: none; padding: 7px 12px; }
  .edit-layout .secnav a.on { box-shadow: none; background: var(--accent); color: #fff; }
  .edit-layout .side { top: 112px; }
}
@media (max-width: 960px) { .edit-layout { grid-template-columns: minmax(0, 1fr); } .edit-layout .side { position: static; } }
@media (max-width: 640px) { .sheet .panel { padding: 22px 18px 18px; } .sheet .savebar { padding: 12px 16px; } .edit-layout .secnav { top: 49px; } }
@media (prefers-reduced-motion: reduce) { .edit-layout .secnav a, .edit-layout .secnav a::before { transition: none; } }

/* ---------- Chip Book: navbar + account menu ---------- */
.bar { padding: 10px 24px; gap: 20px; box-shadow: 0 1px 0 var(--line); border-bottom: 0; }
.topnav { position: relative; display: flex; gap: 2px; margin-left: 4px; padding: 4px; background: #F1F3F7; border-radius: 999px; }
.topnav button { position: relative; z-index: 1; gap: 8px; border: 0; background: transparent; padding: 7px 15px; border-radius: 999px; color: var(--soft); font-weight: 600; font-size: 13.5px; transition: color .18s ease-out; }
.topnav button svg { flex: none; }
.topnav button:hover { background: transparent; color: var(--ink); }
.topnav button.on, .topnav button.on:hover { background: transparent; border-color: transparent; color: #fff; }
.nav-pill { position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 0; width: 0; border-radius: 999px; background: #3360F2; box-shadow: 0 4px 10px -4px rgba(51,96,242,.55); }
.nav-pill.ready { transition: transform .26s cubic-bezier(.23,1,.32,1); }

.bar-right { position: relative; }
.acct { gap: 9px; padding: 4px 10px 4px 4px; border-radius: 999px; background: transparent; border-color: var(--line); font-weight: 600; font-size: 13.5px; transition: background-color .15s ease-out, border-color .15s ease-out, transform .12s ease-out; }
.acct:hover { background: #EEF2FF; }
.acct:active { transform: scale(.97); }
.acct-av { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #2CC4A5, #3B6BFF 60%, #7B5CF6); color: #fff; font-size: 13px; font-weight: 700; }
.acct #who { margin: 0; color: var(--ink); }
.acct-chev { color: var(--soft); transition: transform .2s cubic-bezier(.23,1,.32,1); }
.acct[aria-expanded="true"] .acct-chev { transform: rotate(180deg); }
.acct-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 2px 4px rgba(15,39,71,.05), 0 10px 18px -8px rgba(15,39,71,.28); transform-origin: top right; animation: acct-in .16s cubic-bezier(.23,1,.32,1); z-index: 30; }
@keyframes acct-in { from { opacity: 0; transform: scale(.96) translateY(-4px); } }
.acct-head { display: grid; gap: 1px; padding: 10px 12px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.acct-head strong { font-size: 14px; }
.acct-head span { font-size: 12px; color: var(--soft); }
.acct-menu button { width: 100%; justify-content: flex-start; border: 0; background: transparent; padding: 9px 12px; border-radius: 9px; font-size: 13.5px; }
.acct-menu button:hover, .acct-menu button:focus-visible { background: #EEF2FF; }
.acct-menu button.out { color: #b3322a; }
.acct-menu button.out:hover { background: #FDEDEC; }
@media (prefers-reduced-motion: reduce) { .nav-pill.ready, .acct-chev, .topnav button { transition: none; } .acct-menu { animation: none; } }

@media (max-width: 640px) {
  .bar { padding: 10px 14px; gap: 10px; flex-wrap: nowrap; }
  .acct #who, .acct-chev { display: none; }
  .acct { padding: 3px; }
  .topnav { position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 25; margin: 0; width: auto; order: 0; justify-content: space-between; padding: 6px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 8px 16px -8px rgba(15,39,71,.35); overflow: visible; }
  .topnav button { flex: 1; flex-direction: column; gap: 3px; padding: 7px 4px; min-height: 52px; font-size: 11.5px; border-radius: 16px; }
  .topnav button.on, .topnav button.on:hover { color: #3360F2; background: #EEF2FF; }
  .nav-pill { display: none; }
  body:has(#topNav:not([hidden])) { padding-bottom: 84px; }
  .toast { bottom: 96px; }
}

body { min-height: 100vh; display: flex; flex-direction: column; }
body > main { width: 100%; }
.login { flex: 1; min-height: 0; }
.foot { margin-top: auto; padding: 14px 16px; border-top: 1px solid var(--line); text-align: center; font-size: 11.5px; color: var(--soft); }
body > .foot { background: var(--bg); }

/* show-on-card controls */
.hint-line { margin: -8px 0 16px; font-size: 13px; }
.display-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.display-opt { margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-weight: 500; cursor: pointer; transition: background-color .15s ease-out, border-color .15s ease-out; }
.display-opt:hover { background: #EEF2FF; }
.display-opt:has(input:checked) { border-color: #2CC4A5; background: #F0FBF8; }
.display-opt input { accent-color: #1f9d83; }
button.eye { color: #1f9d83; }
button.eye[aria-pressed="false"] { color: var(--soft); }
.item.is-hidden > input, .item.is-hidden > select, .item.is-hidden > .wide { opacity: .5; }
.item.is-hidden { background: #F3F4F7; }
.display-opt input { flex: none; width: 18px; height: 18px; }
.edit-layout .secnav a[data-sec="display"]::before { display: none; }

/* share image panel */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: #F1F3F7; border-radius: 999px; margin-bottom: 12px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 6px 16px; font-size: 13px; font-weight: 600; color: var(--soft); transition: background-color .15s ease-out, color .15s ease-out; }
.seg button:hover { background: transparent; color: var(--ink); }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(15,39,71,.15); }
.share-frame { border: 1px solid var(--line); border-radius: 12px; background: var(--bg); padding: 8px; display: grid; place-items: center; margin-bottom: 10px; }
.share-frame img { width: 100%; height: auto; display: block; border-radius: 8px; }
.share-frame[data-fmt="story"] img { max-width: 190px; }
.uniq { margin: -4px 0 14px; font-size: 13px; color: var(--soft); }
.uniq strong { color: var(--ink); font-size: 15px; font-variant-numeric: tabular-nums; }
