/* TradeFlow CRM. A call book first: white page, borders for structure, no gradients. */

:root {
    --bg: #FFFFFF;
    --bg-soft: #F6F7F8;
    --surface: #FFFFFF;
    --surface-hover: #F6F7F8;
    --surface-raised: #EEF0F2;
    --border: #E5E8EB;
    --border-light: #D3D8DE;
    --text: #17202B;
    --text-muted: #55606D;
    --text-dim: #7C8693;
    --accent: #047857;
    --accent-strong: #03633F;
    --accent-dim: #E8F4F0;
    --red: #C42B1C;
    --red-dim: #FBECEA;
    --yellow: #A04A06;
    --yellow-dim: #FBF1E6;
    --blue: #1D5FD1;
    --blue-dim: #EBF1FB;
    --font: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 8px 30px rgba(23,32,43,0.14);
    --sidebar-w: 212px;
    --record-w: 480px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; }
body {
    background: var(--bg); color: var(--text);
    font-family: var(--font); line-height: 1.5; min-height: 100vh;
    -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
    -webkit-text-size-adjust: 100%; overflow-x: hidden;
    font-variant-numeric: tabular-nums;
}
button { font-family: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
ol { list-style: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD2DA; border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }

@keyframes spin { to { transform: rotate(360deg) } }
.spin { animation: spin 1s linear infinite; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w); flex-shrink: 0; background: var(--bg);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 40;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; }
.brand-icon {
    width: 30px; height: 30px; border-radius: var(--radius-sm); background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px; color: #FFFFFF;
}
.brand-name { font-weight: 600; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 12px; color: var(--text-dim); line-height: 1.2; }

.sidebar-nav { padding: 6px 8px; flex: 1; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 10px; border-radius: var(--radius-sm); font-size: 14px;
    color: var(--text-muted); margin-bottom: 1px;
    background: none; border: none; cursor: pointer; text-align: left;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent-strong); font-weight: 500; }
.nav-count { margin-left: auto; font-size: 12px; color: var(--text-dim); }
.sidebar-footer {
    display: block; width: 100%; text-align: left; padding: 12px 16px; cursor: pointer;
    background: none; border: none; border-top: 1px solid var(--border);
}
.sidebar-footer:hover { background: var(--surface-hover); }
.sidebar-status { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status-on { background: var(--accent); }
.status-off { background: var(--text-dim); }
.status-bad { background: var(--red); }
.sidebar-status-sub { font-size: 12px; color: var(--text-dim); margin-top: 1px; padding-left: 14px; }
.logout-btn {
    display: flex; align-items: center; gap: 9px; width: 100%; padding: 10px 16px;
    font-size: 13px; color: var(--text-dim);
    background: none; border: none; border-top: 1px solid var(--border); cursor: pointer; text-align: left;
}
.logout-btn:hover { color: var(--text); background: var(--surface-hover); }

.mobile-bar { display: none; }
.sidebar-backdrop { display: none; }

.main-content { flex: 1; padding: 30px 36px 64px; min-width: 0; max-width: 1160px; }
.main-wide { padding: 0; max-width: none; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; gap: 16px; flex-wrap: wrap; }
.page-header h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.2; }
.page-subtitle { font-size: 14px; color: var(--text-muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.section-title { font-size: 15px; font-weight: 600; margin-bottom: 10px; }

/* Home */
.home-ask { max-width: 720px; margin: 22px 0 44px; }
.home-ask-label { display: block; font-size: 32px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; margin-bottom: 14px; }
.home-ask-input {
    width: 100%; padding: 13px 16px; font: inherit; font-size: 18px; color: var(--text);
    border: 1px solid var(--border-light); border-radius: var(--radius); background: var(--bg);
}
.home-ask-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.home-ask-input::placeholder { color: var(--text-dim); }
.home-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 48px; align-items: start; }

.book-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.book-table th { text-align: left; font-weight: 500; color: var(--text-dim); font-size: 13px; padding: 0 0 6px; border-bottom: 1px solid var(--border-light); }
.book-table td { padding: 8px 0 9px; border-bottom: 1px solid var(--border); position: relative; }
.book-table tbody tr { cursor: pointer; }
.book-table tbody tr:hover a { text-decoration: underline; }
.book-table a { color: var(--text); font-weight: 500; }
.book-table .num { text-align: right; width: 72px; }
.market-bar { position: absolute; left: 0; bottom: -1px; height: 2px; background: var(--accent); }

.touch-list { border-top: 1px solid var(--border-light); }
.touch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); color: var(--text); }
.touch-row:hover { text-decoration: none; background: var(--surface-hover); }
.touch-main { display: flex; flex-direction: column; min-width: 0; }

/* Contacts: list beside the open record */
.book { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100vh; }
.book.has-record { grid-template-columns: minmax(0, 1fr) var(--record-w); }
.book-list { padding: 28px 32px 64px; min-width: 0; max-width: 1160px; }
.list-search { margin-bottom: 10px; }
.list-search .form-input { padding-top: 11px; padding-bottom: 11px; font-size: 15px; }

.rows { border-top: 1px solid var(--border-light); }
.row {
    display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.3fr) 112px 118px;
    gap: 16px; align-items: center; padding: 9px 10px; margin: 0 -10px;
    border-bottom: 1px solid var(--border); color: var(--text);
}
a.row:hover { background: var(--surface-hover); text-decoration: none; }
.row.selected, a.row.selected:hover { background: var(--accent-dim); box-shadow: inset 2px 0 0 var(--accent); }
.row-main { min-width: 0; }
.row-name { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 14.5px; min-width: 0; }
.row-products { font-size: 13px; color: var(--text-muted); }
.row-snippet { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.has-record .row { grid-template-columns: minmax(0, 1fr) 118px; }
.has-record .row-products, .has-record .row-role { display: none; }
.sent-row { grid-template-columns: minmax(0, 1fr) 70px 130px; }
.error-text { color: var(--red); }

.role { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.role-buyer { color: var(--blue); }
.role-seller { color: var(--yellow); }
.role-both { color: var(--accent-strong); }
.role-out { color: var(--red); }

.since { font-size: 13px; color: var(--text-dim); white-space: nowrap; text-align: right; }
.since.fresh { color: var(--accent-strong); font-weight: 500; }
.since.aging { color: var(--yellow); }

/* Contact record */
.record {
    border-left: 1px solid var(--border); padding: 18px 28px 48px; background: var(--bg);
    position: sticky; top: 0; height: 100vh; overflow-y: auto; min-width: 0;
}
.record-top { display: flex; align-items: center; justify-content: space-between; min-height: 30px; margin-bottom: 8px; }
.record-back { display: none; }
.record-name { font-size: 24px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.2; overflow-wrap: anywhere; }
.record-company { font-size: 15px; color: var(--text-muted); margin-top: 2px; }
.record-meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; align-items: baseline; }
.record-facts { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 5px 10px; margin: 16px 0; font-size: 14px; }
.record-facts dt { color: var(--text-dim); }
.record-facts dd { overflow-wrap: anywhere; }
.record-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.log-box { padding: 12px; background: var(--bg-soft); border-radius: var(--radius); margin-bottom: 24px; }
.log-box .form-textarea { min-height: 62px; }
.log-box .form-actions { margin-top: 8px; }

/* The call history is the point of this screen: a dated gutter and a continuous rule. */
.history { border-left: 1px solid var(--border-light); margin-left: 3px; }
.entry { position: relative; padding: 0 0 18px 16px; }
.entry::before { content: ''; position: absolute; left: -4px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); }
.entry-email::before { background: var(--blue); }
.entry-day { font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 2px; }
.entry-text { font-size: 14px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.entry-mail { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--blue); margin-bottom: 1px; }
.entry-mail a { margin-left: 8px; }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px; padding: 2px 0; }
.link-btn:hover { text-decoration: underline; }

/* Skeleton */
.skeleton { border-top: 1px solid var(--border); }
.skeleton-row { height: 40px; border-bottom: 1px solid var(--border); padding-top: 14px; }
.skeleton-row::before { content: ''; display: block; width: 46%; height: 12px; background: var(--surface-raised); border-radius: 3px; }

/* Cards, used only for bounded forms */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 14px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-lead { font-size: 14px; color: var(--text-muted); margin-bottom: 14px; max-width: 66ch; }
.settings-block { max-width: 620px; }
.compose { max-width: 820px; }

/* Cells */
.cell-primary { font-weight: 500; }
.cell-secondary { font-size: 13px; color: var(--text-muted); }
.cell-mono { font-size: 13px; color: var(--text-muted); }
.cell-actions { display: flex; gap: 2px; justify-content: flex-end; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 4px; font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.badge-green  { background: var(--accent-dim); color: var(--accent-strong); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); }
.badge-red    { background: var(--red-dim); color: var(--red); }
.badge-blue   { background: var(--blue-dim); color: var(--blue); }
.badge-gray   { background: var(--surface-raised); color: var(--text-muted); }

/* Product chips */
.chip-row { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 4px; font-size: 12.5px; background: var(--bg-soft); color: var(--text-muted); white-space: nowrap; }
.chip-more { background: transparent; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px;
    border-radius: var(--radius-sm); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
    border: 1px solid transparent; line-height: 1.25; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #FFFFFF; }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-light); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--text-dim); }
.btn-danger { background: var(--red); color: #FFFFFF; }
.btn-danger:hover:not(:disabled) { background: #A32417; }
.btn-quiet { background: transparent; color: var(--text-muted); }
.btn-quiet:hover:not(:disabled) { background: var(--surface-raised); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; padding: 10px 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: var(--radius-sm); border: none; cursor: pointer;
    background: transparent; color: var(--text-dim);
}
.btn-icon:hover { background: var(--surface-raised); color: var(--text); }
.btn-icon.danger:hover { background: var(--red-dim); color: var(--red); }

/* Forms */
.form-grid { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 4px; }
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 8px 11px; background: #FFFFFF;
    border: 1px solid var(--border-light); border-radius: var(--radius-sm);
    color: var(--text); font-family: inherit; font-size: 14px;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-dim); }
.form-select {
    appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%237C8693' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px;
}
.form-textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.form-hint { font-size: 13px; color: var(--text-dim); margin-top: 4px; }
.form-actions { display: flex; gap: 8px; margin-top: 4px; justify-content: flex-end; flex-wrap: wrap; }

.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-dim); pointer-events: none; }
.input-icon .form-input { padding-left: 34px; }

/* Filters */
.filter-bar { display: flex; gap: 8px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.filter-bar .form-select { width: auto; max-width: 190px; padding-top: 6px; padding-bottom: 6px; font-size: 13.5px; }
.tab-bar { display: flex; gap: 2px; flex-wrap: wrap; }
.tab-link {
    padding: 6px 11px; border-radius: var(--radius-sm); font-size: 14px;
    color: var(--text-muted); border: none; background: none; cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
}
.tab-link:hover { color: var(--text); background: var(--surface-hover); }
.tab-link.active { background: var(--accent-dim); color: var(--accent-strong); font-weight: 500; }
.tab-count { font-size: 12.5px; opacity: 0.75; }
.filter-spacer { margin-left: auto; }
.searchbar { width: 260px; max-width: 100%; }

/* Alerts */
.flash { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; display: flex; align-items: center; gap: 10px; }
.flash-success { background: var(--accent-dim); color: var(--accent-strong); }
.flash-error { background: var(--red-dim); color: var(--red); }
.flash-warn { background: var(--yellow-dim); color: var(--yellow); }

/* Toast */
.toast {
    position: fixed; bottom: 20px; right: 20px; z-index: 200;
    display: flex; align-items: center; gap: 9px;
    padding: 10px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
    color: #FFFFFF; box-shadow: var(--shadow);
}
.toast-success { background: var(--text); }
.toast-error { background: var(--red); }

/* Login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.login-error { background: var(--red-dim); color: var(--red); padding: 9px 13px; border-radius: var(--radius-sm); font-size: 14px; }

/* Empty state */
.empty-state { padding: 44px 20px; color: var(--text-muted); text-align: center; }
.empty-state svg { color: var(--border-light); margin-bottom: 10px; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.empty-state p { margin-bottom: 14px; font-size: 14px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(23,32,43,0.32); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { width: 100%; max-width: 480px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); max-height: 90vh; overflow-y: auto; }
.modal-wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-title { font-size: 17px; font-weight: 600; }
.modal-body { padding: 18px 20px 20px; }
.confirm-body { display: flex; gap: 12px; font-size: 14px; color: var(--text-muted); margin-bottom: 18px; }
.confirm-body svg { color: var(--yellow); flex-shrink: 0; margin-top: 1px; }

/* Meter */
.meter { height: 6px; background: var(--surface-raised); border-radius: 3px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--accent); transition: width 0.3s ease; }

/* Product picker */
.picker-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.picker-filter { width: 140px; padding: 4px 9px; font-size: 13px; }
.picker-box { display: flex; flex-wrap: wrap; gap: 5px; max-height: 190px; overflow-y: auto; padding: 10px; background: var(--bg-soft); border-radius: var(--radius-sm); }
.picker-opt { padding: 2px 9px; border-radius: 4px; font-size: 13px; cursor: pointer; background: var(--surface); border: 1px solid var(--border-light); color: var(--text-muted); }
.picker-opt:hover { border-color: var(--text-dim); color: var(--text); }
.picker-opt.on { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.suggest-box { background: var(--blue-dim); border-radius: var(--radius-sm); padding: 10px; margin-bottom: 8px; }
.suggest-label { font-size: 13px; font-weight: 500; color: var(--blue); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.picker-opt.suggested { border-style: dashed; border-color: var(--blue); color: var(--blue); }

/* Scan results */
.scan-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 18px; margin-bottom: 20px; }
.scan-num { font-size: 24px; font-weight: 600; }
.scan-num.pending { color: var(--yellow); }
.scan-num.done { color: var(--accent); }
.stat-label { font-size: 13px; color: var(--text-muted); }
.tag-rows { display: grid; gap: 6px; max-height: 420px; overflow-y: auto; padding-right: 6px; }
.tag-row { display: grid; grid-template-columns: 170px 1fr 44px; gap: 12px; align-items: center; font-size: 13.5px; }
.tag-bar { background: var(--bg-soft); height: 6px; overflow: hidden; }
.tag-bar span { display: block; height: 100%; background: var(--accent); }
.tag-count { font-size: 13px; color: var(--text-muted); text-align: right; }
.evidence { margin-top: 18px; }
.evidence summary { cursor: pointer; font-size: 14px; color: var(--text-muted); }
.evidence-list { margin-top: 14px; display: grid; gap: 14px; max-height: 320px; overflow-y: auto; }
.evidence-quote { font-size: 13px; color: var(--text-muted); margin-top: 5px; padding-left: 10px; border-left: 2px solid var(--border); }
.evidence-name { color: var(--text); font-weight: 500; }

/* Mobile list cards used by older screens */
.contact-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; display: grid; gap: 9px; }

/* Autocomplete */
.autocomplete { position: relative; }
.autocomplete-menu {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--surface);
    border: 1px solid var(--border-light); border-radius: var(--radius-sm); box-shadow: var(--shadow);
    max-height: 280px; overflow-y: auto; z-index: 100;
}
.autocomplete-item { display: block; width: 100%; text-align: left; padding: 9px 13px; background: none; border: none; cursor: pointer; border-bottom: 1px solid var(--border); }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--surface-hover); }
.selected-pill { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 11px; border: 1px solid var(--border-light); border-radius: var(--radius-sm); font-size: 14px; }
.selected-pill span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Utilities */
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack-sm { display: grid; gap: 8px; }
.load-more { text-align: center; padding: 18px 0 4px; }

/* Matches: the two sides of the book */
.match-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: start; }
.match-columns .card + .card { margin-top: 0; }
.match-list { display: grid; max-height: 640px; overflow-y: auto; }
.match-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.match-row:last-child { border-bottom: none; }
.match-main { min-width: 0; }
.match-main .cell-primary a { color: var(--text); }
.match-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.match-actions { display: flex; gap: 2px; }
.match-actions .btn-icon { text-decoration: none; }

.only-mobile { display: none; }
.only-desktop { display: block; }

@media (max-width: 1180px) {
    .book.has-record { grid-template-columns: minmax(0, 1fr); }
    .book.has-record .book-list { display: none; }
    .record { position: static; height: auto; border-left: none; max-width: 720px; }
    .record-back { display: block; }
}

@media (max-width: 900px) {
    .mobile-bar {
        display: flex; align-items: center; gap: 12px; position: fixed; top: 0; left: 0; right: 0;
        height: 52px; background: var(--bg); border-bottom: 1px solid var(--border);
        padding: 0 16px; z-index: 50;
    }
    .mobile-menu-btn { background: none; border: none; color: var(--text); cursor: pointer; display: flex; padding: 4px; }
    .mobile-title { font-size: 15px; font-weight: 600; }
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform 0.2s ease; }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
    .sidebar-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(23,32,43,0.32); z-index: 35; }
    .main-content { padding: 72px 16px 48px; }
    .main-wide { padding: 52px 0 0; }
    .book-list { padding: 20px 16px 48px; }
    .record { padding: 16px 16px 48px; }
    .home-ask { margin-top: 4px; }
    .home-ask-label { font-size: 26px; }
    .home-grid { grid-template-columns: minmax(0, 1fr); gap: 32px; }
    .row { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
    .row-products, .row-role { display: none; }
    .sent-row { grid-template-columns: minmax(0, 1fr) auto; }
    .sent-row .since { grid-column: 1 / -1; text-align: left; }
    .searchbar { width: 100%; }
    .filter-spacer { margin-left: 0; width: 100%; }
    .filter-bar .form-select { flex: 1 1 130px; max-width: none; }
    .tag-row { grid-template-columns: 120px 1fr 40px; }
    .toast { left: 16px; right: 16px; bottom: 16px; }
    .match-columns { grid-template-columns: 1fr; }
    .match-row { flex-direction: column; gap: 6px; }
    .match-meta { align-items: flex-start; flex-direction: row; flex-wrap: wrap; }
    .only-mobile { display: block; }
    .only-desktop { display: none; }
    /* 16px stops iOS Safari zooming the page on focus */
    .form-input, .form-select, .form-textarea, .home-ask-input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
