/* Reusable pieces: buttons, cards, inputs, chips, dropdowns, modal, toast */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2);
  border-radius: var(--r-sm); font-weight: 600; font-size: 13.5px; white-space: nowrap;
  text-transform: uppercase; letter-spacing: var(--caps);
}
.btn:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-hover); color: var(--brand-ink); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--brand); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 12px; }
.btn svg { width: 16px; height: 16px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.link-caps { color: var(--brand); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: var(--caps); background: none; border: 0; padding: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 26px 28px; box-shadow: var(--shadow); }
.card + .card { margin-top: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head .sub { color: var(--ink-3); font-size: 13.5px; margin-top: 2px; }
.caps { text-transform: uppercase; letter-spacing: var(--caps); font-size: 15px; font-weight: 700; }
@media (max-width: 760px) { .card { padding: 16px; border-radius: var(--r); } }
.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.input, .textarea {
  width: 100%; border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-sm);
  padding: 9px 12px; outline: none;
}
.input:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--brand-soft); }
.textarea { font-family: var(--mono); font-size: 14.5px; line-height: 1.55; resize: vertical; min-height: 92px; }
.search-input { position: relative; }
.search-input svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); pointer-events: none; }
.search-input .input { padding-left: 34px; height: 40px; }
.kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--ink-3); }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); font-size: 13px; white-space: nowrap;
}
.chip:hover, .chip.on { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }

/* Dropdown list (autocomplete) */
.dropdown {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-pop);
  max-height: 340px; overflow-y: auto; padding: 4px;
}
.dropdown button {
  display: flex; width: 100%; text-align: left; gap: 10px; align-items: baseline; justify-content: space-between;
  border: 0; background: none; padding: 9px 10px; border-radius: var(--r-sm); min-height: 40px;
}
.dropdown button.active, .dropdown button:hover { background: var(--surface-2); }
.dropdown .dd-main { font-weight: 500; }
.dropdown .dd-sub { color: var(--ink-3); font-size: 12.5px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); width: min(560px, 100%); max-height: 86vh; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 760px) {
  .modal-back { place-items: end stretch; padding: 0; }
  .modal { width: 100%; border-radius: var(--r-lg) var(--r-lg) 0 0; padding-bottom: env(safe-area-inset-bottom); }
}

/* Toast */
#toast-root { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 70; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow-pop); }
@media (max-width: 760px) { #toast-root { bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); } }

/* Query box */
.query-wrap { position: relative; }
.query-error { color: var(--down); font-size: 13.5px; margin-top: 6px; }
.query-help { font-size: 13px; color: var(--ink-3); margin-top: 6px; }

/* Screen cards */
.screen-card { display: block; color: inherit; }
.screen-card:hover { text-decoration: none; border-color: var(--line-strong); }
.screen-card h3 { margin-bottom: 4px; }
.screen-card p { color: var(--ink-2); font-size: 13.5px; margin-bottom: 8px; }
.screen-card code { display: block; color: var(--ink-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.empty { text-align: center; padding: 40px 16px; color: var(--ink-3); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.check-list label { display: flex; align-items: center; gap: 8px; padding: 6px 0; min-height: 36px; }
.check-group + .check-group { margin-top: 12px; }
.check-group h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-bottom: 2px; }
.grid > .card, .two-col > .card { margin-top: 0; }

/* Home hero */
.hero { text-align: center; padding: 48px 0 44px; }
.hero-brand { display: inline-flex; align-items: center; gap: 14px; font-size: 52px; font-weight: 700; letter-spacing: -0.04em; }
.hero-brand svg { width: 60px; height: 60px; }
.hero-sub { color: var(--ink-2); font-size: 18px; margin: 12px auto 26px; max-width: 640px; }
.hero-search { max-width: 640px; margin: 0 auto; }
.hero-search .input { height: 54px; font-size: 17px; padding-left: 44px; border-radius: var(--r); box-shadow: var(--shadow); }
.hero-search svg { left: 16px; width: 18px; height: 18px; }
.hero-quick { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.hero-quick .chip { display: inline-flex; align-items: center; text-decoration: none; }
@media (max-width: 760px) { .hero { padding: 24px 0 28px; } .hero-brand { font-size: 36px; } .hero-brand svg { width: 42px; height: 42px; } .hero-sub { font-size: 15px; } }

/* Manage quick ratios */
.qr h1 { font-size: 34px; font-weight: 600; }
.qr-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.qr-chip { display: inline-flex; align-items: center; gap: 10px; padding: 10px 14px 10px 18px; border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); background: var(--surface-2); font-size: 16px; cursor: grab; user-select: none; }
.qr-chip button { border: 0; background: none; color: var(--ink-3); font-size: 18px; line-height: 1; padding: 0 2px; }
.qr-chip button:hover { color: var(--down); }
.qr-filter { display: flex; gap: 40px; align-items: flex-end; flex-wrap: wrap; margin: 24px -28px 0; padding: 22px 28px;
  background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.qr-filter h3 { margin-bottom: 10px; }
.qr-filter .input { width: 300px; height: 46px; }
.qr-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 28px; padding-top: 22px; }
.qr-list label { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; padding: 8px 0; font-size: 16px; }
.qr-list label .small { grid-column: 2; font-size: 12.5px; }
.qr-list input { width: 18px; height: 18px; accent-color: var(--brand); }
@media (max-width: 900px) { .qr-list { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) { .qr-list { grid-template-columns: 1fr; } .qr-filter { margin: 20px -16px 0; padding: 16px; gap: 14px; } .qr-filter .input { width: 100%; } .qr h1 { font-size: 26px; } }
.qr-chip button.mv { color: var(--brand); font-size: 20px; padding-right: 0; }
