:root {
  --green: #ad886b;
  --green-dark: #493223;
  --green-light: #f6eadf;
  --accent: #cfa989;
  --accent-dark: #b78c69;
  --danger: #c0392b;
  --warn: #d68910;
  --bg: #fbf5ec;
  --card: #fffefa;
  --text: #251b14;
  --muted: #746357;
  --border: #dfcdbb;
  --shadow: 0 2px 12px rgba(96, 67, 41, 0.12);
  --radius: 14px;
  --nav-h: 58px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--green); }
button, input, select, textarea { font: inherit; }

.app-header {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: #fff;
  padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
.app-header h1 {
  margin: 0; font-size: 1.05rem; font-weight: 700;
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-header .badge {
  background: rgba(255,255,255,.2);
  padding: 2px 8px; border-radius: 999px; font-size: .75rem;
}

.nav {
  position: sticky; top: var(--nav-h); z-index: 40;
  display: flex; gap: 4px; overflow-x: auto;
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav button {
  flex: 0 0 auto;
  border: none; background: transparent;
  padding: 8px 12px; border-radius: 999px;
  color: var(--muted); cursor: pointer; white-space: nowrap;
  font-weight: 600; font-size: .9rem;
}
.nav button.active {
  background: var(--green-light); color: var(--green);
}

.main {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 12px calc(24px + var(--safe-bottom));
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}
.card h2 {
  margin: 0 0 10px; font-size: 1.05rem; color: var(--green-dark);
}
.card h3 { margin: 12px 0 8px; font-size: .95rem; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 auto; }
.stack { display: flex; flex-direction: column; gap: 8px; }

label.field {
  display: flex; flex-direction: column; gap: 4px;
  font-size: .85rem; color: var(--muted); font-weight: 600;
}
input[type=text], input[type=search], input[type=number], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(173,136,107,.18);
}
.scan-input {
  font-size: 1.25rem !important;
  font-weight: 700;
  letter-spacing: .05em;
  text-align: center;
  padding: 14px !important;
  border-color: var(--green) !important;
  background: var(--green-light) !important;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700; cursor: pointer;
  background: var(--green); color: #fff;
  transition: transform .05s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary { background: #f6eadf; color: var(--green-dark); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warn { background: var(--warn); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: .85rem; border-radius: 8px; }
.btn-block { width: 100%; }

.mode-toggle {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.mode-toggle .btn {
  padding: 12px; font-size: 1rem;
  background: #f6eadf; color: var(--muted);
}
.mode-toggle .btn.active-borrow {
  background: var(--green); color: #fff;
}
.mode-toggle .btn.active-return {
  background: var(--accent); color: #fff;
}

.book-card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  align-items: start;
}
.book-cover {
  width: 96px; height: 128px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--green-light);
  border: 1px solid var(--border);
}
.book-cover.placeholder {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: .75rem; text-align: center; padding: 8px;
}
.book-meta { min-width: 0; }
.book-meta .title {
  font-size: 1.15rem; font-weight: 800; margin: 0 0 4px;
  word-break: break-word;
}
.book-meta .sub { color: var(--muted); font-size: .9rem; margin: 2px 0; }
.pill {
  display: inline-block;
  padding: 2px 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 700;
}
.pill-available { background: #d4edda; color: #155724; }
.pill-borrowed { background: #ffe8cc; color: #9a5b00; }
.pill-missing { background: #f8d7da; color: #721c24; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 100;
  max-width: min(92vw, 420px);
  padding: 12px 16px;
  border-radius: 12px;
  background: #1f2937; color: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: var(--green); }
.toast.err { background: var(--danger); }

.hidden { display: none !important; }
.empty {
  text-align: center; color: var(--muted); padding: 28px 12px;
}

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
  width: 100%; border-collapse: collapse; font-size: .9rem;
}
th, td {
  text-align: left; padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th { color: var(--muted); font-weight: 700; font-size: .8rem; white-space: nowrap; }
tr:hover td { background: #fbf5ee; }
tr.clickable { cursor: pointer; }

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
@media (min-width: 640px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
  .book-card { grid-template-columns: 120px 1fr; }
  .book-cover { width: 120px; height: 160px; }
}
.stat {
  background: var(--green-light);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}
.stat .n { font-size: 1.4rem; font-weight: 800; color: var(--green-dark); }
.stat .l { font-size: .8rem; color: var(--muted); }

.list-item {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .actions { display: flex; gap: 6px; flex-shrink: 0; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 80; display: flex; align-items: flex-end; justify-content: center;
  padding: 12px;
}
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
}
.modal {
  background: #fff; border-radius: 16px;
  width: min(100%, 520px);
  max-height: 90vh; overflow: auto;
  padding: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,.25);
}
.modal h3 { margin: 0 0 12px; }

.catalog-entry { display: grid; grid-template-columns: 130px 1fr; gap: 14px; }
.catalog-photo { width: 100%; max-height: 220px; object-fit: contain; background: var(--green-light); border-radius: 10px; }
.catalog-fields { min-width: 0; }
.catalog-lines { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.catalog-lines button { text-align: left; max-width: 100%; overflow-wrap: anywhere; }
.catalog-review { display: flex; gap: 8px; align-items: flex-start; padding: 12px 0; font-weight: 700; }
.catalog-state { white-space: pre-wrap; overflow-wrap: anywhere; margin: 4px 0 10px; }
@media (max-width: 520px) {
  .catalog-entry { grid-template-columns: 1fr; }
  .catalog-photo { height: 170px; }
}

.teacher-pick {
  display: grid; gap: 6px;
  max-height: 240px; overflow: auto;
}
.teacher-pick button {
  text-align: left;
  border: 1.5px solid var(--border);
  background: #fff; border-radius: 10px;
  padding: 10px 12px; cursor: pointer;
}
.teacher-pick button.selected {
  border-color: var(--green);
  background: var(--green-light);
}
.teacher-pick .loans {
  float: right; color: var(--muted); font-size: .85rem;
}

.progress-bar {
  height: 10px; background: #eee0d1; border-radius: 999px; overflow: hidden;
}
.progress-bar > span {
  display: block; height: 100%; background: var(--green); width: 0%;
  transition: width .2s;
}

.file-btn {
  position: relative; overflow: hidden;
}
.file-btn input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}

.tabs-inline {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px;
}
.tabs-inline button {
  border: 1px solid var(--border); background: #fff;
  border-radius: 999px; padding: 6px 12px; cursor: pointer;
  font-weight: 600; color: var(--muted);
}
.tabs-inline button.active {
  background: var(--green); color: #fff; border-color: var(--green);
}

.author-group { margin-bottom: 14px; }
.author-group h3 {
  background: var(--green-light);
  margin: 0 0 6px; padding: 8px 10px; border-radius: 8px;
}

.muted { color: var(--muted); }
.danger-text { color: var(--danger); font-weight: 700; }
.ok-text { color: var(--green); font-weight: 700; }

/* Camera scan */
.scan-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.scan-row .scan-input,
.scan-row input[type=search],
.scan-row input[type=text] {
  flex: 1 1 auto;
  min-width: 0;
}
.btn-camera {
  flex: 0 0 auto;
  background: #ad8b72;
  color: #fff;
  white-space: nowrap;
  padding: 10px 12px;
  align-self: stretch;
}
.btn-camera.btn-sm { padding: 8px 10px; font-size: .85rem; }
.btn-camera:disabled { opacity: .55; }

.camera-modal {
  width: min(100%, 560px);
}
.camera-reader {
  width: 100%;
  min-height: 240px;
  border-radius: 12px;
  overflow: hidden;
  background: #111;
  border: 1px solid var(--border);
}
.camera-reader video {
  width: 100% !important;
  border-radius: 12px;
}
.camera-reader img { max-width: 100%; }
#cameraStatus.err { color: var(--danger); font-weight: 700; }
#cameraStatus.ok { color: var(--green); font-weight: 700; }

@media (max-width: 480px) {
  .scan-row { flex-wrap: wrap; }
  .btn-camera { width: 100%; }
}


/* Warm paper palette and illustrated library dashboard. */
@font-face { font-family: LibrarySerif; src: url("../fonts/library-serif.woff2") format("woff2"); font-weight: 400 600; font-display: swap; }
@font-face { font-family: LibrarySerif; src: url("../fonts/library-serif-bold.woff2") format("woff2"); font-weight: 700 900; font-display: swap; }
:root { --radius: 16px; --nav-h: 70px; --shadow: 0 5px 9px rgba(93, 66, 44, .13), 0 1px 2px rgba(93, 66, 44, .05); }
html { background: #fbf5ec; }
body { min-height: 100svh; background: #fbf5ec url("../img/paper-garden.svg") center / 100% 100% no-repeat; font-family: LibrarySerif, "Songti TC", "Noto Serif CJK TC", "PMingLiU", serif; }
.icon-definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
.app-header { min-height: var(--nav-h); padding: 16px max(15px, calc((100% - 930px) / 2)); gap: 10px; background: linear-gradient(110deg, #f8e8d6e8, #efd9bfe8), url("../img/paper-garden.svg") top right / cover; color: var(--text); box-shadow: none; border-bottom: 1px solid #f5e5d5; }
.app-header h1 { display: flex; align-items: center; gap: 7px; font-size: clamp(16px, 4.7vw, 29px); font-weight: 800; letter-spacing: -.04em; overflow: visible; }
.app-header h1 span { white-space: nowrap; }
.brand-icon { width: 23px; height: 29px; color: #b28d68; flex-shrink: 0; }
.app-header .badge { flex-shrink: 0; white-space: nowrap; font-family: "PingFang TC", "Microsoft JhengHei", sans-serif; font-size: clamp(10px, 2.6vw, 14px); padding: 5px 9px; border: 1px solid #dbc2a9; background: #fff5e780; box-shadow: inset 0 1px 1px #fff8; color: #302218; }
.nav { padding: 16px max(10px, calc((100% - 940px) / 2)) 11px; gap: 8px; background: #fbf5ecf5; border-bottom: none; }
.nav button { color: #21180f; padding: 9px 13px; font-size: 16px; font-weight: 700; border: 1px solid transparent; }
.nav button.active { color: #21180f; background: #f6e8d7; border-color: #dec5ab; box-shadow: inset 0 0 0 1px #fff5; }
.main { padding: 4px 15px calc(36px + var(--safe-bottom)); }
.card { padding: 16px 14px; margin-bottom: 16px; background: #fffefaed; border-color: #dfd0c1; }
.card h2 { color: #251a11; font-size: 22px; font-weight: 700; margin-bottom: 12px; }
.card h3 { color: #342317; }
label.field { color: #33251a; font-size: 15px; }
input[type=text], input[type=search], input[type=number], select, textarea { background: #fffaf4; color: var(--text); border-color: #d7c1aa; }
input::placeholder, textarea::placeholder { color: #7d6b59; opacity: 1; }
input:focus-visible, button:focus-visible, a:focus-visible, select:focus-visible { outline: 2px solid #78543b; outline-offset: 3px; }
.btn { border-radius: 10px; min-height: 44px; background: #a27c5f; box-shadow: inset 0 0 0 1px #92705633; }
.btn-secondary { background: #f4e7da; color: #493223; }
.btn-accent { background: #b58a68; }
.btn-danger { background: var(--danger); }
.btn-warn { background: #a37b3d; }
.btn-sm { min-height: 36px; }
.mode-toggle { gap: 8px; }
.mode-toggle .btn { min-height: 48px; font-size: 20px; color: #24180f; background: #f6eadf; }
.mode-toggle .btn.active-borrow, .mode-toggle .btn.active-return { background: #cba685; color: #fff; }
#view-scan > .card:first-child { padding: 15px 14px 17px; }
#view-scan > .card:first-child > div[style] { height: 13px !important; }
#view-scan > .card:first-child .scan-row { flex-direction: column; gap: 11px; margin-top: 3px; }
#scanInput { min-height: 63px; font-size: 22px !important; letter-spacing: .02em; border: 1px solid #bda084 !important; background: #faf1e8 !important; box-shadow: inset 0 0 0 3px #fff7ed, 0 2px 4px #b99c7c30; font-weight: 600; }
#scanInput::placeholder { color: #38281b; }
.btn-camera { background: #ad8b72; color: #fff; gap: 8px; }
#scanCamBtn { width: 100%; min-height: 47px; font-size: 20px; }
.barcode-icon { width: 25px; height: 23px; flex-shrink: 0; }
#view-scan > .card:first-child p.muted { color: #34251a; line-height: 1.65; font-size: 14px !important; margin-top: 8px !important; }
code { font-family: inherit; }
.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { display: grid; grid-template-columns: 44% 56%; grid-template-rows: auto auto; align-items: center; min-height: 81px; padding: 10px 9px; text-align: center; background: #fcf5ed; border: 1px solid #d2bca5; box-shadow: inset 0 0 0 2px #fffaf1, 0 2px 3px #ac8a6720; border-radius: 11px; }
.stat-icon { grid-row: 1 / 3; width: 48px; height: 53px; max-width: 100%; justify-self: center; color: #8e9982; }
.stat:nth-child(even) .stat-icon { color: #b3837c; }
.stat .n { color: #261b13; font-size: 31px; font-weight: 600; line-height: 1.1; }
.stat .l { color: #261b13; font-size: 15px; margin-top: 4px; }
.pill-available { background: #e9eddf; color: #4e6041; }
.pill-borrowed { background: #f4e2d2; color: #805333; }
.modal { background: #fffaf2; border: 1px solid #d7bfa6; font-family: inherit; }
.teacher-pick button, .tabs-inline button { background: #fffaf4; color: #493223; }
.toast { background: #493223; }
.toast.ok { background: #78583e; }
input[type=checkbox] { accent-color: #967354; }
@media (max-width: 359px) {
  .app-header { padding: 13px 10px; gap: 5px; }
  .app-header h1 { font-size: 16px; gap: 4px; }
  .app-header .badge { padding: 4px 6px; font-size: 9px; }
  .brand-icon { width: 20px; }
  .main { padding-left: 10px; padding-right: 10px; }
  .stat { padding: 10px 6px; }
  .stat .n { font-size: 27px; }
}
@media (min-width: 640px) {
  :root { --nav-h: 96px; }
  .app-header { padding-top: 24px; padding-bottom: 24px; }
  .brand-icon { width: 36px; height: 44px; }
  .app-header .badge { font-size: 17px; padding: 7px 14px; }
  .nav { gap: 12px; padding-top: 20px; padding-bottom: 20px; }
  .nav button { font-size: 19px; padding: 11px 18px; }
  .main { padding-left: 25px; padding-right: 25px; }
  .card { padding: 24px; margin-bottom: 24px; border-radius: 20px; }
  #view-scan > .card:first-child { padding: 25px; }
  .mode-toggle { gap: 14px; }
  .mode-toggle .btn { min-height: 68px; font-size: 26px; }
  label.field { font-size: 18px; }
  #scanInput { min-height: 86px; font-size: 29px !important; }
  #scanCamBtn { min-height: 65px; font-size: 26px; }
  #view-scan > .card:first-child p.muted { font-size: 18px !important; }
  .card h2 { font-size: 28px; }
  .stats { gap: 16px; }
  .stat { min-height: 127px; }
  .stat-icon { width: 69px; height: 77px; }
  .stat .n { font-size: 43px; }
  .stat .l { font-size: 21px; }
}
@media (min-width: 1000px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat { grid-template-columns: 38% 62%; }
  .stat-icon { width: 57px; }
}
/* Keep the reference composition on phones and portrait tablets. */
.app-header h1 { font-size: clamp(16px, 5.1vw, 38px); }
.nav { padding-top: 10px; padding-bottom: 7px; }
#scanInput:focus-visible { outline: none; }
@media (min-width: 640px) and (max-width: 999px) {
  :root { --nav-h: 125px; }
  .app-header { padding-left: 28px; padding-right: 24px; }
  .app-header h1 { font-size: clamp(28px, 5.1vw, 40px); }
  .app-header .badge { font-size: 18px; }
  .nav { padding: 31px 18px 27px; gap: 12px; }
  .nav button { font-size: 24px; padding: 12px 20px; }
  .main { padding: 0 28px 50px; }
  .card { border-radius: 22px; padding: 26px; margin-bottom: 28px; }
  #view-scan > .card:first-child { padding: 28px 26px 30px; }
  .mode-toggle .btn { min-height: 87px; font-size: 31px; }
  #view-scan > .card:first-child > div[style] { height: 23px !important; }
  label.field { font-size: 23px; line-height: 1.4; }
  #view-scan > .card:first-child .scan-row { margin-top: 8px; gap: 19px; }
  #scanInput { min-height: 114px; font-size: 35px !important; border-radius: 16px; }
  #scanCamBtn { min-height: 84px; font-size: 32px; border-radius: 15px; }
  #scanCamBtn .barcode-icon { width: 36px; height: 32px; }
  #view-scan > .card:first-child p.muted { font-size: 23px !important; line-height: 1.55; margin-top: 14px !important; }
  .card h2 { font-size: 34px; margin-bottom: 15px; }
  .stats { gap: 17px 20px; }
  .stat { min-height: 143px; border-radius: 16px; }
  .stat-icon { width: 77px; height: 85px; }
  .stat .n { font-size: 49px; }
  .stat .l { font-size: 23px; }
}


/* Form fields need their own columns; content-sized flex items squeezed names. */
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: end; }
.form-row > * { min-width: 0; }
.form-row label.field { gap: 6px; }
#view-teachers .form-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
#view-books .form-row { grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr)); }
#view-categories .form-row, #invIdle .form-row { grid-template-columns: minmax(0, 1fr) auto; }
@media (max-width: 639px) {
  .form-row,
  #view-teachers .form-row,
  #view-books .form-row,
  #view-categories .form-row,
  #invIdle .form-row { grid-template-columns: minmax(0, 1fr); }
  .form-row > .btn { width: 100%; }
}

/* Five illustrated tabs and the grouped disclosure match the new reference. */
@font-face { font-family: LibrarySans; src: url("../fonts/library-sans.woff2") format("woff2"); font-weight: 400 600; font-display: swap; }
@font-face { font-family: LibrarySans; src: url("../fonts/library-sans-bold.woff2") format("woff2"); font-weight: 700 900; font-display: swap; }
[hidden] { display: none !important; }
body { font-family: LibrarySans, "PingFang TC", "Microsoft JhengHei", sans-serif; }
.app-header h1, .card h2, .stat .n { font-family: LibrarySerif, "Songti TC", "PMingLiU", serif; }
.app-header h1 { font-size: clamp(16px, 5.64vw, 41px); letter-spacing: 0; }
.app-header .badge { font-family: inherit; }
.nav { display: block; overflow: visible; padding: 12px 12px 8px; background: #fcf1e7f5; box-shadow: 0 3px 5px #6b4b2920; z-index: 72; }
.primary-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; max-width: 930px; margin: 0 auto; }
.nav .nav-item { min-width: 0; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 7px 2px; border-radius: 16px; min-height: 62px; font: 600 clamp(11px, 3.3vw, 16px)/1.4 LibrarySans, sans-serif; color: #17120d; white-space: nowrap; }
.nav .nav-item.active { background: linear-gradient(135deg, #f4dfcc, #f7e7d6); border: 1px solid #ddc3aa; box-shadow: inset 0 0 0 1px #fff6; }
.nav-icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-people { width: 31px; }
.more-arrow { display: inline-block; font-size: .8em; margin-left: 2px; }
.more-menu { position: absolute; right: max(12px, calc((100% - 930px) / 2)); top: calc(100% - 7px); width: 194px; padding: 17px 17px 12px; border: 1px solid #cdbdad; border-radius: 13px; background: #fff6ec url("../img/menu-paper.svg") center / cover; box-shadow: 0 5px 8px #281a1430; max-height: calc(100dvh - var(--nav-bottom, 160px) - 6px); overflow-y: auto; overscroll-behavior: contain; }
.more-menu h2 { margin: 0 0 6px; font-size: 16px; line-height: 1.4; font-weight: 600; color: #18130f; }
.more-menu .more-group + .more-group { border-top: 1px solid #d9cbbb; padding-top: 16px; margin-top: 12px; }
.more-menu button { width: 100%; display: flex; gap: 10px; align-items: center; padding: 8px 2px; min-height: 44px; border: 1px solid transparent; border-radius: 6px; font-size: 17px; line-height: 1.4; text-align: left; color: #17120d; }
.more-menu button .nav-icon { width: 24px; height: 26px; }
.more-menu button:hover, .more-menu button.active { background: #eedcc7; color: #17120d; }
.more-backdrop { position: fixed; inset: var(--nav-bottom, 160px) 0 0; background: rgba(41, 30, 21, .40); z-index: 65; }
body.more-open { overflow: hidden; }
.main { padding-top: 10px; }
@media (max-width: 359px) {
  .app-header h1 { font-size: 16px; letter-spacing: -.02em; }
  .nav { padding-left: 8px; padding-right: 8px; }
  .nav .nav-item { font-size: 11px; }
}
@media (min-width: 640px) and (max-width: 999px) {
  .app-header h1 { font-size: clamp(33px, 5.7vw, 41px); }
  .app-header .badge { width: 193px; font-size: 20px; padding: 8px 10px; text-align: center; }
  .nav { padding: 24px 24px 16px; }
  .primary-nav { gap: 4px; }
  .nav .nav-item { min-height: 103px; border-radius: 27px; padding: 10px 2px; gap: 10px; font-size: 24px; }
  .nav .nav-icon { width: 40px; height: 40px; }
  .nav .nav-people { width: 54px; }
  .main { padding-top: 17px; }
  .more-menu { right: 18px; top: calc(100% - 12px); width: 195px; padding: 21px 19px 16px; border-radius: 17px; }
  .more-menu h2 { font-size: 22px; margin-bottom: 11px; }
  .more-menu button { min-height: 56px; gap: 12px; padding: 9px 3px; font-size: 24px; }
  .more-menu button .nav-icon { width: 31px; height: 33px; }
  .more-menu .more-group + .more-group { margin-top: 15px; padding-top: 22px; }
}
@media (min-width: 1000px) {
  .nav { padding: 14px 20px; }
  .nav .nav-item { min-height: 77px; font-size: 18px; border-radius: 20px; }
  .nav .nav-icon { width: 31px; height: 31px; }
  .nav .nav-people { width: 39px; }
  .more-menu { width: 218px; }
  .main { padding-top: 18px; }
}
.app-header h1 { font-size: clamp(16px, calc(8.7vw - 12px), 41px); }
.stat .n { font-weight: 700; }
.more-menu h2 { font-weight: 700; }
@media (max-width: 359px) { .app-header h1 { font-size: 16px; } }
@media (min-width: 640px) and (max-width: 999px) {
  .app-header h1 { font-size: clamp(30px, calc(10vw - 30px), 41px); }
  .nav .nav-item { line-height: 1.3; }
  .more-menu { padding-top: 20px; }
  .more-menu h2 { line-height: 1.3; }
  .more-menu .more-group + .more-group { padding-top: 18px; }
}


/* A visible submit action also works with phone number keyboards without Enter. */
.scan-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; min-width: 0; }
#scanLookupBtn { padding: 10px 14px; min-width: 62px; font-size: 17px; }
.scan-feedback { margin: 10px 0 0; color: #493223; font-size: 14px; overflow-wrap: anywhere; }
.scan-feedback.danger-text { color: var(--danger); }
@media (max-width: 359px) { #scanInput { font-size: 18px !important; } #scanLookupBtn { min-width: 56px; padding: 10px; } }
@media (min-width: 640px) { #scanLookupBtn { font-size: 23px; min-width: 87px; } .scan-feedback { font-size: 18px; } }
