:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #fff;
  --surface-soft: #f8fafc;
  --ink: #202734;
  --muted: #737f91;
  --line: #e3e8ef;
  --primary: #3568e8;
  --primary-deep: #2855c4;
  --primary-soft: #edf3ff;
  --success: #158765;
  --success-soft: #eaf7f2;
  --warning: #b96b18;
  --warning-soft: #fff3e4;
  --danger: #c6475c;
  --danger-soft: #fff0f2;
  --radius: 8px;
  --shadow: 0 5px 18px rgba(32, 48, 74, .07);
  font-family: "PingFang SC", "Microsoft YaHei UI", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { width: 100%; min-height: 100%; overflow-x: hidden; -webkit-text-size-adjust: 100%; }
html, body { min-height: 100%; margin: 0; background: var(--bg); color: var(--ink); }
body { width: 100%; max-width: 100vw; min-width: 320px; overflow-x: hidden; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, label { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.mobile-auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: #f2f5fa; }
.auth-panel { width: min(380px, 100%); padding: 28px 23px 24px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.brand-mark, .compact-brand { display: grid; place-items: center; flex: 0 0 auto; background: var(--primary); color: #fff; }
.brand-mark { width: 44px; height: 44px; border-radius: var(--radius); }
.brand-mark svg { width: 23px; height: 23px; }
.brand-kicker { margin: 17px 0 4px; color: var(--primary); font-size: 10px; font-weight: 800; letter-spacing: 0; }
.auth-panel h1 { margin: 0 0 21px; font-size: 23px; letter-spacing: 0; }
.auth-form { display: grid; gap: 13px; }
.auth-form label, .dispatch-form label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 650; }
.auth-form input, .dispatch-form input, .dispatch-form select, .dispatch-form textarea { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; outline: 0; }
.auth-form input, .dispatch-form input, .dispatch-form select { height: 44px; padding: 0 12px; }
.dispatch-form textarea { min-height: 105px; padding: 11px 12px 27px; line-height: 1.6; resize: vertical; }
.auth-form input:focus, .dispatch-form input:focus, .dispatch-form select:focus, .dispatch-form textarea:focus, .chat-composer textarea:focus, .search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(53, 104, 232, .11); }

.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 14px; border: 1px solid transparent; border-radius: var(--radius); font-size: 12px; font-weight: 750; white-space: nowrap; }
.button svg, .icon-button svg, .text-button svg { width: 17px; height: 17px; }
.button-primary { border-color: var(--primary); background: var(--primary); color: #fff; box-shadow: 0 4px 11px rgba(53, 104, 232, .18); }
.button-primary:active:not(:disabled) { background: var(--primary-deep); }
.button-primary:disabled { border-color: #c8d0dc; background: #c8d0dc; box-shadow: none; cursor: not-allowed; }
.button-wide { width: 100%; }
.form-error, .inline-error { min-height: 18px; margin: 6px 0 0; color: var(--danger); font-size: 11px; line-height: 1.45; }

.mobile-app { width: 100%; min-height: 100dvh; overflow-x: hidden; }
.app-view { width: 100%; max-width: 100vw; min-width: 0; min-height: 100dvh; padding: max(10px, env(safe-area-inset-top)) 12px calc(76px + env(safe-area-inset-bottom)); }
.app-header { min-height: 50px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 1px 8px; }
.app-header h1 { margin: 0; font-size: 19px; letter-spacing: 0; }
.app-header small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.sticky-header { position: sticky; top: 0; z-index: 15; margin: -10px -12px 0; padding: max(10px, env(safe-area-inset-top)) 13px 8px; border-bottom: 1px solid var(--line); background: rgba(244, 246, 249, .96); backdrop-filter: blur(10px); }
.brand-line { min-width: 0; display: flex; align-items: center; gap: 9px; }
.brand-line strong, .brand-line small { display: block; }
.brand-line strong { font-size: 15px; }
.brand-line small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.compact-brand { width: 34px; height: 34px; border-radius: 7px; }
.compact-brand svg { width: 18px; height: 18px; }
.icon-button { width: 36px; height: 36px; display: inline-grid; place-items: center; flex: 0 0 auto; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--muted); }
.icon-button:active { color: var(--primary); background: var(--primary-soft); }
.text-button { min-height: 36px; padding: 0 4px; border: 0; background: transparent; color: var(--primary); font-size: 12px; }

.list-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 7px 1px 10px; }
.list-heading h1 { display: inline; margin: 0; font-size: 18px; }
.list-heading > div span { margin-left: 5px; color: var(--muted); font-size: 10px; }
.records-entry { width: 100%; min-width: 0; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto 16px; align-items: center; gap: 8px; margin: 4px 0 11px; padding: 10px 11px; border: 1px solid #d9e2f1; border-radius: var(--radius); background: var(--primary-soft); color: var(--ink); text-align: left; }
.records-entry > svg:first-child { width: 18px; height: 18px; color: var(--primary); }
.records-entry > svg:last-child { width: 15px; height: 15px; color: var(--muted); }
.records-entry span, .records-entry small { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.records-entry span { font-size: 12px; font-weight: 750; }
.records-entry small { color: var(--muted); font-size: 9px; }
.records-view { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
.records-header { margin-bottom: 10px; }
.records-heading { min-width: 0; display: flex; align-items: center; gap: 7px; }
.records-heading > div { min-width: 0; }
.records-heading h1 { margin: 0; font-size: 17px; }
.records-heading small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; }
.records-toolbar { display: grid; gap: 9px; margin-bottom: 10px; }
.records-days { display: flex; gap: 7px; overflow-x: auto; min-width: 0; padding: 1px 1px 3px; scrollbar-width: none; }
.records-days::-webkit-scrollbar { display: none; }
.records-day { min-width: 62px; min-height: 45px; display: grid; align-content: center; gap: 3px; flex: 0 0 auto; padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--muted); text-align: center; }
.records-day strong { font-size: 10px; font-weight: 700; }
.records-day small { font-size: 8px; }
.records-day.is-active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); box-shadow: inset 0 0 0 1px rgba(53, 104, 232, .08); }
.retention-setting { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; padding: 9px 10px; border: 1px solid #e8ddc9; border-radius: 7px; background: #fffaf2; }
.retention-setting > div { min-width: 0; }
.retention-setting strong, .retention-setting small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.retention-setting strong { color: #7c531b; font-size: 10px; }
.retention-setting small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.switch-control { position: relative; width: 42px; height: 24px; display: block; flex: 0 0 auto; cursor: pointer; }
.switch-control input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.switch-control span { position: absolute; inset: 0; border-radius: 999px; background: #c9d1dc; pointer-events: none; transition: background .16s ease; }
.switch-control span::after { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(24, 36, 55, .25); content: ""; transition: transform .16s ease; }
.switch-control input:checked + span { background: var(--success); }
.switch-control input:checked + span::after { transform: translateX(18px); }
.switch-control input:disabled + span { opacity: .48; cursor: not-allowed; }
.records-search { margin-bottom: 10px; }
.records-list { display: grid; gap: 11px; min-width: 0; }
.records-group { display: grid; gap: 7px; min-width: 0; }
.records-date-heading { display: flex; align-items: baseline; gap: 5px; margin: 2px 1px 0; color: var(--ink); font-size: 11px; }
.records-date-heading small { color: var(--muted); font-size: 9px; font-weight: 400; }
.records-more { width: 100%; min-height: 38px; margin-top: 12px; border-color: var(--line); background: #fff; color: var(--primary); box-shadow: none; }
.records-more svg { width: 15px; height: 15px; }
.records-more:disabled { color: var(--muted); }
.sync-state { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.sync-state i { width: 6px; height: 6px; border-radius: 50%; background: #adb7c5; }
.sync-state.is-online i { background: var(--success); }
.sync-state.is-error { color: var(--danger); }
.sync-state.is-error i { background: var(--danger); }
.search-box { width: 100%; height: 39px; display: flex; align-items: center; gap: 7px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--muted); }
.search-box svg { width: 16px; height: 16px; flex: 0 0 auto; }
.search-box input { width: 100%; min-width: 0; height: 100%; padding: 0; border: 0; outline: 0; background: transparent; font-size: 12px; }
.status-tabs { display: flex; gap: 19px; overflow-x: auto; margin: 9px 0 10px; padding: 0 1px 4px; scrollbar-width: none; }
.status-tabs::-webkit-scrollbar { display: none; }
.status-tabs button { position: relative; display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; min-height: 31px; padding: 0 1px; border: 0; background: transparent; color: var(--muted); font-size: 11px; }
.status-tabs button b { font-size: 9px; }
.status-tabs button.is-active { color: var(--primary); font-weight: 750; }
.status-tabs button.is-active::after { position: absolute; right: 2px; bottom: -2px; left: 2px; height: 2px; border-radius: 2px; background: var(--primary); content: ""; }

.task-list { display: grid; gap: 8px; }
.task-card { display: grid; grid-template-columns: 66px minmax(0, 1fr); gap: 10px; min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: 0 3px 11px rgba(35, 50, 76, .045); text-align: left; }
.task-card:active { background: #fbfcfe; transform: translateY(1px); }
.task-thumb { position: relative; width: 66px; height: 82px; overflow: hidden; border-radius: 6px; background: #edf1f6; }
.task-thumb img { width: 100%; height: 100%; object-fit: cover; }
.task-thumb > svg { position: absolute; top: 50%; left: 50%; width: 20px; color: #a6b0c0; transform: translate(-50%, -50%); }
.thumb-count { position: absolute; right: 4px; bottom: 4px; display: inline-flex; align-items: center; gap: 3px; padding: 3px 4px; border-radius: 4px; background: rgba(25, 34, 49, .76); color: #fff; font-size: 8px; }
.thumb-count svg { width: 10px; height: 10px; }
.task-body { min-width: 0; }
.task-line { display: flex; align-items: flex-start; justify-content: space-between; gap: 7px; }
.task-line strong { min-width: 0; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.status-badge { display: inline-flex; flex: 0 0 auto; padding: 4px 6px; border-radius: 5px; background: var(--primary-soft); color: var(--primary); font-size: 9px; font-weight: 750; }
.status-badge.is-warn { background: var(--warning-soft); color: var(--warning); }
.status-badge.is-danger { background: var(--danger-soft); color: var(--danger); }
.status-badge.is-success { background: var(--success-soft); color: var(--success); }
.task-order-id { margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.task-request { display: -webkit-box; min-height: 27px; margin-top: 7px; overflow: hidden; color: #4b5668; font-size: 10px; line-height: 1.4; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.task-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 7px; color: var(--muted); font-size: 9px; }
.task-meta .urgent { color: var(--danger); font-weight: 700; }
.task-owner { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-state, .loading-state { min-height: 230px; display: grid; align-content: center; justify-items: center; gap: 8px; padding: 24px; color: var(--muted); text-align: center; }
.empty-state svg { width: 29px; height: 29px; color: var(--primary); }
.empty-state strong { color: var(--ink); font-size: 13px; }
.empty-state span, .loading-state span { font-size: 11px; line-height: 1.5; }
.loading-state svg { width: 23px; height: 23px; color: var(--primary); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.dispatch-form { padding-top: 12px; }
.form-section { margin-bottom: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.compact-fields { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(105px, .7fr); gap: 9px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.section-title strong { font-size: 13px; }
.section-title span { color: var(--muted); font-size: 9px; }
.type-selector { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.type-selector button { min-height: 52px; display: grid; align-content: center; justify-items: center; gap: 5px; padding: 4px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--muted); font-size: 10px; }
.type-selector button svg { width: 17px; height: 17px; }
.type-selector button.is-selected { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 750; }
.upload-section { padding-bottom: 11px; }
.preview-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; margin-bottom: 8px; }
.preview-grid:empty { display: none; }
.preview-item { position: relative; min-width: 0; overflow: hidden; aspect-ratio: .82; border: 1px solid var(--line); border-radius: 6px; background: #eef1f5; }
.preview-item img { width: 100%; height: 100%; object-fit: cover; }
.preview-item.is-processing img { opacity: .62; }
.preview-item.is-error { border-color: var(--danger); }
.remove-file, .retry-file { position: absolute; display: grid; place-items: center; padding: 0; border: 0; color: #fff; }
.remove-file { top: 4px; right: 4px; width: 23px; height: 23px; border-radius: 50%; background: rgba(24, 34, 51, .76); }
.remove-file svg { width: 13px; height: 13px; }
.retry-file { inset: 50% auto auto 50%; min-width: 49px; min-height: 28px; gap: 3px; padding: 0 6px; border-radius: 5px; background: rgba(198, 71, 92, .92); font-size: 9px; transform: translate(-50%, -50%); }
.retry-file svg { width: 12px; height: 12px; }
.file-state { position: absolute; right: 0; bottom: 0; left: 0; display: flex; align-items: center; justify-content: center; gap: 3px; min-height: 20px; padding: 3px; background: rgba(25, 35, 51, .76); color: #fff; font-size: 8px; text-align: center; }
.file-state svg { width: 10px; height: 10px; }
.file-state .lucide-loader-circle { animation: spin 1s linear infinite; }
.file-state.is-ready { background: rgba(21, 135, 101, .86); }
.file-state.is-error { background: rgba(198, 71, 92, .9); }
.upload-trigger { min-height: 60px; display: grid !important; grid-template-columns: auto 1fr; align-content: center; gap: 2px 8px !important; padding: 9px 11px; border: 1px dashed #bdc7d6; border-radius: 7px; background: var(--surface-soft); color: var(--ink) !important; cursor: pointer; }
.upload-trigger.is-dragging { border-color: var(--primary); background: var(--primary-soft); }
.upload-trigger svg { grid-row: 1 / 3; align-self: center; width: 21px; height: 21px; color: var(--primary); }
.upload-trigger span { font-size: 11px; font-weight: 700; }
.upload-trigger small { color: var(--muted); font-size: 9px; font-weight: 400; }
.requirements-field { position: relative; }
.counter { position: absolute; right: 10px; bottom: 8px; color: #9aa4b2; font-size: 9px; font-weight: 400; }
.consent-row { display: flex !important; align-items: flex-start; gap: 7px !important; margin: 4px 3px 0; color: var(--muted) !important; font-size: 10px !important; font-weight: 400 !important; line-height: 1.5; }
.consent-row input { width: 17px !important; height: 17px !important; flex: 0 0 auto; margin: 0; }
.request-error { margin: 5px 3px 0; }
.submit-spacer { height: 70px; }
.submit-bar { position: fixed; right: 0; bottom: calc(61px + env(safe-area-inset-bottom)); left: 0; z-index: 25; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 62px; padding: 8px 12px; border-top: 1px solid var(--line); background: rgba(255, 255, 255, .97); box-shadow: 0 -5px 16px rgba(36, 49, 72, .06); backdrop-filter: blur(10px); }
.submit-bar strong, .submit-bar small { display: block; }
.submit-bar strong { font-size: 11px; }
.submit-bar small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.upload-progress { position: relative; height: 6px; margin: 8px 3px 22px; overflow: visible; border-radius: 999px; background: #e2e7ef; }
.upload-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--primary); transition: width 120ms ease; }
.upload-progress em { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; font-style: normal; }

.profile-card { display: flex; align-items: center; gap: 11px; margin-top: 8px; padding: 15px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.profile-avatar { width: 46px; height: 46px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: 17px; font-weight: 800; }
.profile-card > div { min-width: 0; flex: 1; }
.profile-card strong, .profile-card span { display: block; }
.profile-card strong { font-size: 14px; }
.profile-card span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.online-pill { display: inline-flex !important; align-items: center; gap: 5px; flex: 0 0 auto; margin: 0 !important; padding: 5px 7px; border-radius: 999px; background: var(--success-soft); color: var(--success) !important; font-size: 9px !important; }
.online-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
.profile-menu { margin-top: 10px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.profile-menu > div, .profile-menu > a, .profile-menu > button { width: 100%; min-height: 58px; display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--line); background: #fff; color: var(--ink); text-align: left; text-decoration: none; }
.profile-menu > :last-child { border-bottom: 0; }
.profile-menu > * > svg { width: 18px; height: 18px; color: var(--muted); }
.profile-menu > * > svg:last-child { width: 15px; }
.profile-menu strong, .profile-menu small { display: block; }
.profile-menu strong { font-size: 12px; }
.profile-menu small { margin-top: 3px; color: var(--muted); font-size: 9px; }

.bottom-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 40; height: calc(61px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px 10px env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: rgba(255, 255, 255, .97); box-shadow: 0 -5px 17px rgba(35, 48, 70, .06); backdrop-filter: blur(12px); }
.bottom-nav button { position: relative; display: grid; align-content: center; justify-items: center; gap: 3px; padding: 0; border: 0; background: transparent; color: #778295; font-size: 10px; }
.bottom-nav button svg { width: 20px; height: 20px; }
.bottom-nav button.is-active { color: var(--primary); font-weight: 750; }
.bottom-nav button b { position: absolute; top: 1px; left: calc(50% + 9px); min-width: 16px; height: 16px; display: grid; place-items: center; padding: 0 3px; border: 2px solid #fff; border-radius: 999px; background: var(--danger); color: #fff; font-size: 8px; }

.detail-page { height: 100dvh; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto auto; overflow: hidden; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); background: #f5f7fa; }
.detail-page.has-delivery { grid-template-rows: auto auto auto minmax(0, 1fr) auto auto; }
.detail-topbar { min-height: 50px; display: flex; align-items: center; gap: 8px; padding: 6px 11px; border-bottom: 1px solid var(--line); background: #fff; }
.detail-title { min-width: 0; flex: 1; }
.detail-title strong, .detail-title span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-title strong { font-size: 14px; }
.detail-title span { margin-top: 3px; color: var(--muted); font-size: 9px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #aab4c2; }
.status-dot.is-active { background: var(--success); box-shadow: 0 0 0 4px rgba(21, 135, 101, .11); }
.detail-summary { display: flex; align-items: center; gap: 8px; min-height: 49px; padding: 7px 12px; border-bottom: 1px solid var(--line); background: #fbfcfd; }
.summary-thumb { width: 34px; height: 39px; overflow: hidden; flex: 0 0 auto; border-radius: 5px; background: #e9edf3; }
.summary-thumb img { width: 100%; height: 100%; object-fit: cover; }
.detail-summary > div { min-width: 0; flex: 1; }
.detail-summary strong, .detail-summary span { display: block; }
.detail-summary strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.detail-summary span { margin-top: 3px; color: var(--muted); font-size: 9px; }
.detail-summary .status-badge { flex: 0 0 auto; }
.delivery-strip { display: flex; align-items: center; gap: 7px; overflow-x: auto; min-height: 68px; padding: 7px 11px; border-bottom: 1px solid var(--line); background: var(--success-soft); scrollbar-width: none; }
.delivery-strip::-webkit-scrollbar { display: none; }
.delivery-label { display: grid; justify-items: center; gap: 3px; flex: 0 0 43px; color: var(--success); font-size: 8px; }
.delivery-label svg { width: 17px; height: 17px; }
.delivery-thumb { position: relative; width: 47px; height: 53px; flex: 0 0 auto; overflow: hidden; padding: 0; border: 1px solid rgba(21, 135, 101, .24); border-radius: 5px; background: #fff; }
.delivery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.delivery-thumb span { position: absolute; right: 2px; bottom: 2px; display: grid; place-items: center; width: 17px; height: 17px; border-radius: 4px; background: rgba(22, 32, 47, .7); color: #fff; }
.delivery-thumb svg { width: 10px; height: 10px; }
.chat-messages { min-height: 0; overflow-y: auto; padding: 12px 11px 16px; }
.chat-message { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin-bottom: 11px; }
.chat-message.is-own { align-items: flex-end; }
.chat-message.is-system { align-items: center; }
.message-meta { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 8px; }
.message-meta time { color: #a1aab8; }
.chat-bubble { max-width: 86%; padding: 8px 9px; border: 1px solid var(--line); border-radius: 7px 7px 7px 3px; background: #fff; box-shadow: 0 2px 7px rgba(34, 49, 75, .04); }
.chat-message.is-own .chat-bubble { border-color: #d4e0fb; border-radius: 7px 7px 3px 7px; background: var(--primary-soft); }
.chat-message.is-system .chat-bubble { max-width: 94%; border-color: #c9e8dc; border-radius: 5px; background: var(--success-soft); box-shadow: none; }
.chat-bubble p { margin: 0; font-size: 10px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-message.is-system .chat-bubble p { color: var(--success); }
.message-files { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin-top: 7px; }
.message-file { position: relative; min-width: 0; overflow: hidden; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: #edf1f5; }
.message-file img { width: 100%; aspect-ratio: 1 / 1.08; object-fit: cover; }
.message-file > span { position: absolute; right: 2px; bottom: 2px; left: 2px; overflow: hidden; padding: 2px 3px; border-radius: 3px; background: rgba(22, 31, 45, .72); color: #fff; font-size: 7px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.prompt-attachment { display: inline-flex; align-items: center; gap: 5px; color: var(--primary); font-size: 9px; text-decoration: none; }
.prompt-attachment svg { width: 14px; height: 14px; }
.chat-composer { padding: 8px 10px; border-top: 1px solid var(--line); background: #fff; }
.chat-composer textarea { width: 100%; min-height: 47px; max-height: 110px; padding: 8px 9px; border: 1px solid var(--line); border-radius: var(--radius); outline: 0; resize: none; font-size: 10px; line-height: 1.5; }
.composer-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 6px; margin-top: 6px; }
.composer-row select { min-width: 0; height: 34px; padding: 0 7px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; font-size: 9px; }
.attachment-button { height: 34px; display: inline-flex !important; align-items: center; justify-content: center; gap: 4px !important; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--muted) !important; font-size: 9px !important; cursor: pointer; }
.attachment-button svg { width: 14px; height: 14px; }
.send-button { min-height: 34px; padding: 0 10px; font-size: 10px; }
.selected-files { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.selected-file { display: inline-flex; align-items: center; gap: 4px; max-width: 145px; padding: 4px 5px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-soft); color: var(--muted); font-size: 8px; }
.selected-file > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-file button { width: 16px; height: 16px; display: grid; place-items: center; flex: 0 0 auto; padding: 0; border: 0; background: transparent; color: var(--muted); }
.selected-file button svg { width: 11px; height: 11px; }
.chat-composer .upload-progress { margin-bottom: 15px; }
.detail-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 53px; padding: 7px 10px; border-top: 1px solid var(--line); background: #fff; }
.detail-footer strong, .detail-footer small { display: block; }
.detail-footer strong { font-size: 10px; }
.detail-footer small { margin-top: 2px; color: var(--muted); font-size: 8px; }
.confirm-button { min-height: 35px; display: inline-flex; align-items: center; gap: 5px; padding: 0 10px; border: 1px solid #b9dfd2; border-radius: var(--radius); background: var(--success-soft); color: var(--success); font-size: 9px; font-weight: 750; white-space: nowrap; }
.confirm-button svg { width: 14px; height: 14px; }
.confirm-button.is-confirmed { border-color: var(--success); background: var(--success); color: #fff; }
.confirm-button:disabled { opacity: .55; cursor: not-allowed; }

.image-viewer { position: fixed; inset: 0; z-index: 100; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; place-items: center; padding: max(8px, env(safe-area-inset-top)) 8px max(13px, env(safe-area-inset-bottom)); background: rgba(10, 14, 21, .96); color: #fff; touch-action: pan-y; }
.image-viewer header { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 0 3px 7px; color: #d8dde6; font-size: 11px; }
.image-viewer header > div { display: flex; gap: 7px; }
.viewer-action { width: 36px; height: 36px; display: grid; place-items: center; padding: 0; border: 1px solid rgba(255, 255, 255, .18); border-radius: 7px; background: rgba(255, 255, 255, .08); color: #fff; }
.viewer-action svg { width: 18px; height: 18px; }
.image-viewer > img { max-width: calc(100vw - 18px); max-height: calc(100dvh - 110px); object-fit: contain; user-select: none; }
.image-viewer > p { width: 100%; margin: 7px 0 0; overflow: hidden; color: #bdc5d1; font-size: 9px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.viewer-arrow { position: absolute; top: 50%; z-index: 1; width: 38px; height: 46px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 6px; background: rgba(0, 0, 0, .35); color: #fff; transform: translateY(-50%); }
.viewer-arrow svg { width: 22px; height: 22px; }
.viewer-prev { left: 5px; }
.viewer-next { right: 5px; }
.viewer-arrow:disabled { display: none; }

.toast { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 120; max-width: calc(100vw - 30px); padding: 9px 12px; border-radius: 6px; background: #202a3b; color: #fff; font-size: 10px; line-height: 1.45; opacity: 0; pointer-events: none; transform: translate(-50%, 9px); transition: opacity .16s ease, transform .16s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: #9e3448; }

@media (min-width: 700px) {
  .app-view { width: min(680px, 100%); margin: 0 auto; padding-right: 20px; padding-left: 20px; }
  .bottom-nav, .submit-bar { left: 50%; width: min(700px, 100%); transform: translateX(-50%); }
  .detail-page { width: min(700px, 100%); margin: 0 auto; border-right: 1px solid var(--line); border-left: 1px solid var(--line); }
}

@media (max-width: 370px) {
  .compact-fields { grid-template-columns: 1fr; }
  .preview-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .type-selector button { font-size: 9px; }
  .submit-bar small { display: none; }
  .composer-row { grid-template-columns: minmax(0, 1fr) auto; }
  .send-button { grid-column: 1 / -1; }
}

@media (max-width: 430px) {
  .app-view { padding-right: 10px; padding-left: 10px; }
  .sticky-header { margin-right: -10px; margin-left: -10px; padding-right: 11px; padding-left: 11px; }
  .form-section { padding: 11px; }
  .preview-grid { gap: 6px; }
  .submit-bar { padding-right: 10px; padding-left: 10px; }
  .submit-bar .button { padding-right: 12px; padding-left: 12px; }
  .chat-bubble { max-width: 90%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
