:root {
  --coral: #fe6f60;
  --coral-deep: #e85a4c;
  --coral-soft: #fff1ee;
  --peach: #fad7a1;
  --grad: linear-gradient(45deg, #fad7a1, #fe6f60);
  --grad-soft: linear-gradient(45deg, #fad7a133, #fe6f6033);
  --cream: #fffaf7;
  --paper: #ffffff;
  --ink: #321908;
  --muted: #8a7a70;
  --line: #f1e4dc;
  --shadow: 0 2px 12px #0000001a;
  --shadow-soft: 0 2px 6px #eeeeee;
  --error: #c0392b;
  --amber-bg: #fff4e4;
  --amber: #b0763c;
  --sheet-shadow: 0 24px 60px #3219082e, 0 2px 8px #32190814;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--cream);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button, summary, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
a { color: inherit; text-underline-offset: 4px; }
button, a, input, textarea, summary { outline-offset: 4px; }
:focus-visible { outline: 2px solid var(--coral); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 100; background: var(--paper); padding: 12px 18px; border-radius: 8px; box-shadow: var(--shadow); }
.skip-link:focus { top: 12px; }
.app-shell { display: grid; grid-template-columns: 268px minmax(0, 1fr); height: 100vh; height: 100dvh; overflow: hidden; }

/* Sidebar: white card column, like UNU's clean nav surfaces. */
.sidebar { background: var(--paper); color: var(--ink); padding: 22px 18px 18px; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); box-shadow: 2px 0 12px #0000000a; position: relative; z-index: 2; }
.brand { display: block; margin: 0 6px 16px; text-decoration: none; }
.brand img { display: block; width: 132px; height: auto; }
.new-chat { border: 0; background: linear-gradient(45deg, #f5a77a, #e85a4c); color: #fff; border-radius: 6px; text-align: center; padding: 12px 16px; font-size: 15px; font-weight: 600; letter-spacing: 1px; box-shadow: 0 4px 14px #fe6f6040; transition: filter .15s, transform .15s; }
.new-chat span { margin-right: 6px; font-size: 18px; line-height: 1; }
.new-chat:hover { filter: brightness(1.04); transform: translateY(-1px); }
.search { display: flex; align-items: center; gap: 8px; margin: 16px 0 18px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; background: #fdf8f5; color: var(--muted); }
.search:focus-within { border-color: var(--coral); background: #fff; }
.search > span:first-child { font-size: 19px; line-height: 1; }
.search input { width: 100%; min-width: 0; padding: 10px 2px; background: transparent; border: 0; outline: none; color: var(--ink); font-size: 13px; }
.search input::placeholder { color: #b3a49b; }
.list-heading { display: flex; justify-content: space-between; align-items: center; margin: 0 6px 10px; color: var(--muted); font-size: 12px; }
.list-heading h2 { font-size: 13px; font-weight: 600; margin: 0; color: var(--ink); }
.list-heading > span { font-variant-numeric: tabular-nums; background: var(--coral-soft); color: var(--coral-deep); border-radius: 999px; padding: 1px 9px; font-size: 11px; }
.case-list { overflow: auto; min-height: 0; flex: 1; scrollbar-width: thin; scrollbar-color: #f0d8cf transparent; margin: 0 -4px; padding: 0 4px; }
.case-row { position: relative; margin-bottom: 3px; }
.case-row .case-item { margin-bottom: 0; padding-right: 34px; }
.case-delete { position: absolute; top: 8px; right: 6px; width: 24px; height: 24px; border: 0; border-radius: 50%; background: transparent; color: #b3a49b; font-size: 17px; line-height: 1; display: grid; place-items: center; opacity: .55; transition: opacity .15s, background .15s, color .15s; }
.case-row:hover .case-delete, .case-row:focus-within .case-delete, .case-item.is-active + .case-delete, .case-delete:focus-visible { opacity: 1; }
.case-delete:hover:not(:disabled) { background: var(--coral-soft); color: var(--coral-deep); }
.case-item { display: block; width: 100%; border: 0; border-left: 3px solid transparent; background: transparent; color: var(--ink); text-align: left; border-radius: 4px; padding: 11px 12px; margin-bottom: 3px; transition: background .15s; }
.case-item:hover { background: #fdf3ef; }
.case-item.is-active { background: var(--grad-soft); border-left-color: var(--coral); }
.case-item.is-active strong { color: var(--coral-deep); }
.case-item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; }
.case-preview { display: block; color: var(--muted); font-size: 12px; line-height: 1.6; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-note { font-size: 12px; line-height: 1.9; color: var(--muted); margin: 8px 6px; overflow-wrap: anywhere; }
.sidebar-retry { background: transparent; border: 1px solid var(--coral); color: var(--coral); border-radius: 4px; padding: 9px; margin: 10px 6px; }
.sidebar-footer { display: flex; align-items: center; gap: 10px; padding: 14px 12px; margin-top: 14px; border-radius: 6px; background: linear-gradient(45deg, #f5a77a, #e85a4c); color: #fff; }
.sidebar-footer > span { font-size: 20px; }
.sidebar-footer p { margin: 0; font-size: 13px; font-weight: 600; line-height: 1.5; letter-spacing: .5px; }
.sidebar-footer small { display: block; font-size: 10px; font-weight: 400; opacity: .9; margin-top: 2px; letter-spacing: 0; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--cream); }
.topbar { min-height: 64px; padding: 10px 32px; background: var(--paper); box-shadow: var(--shadow-soft); display: flex; align-items: center; justify-content: space-between; gap: 15px; flex-shrink: 0; position: relative; z-index: 1; }
.assistant-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.assistant-identity > div { min-width: 0; }
.avatar { display: grid; place-items: center; flex-shrink: 0; border-radius: 50%; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-soft); }
.avatar img { width: 70%; height: 70%; object-fit: contain; }
.small-avatar { width: 38px; height: 38px; font-size: 16px; position: relative; }
.small-avatar > span { position: absolute; width: 10px; height: 10px; background: #4cc38a; border: 2px solid #fff; border-radius: 50%; right: -1px; bottom: -1px; }
.assistant-identity h1 { margin: 0; font-size: 17px; font-weight: 600; }
.assistant-identity h1 > span { font-size: 12px; font-weight: 400; color: var(--muted); padding-left: 10px; }
.assistant-identity p { font-size: 12px; color: var(--muted); margin: 3px 0 0; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.connection { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.connection-badge { font-size: 12px; color: #b0763c; display: inline-flex; align-items: center; gap: 7px; background: #fff4e4; padding: 4px 11px; border-radius: 999px; }
.connection-badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #f0a64a; }
.connection-badge.is-connected { color: #2f8a5f; background: #eaf8f0; }
.connection-badge.is-connected::before { background: #4cc38a; }
.text-button { padding: 6px 2px; border: 0; background: transparent; color: var(--coral); font-size: 13px; text-decoration: none; }
.text-button:hover { color: var(--coral-deep); text-decoration: underline; }
.connection-notice { background: #fff4e4; color: #8a5a22; font-size: 12px; padding: 10px 26px; line-height: 1.7; border-bottom: 1px solid #f6e0c2; flex-shrink: 0; }
.conversation-scroll { flex: 1; overflow-y: auto; min-height: 0; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #f0d8cf transparent; }
.conversation-width { max-width: 860px; margin: 0 auto; padding: 0 35px 28px; }

/* Welcome: UNU hero band + coloured tiles. */
.welcome { padding: clamp(22px, 5vh, 60px) 0 24px; }
.welcome-hero { background: linear-gradient(45deg, #f5b98a, #e85a4c); color: #fff; border-radius: 10px; padding: 30px 34px; display: flex; align-items: center; justify-content: space-between; gap: 22px; box-shadow: 0 8px 26px #fe6f6033; margin-bottom: 26px; }
.welcome-hero h2 { margin: 0; font-size: clamp(24px, 2.4vw, 32px); line-height: 1.45; font-weight: 700; letter-spacing: 1px; }
.welcome-hero .eyebrow { color: #ffffffd9; margin: 0 0 10px; }
.welcome-mark { flex-shrink: 0; width: 86px; height: 86px; border-radius: 50%; background: #fff; display: grid; place-items: center; box-shadow: 0 4px 14px #0000001f; border: 4px solid #fad7a1; }
.welcome-mark img { width: 56px; height: auto; }
.eyebrow { font-size: 11px; letter-spacing: 2px; line-height: 1.6; margin: 0 0 16px; color: var(--muted); }
.welcome-copy { font-size: 15px; color: var(--muted); line-height: 1.9; margin: 0 0 18px; }
.starters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.starters button { border: 0; color: var(--ink); text-align: left; padding: 18px; border-radius: 6px; transition: transform .15s, box-shadow .15s; box-shadow: var(--shadow-soft); min-height: 112px; }
.starters button:nth-child(odd) { background: #fde3df; }
.starters button:nth-child(even) { background: #fcebcf; }
.starters button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow); }
.starters button > span { color: var(--coral-deep); font-size: 22px; display: block; margin-bottom: 10px; }
.starters strong { display: block; font-size: 16px; font-weight: 600; letter-spacing: .5px; }
.starters small { display: block; font-size: 12px; line-height: 1.7; margin-top: 6px; color: #7a6458; }
.history-note { text-align: center; padding: 60px 15px 30px; line-height: 1.9; color: var(--muted); font-size: 14px; }

/* Messages */
.messages { padding-top: 25px; }
.messages:empty { padding: 0; }
.message { display: flex; align-items: flex-start; gap: 12px; margin: 8px 0 26px; min-width: 0; }
.message-avatar { width: 32px; height: 32px; margin-top: 2px; font-size: 14px; }
.message-body { min-width: 0; max-width: 100%; }
.message-assistant .message-body { flex: 1; background: var(--paper); border-radius: 4px 12px 12px 12px; padding: 14px 18px 10px; box-shadow: var(--shadow-soft); border: 1px solid #f6ece6; }
.message-author { font-size: 12px; font-weight: 600; color: var(--coral-deep); margin: 0 0 6px; }
.message-content { margin: 0; font-size: 15px; line-height: 1.85; }
.plain-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.message-user { justify-content: flex-end; padding-left: 60px; }
.message-user .message-body { background: var(--coral-deep); color: #fff; padding: 12px 18px 9px; border-radius: 12px 12px 4px 12px; box-shadow: 0 4px 14px #fe6f6026; }
.message-user .message-author { margin: 0 0 4px; color: #ffffffd9; font-size: 11px; }
.message-user .message-time, .message-user .message-files { color: #ffffffcc; }
.message-time { display: block; font-size: 11px; color: #a89990; margin-top: 8px; line-height: 1.5; }
.message-files { margin: 8px 0 0; font-size: 12px; color: var(--muted); line-height: 1.7; overflow-wrap: anywhere; }
.is-pending .message-body { opacity: .8; }
.sending { display: flex; align-items: center; gap: 14px; color: var(--muted); margin: 18px 0 27px 44px; font-size: 13px; padding: 12px 16px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-soft); max-width: 520px; }
.sending-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.sending-text strong { color: var(--ink); font-weight: 600; font-size: 14px; }
.sending-text span { font-size: 12px; }
.sending-time { font-variant-numeric: tabular-nums; font-size: 12px; color: #b3a49b; }
.sending { align-items: flex-start; }
.sending .thinking-dot, .sending-time { margin-top: 4px; }
.sending .thinking-dot { flex-shrink: 0; margin-right: 12px; }
.steps { list-style: none; margin: 4px 0 2px; padding: 0; display: grid; gap: 3px; }
.step { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); }
.step.is-running { color: var(--ink); }
.step-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-mark { display: grid; place-items: center; width: 16px; height: 16px; font-size: 11px; color: #3f9b62; }
.step.is-failed .step-mark { color: var(--coral-deep); font-weight: 700; }
.step-spin { width: 11px; height: 11px; border-radius: 50%; border: 2px solid #f1d9cf; border-top-color: var(--coral); animation: step-spin .8s linear infinite; }
@keyframes step-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .step-spin { animation: none; } }
.activity { margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.activity > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 4px; }
.activity > summary::-webkit-details-marker { display: none; }
.activity > summary::after { content: '▸'; font-size: 10px; transition: transform .15s; }
.activity[open] > summary::after { transform: rotate(90deg); }
.activity .steps { margin: 6px 0 4px; padding: 8px 10px; background: #fdf8f5; border-radius: 8px; }
.thinking-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--coral); animation: breathe 1.4s ease-in-out infinite; box-shadow: 14px 0 0 var(--peach); }
@keyframes breathe { 50% { opacity: .35; } }

/* Case materials */
.case-materials { margin: 26px 0 0 44px; background: var(--paper); border-radius: 8px; padding: 2px 18px; box-shadow: var(--shadow-soft); border: 1px solid #f6ece6; }
.material-details { border-bottom: 1px solid var(--line); font-size: 13px; }
.material-details:last-child { border-bottom: 0; }
.material-details > summary { cursor: pointer; padding: 15px 0; color: var(--ink); font-size: 14px; font-weight: 600; }
.material-details > summary > span { margin-left: 10px; color: var(--muted); font-size: 12px; font-weight: 400; }
.material-details[open] > summary { color: var(--coral-deep); }
.summary-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 25px; margin: 6px 0 18px; }
.summary-facts > div { min-width: 0; }
.summary-facts dt { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.summary-facts dd { margin: 0; font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.summary-requirements { line-height: 1.9; color: #5e4a3e; margin: 0 0 20px; }
.panel-note { font-size: 12px; line-height: 1.85; color: var(--muted); margin: 0 0 14px; }
.file-list { list-style: none; padding: 0; margin: 0; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 5px 0 16px; }
.file-row > div { flex: 1; min-width: 0; }
.file-symbol { color: var(--coral); font-size: 22px; }
.file-link { font-size: 13px; overflow-wrap: anywhere; }
.file-row small { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.download-symbol { color: var(--coral); }
.draft-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 14px; margin: 0 0 14px; }
.draft-preview { flex: 1 1 100%; min-width: 0; }
.draft-preview summary { cursor: pointer; font-size: 13px; padding: 6px 0; }
.draft-preview p { max-height: 320px; overflow: auto; padding: 14px; border: 1px solid var(--line); background: #fffaf6; border-radius: 6px; font-size: 13px; line-height: 1.85; }
.draft-row > button, .draft-row > a { flex-shrink: 0; }

/* Composer */
.composer-area { flex-shrink: 0; padding: 12px 35px 16px; background: linear-gradient(#fffaf700, var(--cream) 30%); }
.composer-width { max-width: 800px; margin: 0 auto; }
.composer-form { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 14px 14px 10px; box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s; }
.composer-form:focus-within { border-color: var(--coral); box-shadow: 0 4px 18px #fe6f6026; }
.composer-form textarea { width: 100%; min-height: 50px; max-height: 180px; resize: none; display: block; border: 0; outline: none; background: transparent; color: var(--ink); padding: 0 3px 8px; font-size: 15px; line-height: 1.75; scrollbar-width: thin; }
.composer-form textarea::placeholder { color: #b3a49b; }
.composer-tools { display: flex; align-items: center; gap: 12px; }
.upload-button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fdf8f5; color: var(--ink); font-size: 13px; padding: 6px 12px; border-radius: 4px; }
.upload-button > span:first-child { font-size: 17px; line-height: 1; color: var(--coral); }
.upload-button:hover:not(:disabled) { border-color: var(--coral); color: var(--coral-deep); }
.composer-state { font-size: 11px; color: var(--muted); flex: 1; text-align: right; line-height: 1.6; }
.send-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--coral); color: #fff; border: 0; border-radius: 4px; padding: 8px 18px; min-width: 88px; min-height: 40px; font-weight: 600; letter-spacing: 1px; transition: background .15s; }
.send-button:hover:not(:disabled) { background: var(--coral-deep); }
.send-button:disabled { background: #f3b8b0; opacity: .8; }
.send-label { font-size: 14px; }
.send-button > span:last-child { font-size: 17px; line-height: 1; }
.composer-help { display: flex; justify-content: space-between; gap: 8px; margin: 8px 6px 0; color: #a89990; font-size: 11px; line-height: 1.6; }
.review-note { text-align: center; font-size: 11px; line-height: 1.7; color: #b0a197; margin: 6px 0 0; }
.operation-status { padding: 0 10px 10px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.operation-error { display: flex; align-items: flex-start; gap: 14px; background: #fff0ee; color: var(--error); border: 1px solid #f8d0ca; border-radius: 6px; margin-bottom: 11px; padding: 10px 13px; max-height: 135px; overflow-y: auto; }
.operation-error p { flex: 1; margin: 0; font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
.operation-error button { flex-shrink: 0; color: var(--error); }
.icon-button { border: 0; background: transparent; color: var(--coral); font-size: 22px; width: 40px; height: 42px; border-radius: 6px; }
.mobile-menu { display: none; }
.scrim { display: none; }
noscript { position: fixed; inset: 30% 10% auto; background: var(--paper); padding: 30px; border: 1px solid var(--coral); z-index: 100; }

/* Stage bar + draft cards */
.stage-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 32px; background: var(--grad-soft); border-bottom: 1px solid var(--line); font-size: 13px; }
.stage { padding: 4px 12px; border-radius: 999px; color: var(--muted); background: #ffffffb3; }
.stage.is-done { color: var(--coral-deep); background: #fff; }
.stage.is-current { color: #fff; background: var(--coral); font-weight: 600; box-shadow: 0 2px 8px #fe6f6040; }
.stage-hint { margin-left: 8px; color: #b0632e; }
.draft-card { margin-top: 12px; border: 1px solid #f6dcd2; border-left: 4px solid var(--coral); border-radius: 6px; background: #fffaf7; padding: 12px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.draft-card-head { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; flex: 1 1 100%; }
.draft-card-head span { color: var(--muted); font-size: 12px; }
.draft-card-body { margin: 6px 0 2px; flex: 1 1 100%; }
.draft-card-body summary { cursor: pointer; color: var(--coral-deep); font-size: 13px; }
.draft-card-body p { max-height: 420px; overflow: auto; font-size: 13px; line-height: 1.7; margin: 8px 0 0; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 12px; }
.office-link { display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: 4px; font-size: 13px; text-decoration: none; border: 1px solid var(--coral); color: var(--coral-deep); background: #fff; }
.office-link:hover { background: var(--coral); color: #fff; }
.office-link.is-primary { background: var(--coral); color: #fff; }
.office-options { display: flex; flex-direction: column; gap: 6px; width: 100%; margin-top: 6px; }
.office-options-label { font-size: 12px; color: var(--muted); }
.office-option { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-radius: 10px; background: var(--cream); }
.office-option-name { flex: 1; min-width: 0; display: flex; gap: 8px; align-items: baseline; font-size: 13px; color: var(--ink); }
.office-option-name span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) { .office-option { flex-wrap: wrap; } .office-option-name { flex-basis: 100%; } }
.office-link.is-primary:hover { background: var(--coral-deep); }

@media (min-width: 1500px) {
  .app-shell { grid-template-columns: 288px minmax(0, 1fr); }
  .sidebar { padding-inline: 24px; }
  .conversation-width { max-width: 900px; }
  .composer-width { max-width: 840px; }
}
@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 232px minmax(0, 1fr); }
  .sidebar { padding-inline: 14px; }
  .brand img { width: 118px; }
  .topbar { padding-inline: 22px; }
  .assistant-identity h1 > span { display: none; }
  .conversation-width { padding-inline: 26px; }
  .composer-area { padding-inline: 26px; }
  .starters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .starters button { padding: 14px; }
  .welcome-hero { padding: 24px 26px; }
}
@media (max-width: 760px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: min(300px, 85vw); padding: 22px 18px 20px; visibility: hidden; transform: translateX(-100%); transition: transform .2s, visibility .2s; }
  .sidebar-open .sidebar { visibility: visible; transform: translateX(0); }
  .scrim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 35; border: 0; background: #32190866; }
  .mobile-menu { display: block; flex-shrink: 0; }
  .topbar { min-height: 60px; padding: 8px 14px 8px 6px; gap: 7px; }
  .assistant-identity { gap: 9px; flex: 1; }
  .small-avatar { width: 32px; height: 32px; font-size: 14px; }
  .assistant-identity h1 { font-size: 16px; }
  .assistant-identity p { max-width: 160px; font-size: 11px; }
  .connection { flex-direction: column; align-items: flex-end; gap: 2px; }
  .connection-badge { font-size: 11px; }
  .connection .text-button { font-size: 11px; padding: 4px 2px; }
  .connection-notice { padding: 8px 18px; font-size: 11px; }
  .stage-bar { padding: 8px 14px; font-size: 12px; }
  .stage-hint { width: 100%; margin: 2px 0 0; }
  .conversation-width { padding: 0 16px 18px; }
  .welcome { padding-top: 18px; }
  .welcome-hero { padding: 20px; gap: 14px; border-radius: 8px; margin-bottom: 18px; }
  .welcome-hero h2 { font-size: 20px; }
  .welcome-hero h2 br { display: none; }
  .welcome-mark { width: 60px; height: 60px; border-width: 3px; }
  .welcome-mark img { width: 38px; }
  .eyebrow { font-size: 10px; letter-spacing: 1.2px; }
  .welcome-copy { font-size: 14px; }
  .starters { grid-template-columns: 1fr; }
  .starters button { min-height: 0; padding: 13px 15px 13px 50px; position: relative; }
  .starters button > span { position: absolute; left: 16px; top: 14px; margin: 0; }
  .starters strong { font-size: 15px; }
  .starters small { margin-top: 2px; }
  .message { gap: 8px; margin-bottom: 20px; }
  .message-avatar { width: 28px; height: 28px; font-size: 12px; }
  .message-user { padding-left: 28px; }
  .message-user .message-body { padding: 11px 15px 8px; }
  .message-assistant .message-body { padding: 12px 14px 9px; }
  .sending { margin-left: 36px; }
  .case-materials { margin-left: 0; padding-inline: 14px; }
  .composer-area { padding: 8px 12px max(12px, env(safe-area-inset-bottom)); }
  .composer-form { padding: 11px 11px 9px; border-radius: 8px; }
  .composer-form textarea { font-size: 16px; min-height: 46px; max-height: 130px; }
  .composer-tools { gap: 6px; }
  .upload-button { min-height: 40px; }
  .send-button { min-width: 76px; }
  .composer-state { font-size: 10px; }
  .composer-help > span:first-child { display: none; }
  .composer-help > span:last-child { margin-inline: auto; font-size: 10px; }
  .review-note { font-size: 10px; margin-top: 4px; }
  .operation-error p { font-size: 11px; }
}
@media (max-width: 370px) {
  .conversation-width { padding-inline: 12px; }
  .welcome-mark { display: none; }
  .assistant-identity p { max-width: 110px; }
  .small-avatar { display: none; }
  .composer-state { max-width: 105px; }
}
@media (max-height: 720px) and (min-width: 761px) {
  .welcome { padding-top: 20px; }
  .welcome-hero { padding: 22px 28px; margin-bottom: 18px; }
  .welcome-mark { width: 66px; height: 66px; }
  .welcome-mark img { width: 44px; }
  .starters button { min-height: 92px; padding: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

.sidebar-footer form { margin-left: auto; }
.sidebar-footer form button { border: 1px solid rgba(255,255,255,.55); background: transparent; color: inherit; border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.sidebar-footer form button:hover { background: rgba(255,255,255,.18); }
.login-page { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 10%, #fde3df 0, transparent 45%), radial-gradient(circle at 90% 90%, #fcebcf 0, transparent 40%), var(--cream); }
.login-card { width: min(380px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-soft); padding: 34px 30px 28px; }
.login-card img { display: block; width: 128px; height: auto; margin: 0 auto 22px; }
.login-card h1 { margin: 0 0 4px; font-size: 20px; text-align: center; color: var(--ink); }
.login-card > p { margin: 0 0 22px; text-align: center; color: var(--muted); font-size: 13px; }
.login-card label { display: block; margin: 0 0 14px; font-size: 13px; font-weight: 600; color: var(--ink); }
.login-card input { display: block; width: 100%; margin-top: 6px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; font: inherit; font-size: 15px; background: var(--cream); color: var(--ink); }
.login-card input:focus { outline: 2px solid var(--coral); outline-offset: 1px; background: #fff; }
.login-card button { width: 100%; margin-top: 8px; padding: 12px; border: 0; border-radius: 12px; background: var(--grad); color: #fff; font: inherit; font-size: 15px; font-weight: 700; cursor: pointer; }
.login-error { margin: 0 0 16px; padding: 9px 12px; border-radius: 10px; background: #fde3df; color: var(--coral-deep); font-size: 13px; text-align: center; }
.composer textarea:disabled, #composer:disabled { cursor: not-allowed; opacity: .55; }
.file-use { flex: none; border: 1px solid var(--line); background: #fff; color: var(--coral); border-radius: 999px; padding: 4px 11px; font-size: 12px; cursor: pointer; }
.file-use:hover:not(:disabled) { border-color: var(--coral); }
.file-use.is-chosen { background: var(--coral); border-color: var(--coral); color: #fff; }
.file-use:disabled { opacity: .5; cursor: not-allowed; }
.composer-refs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.ref-chip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--cream); border: 1px solid var(--line); font-size: 12px; color: var(--ink); }
.ref-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.ref-chip-remove { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; padding: 2px 6px; border-radius: 50%; }
.ref-chip-remove:hover:not(:disabled) { color: var(--coral); }
.stage-actions { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.stage-action { border: 1px solid var(--coral); background: #fff; color: var(--coral-deep); border-radius: 999px; padding: 4px 12px; font-size: 12px; cursor: pointer; }
.stage-action.is-soft { border-color: var(--line); color: var(--muted); }
.stage-action:hover:not(:disabled) { background: var(--cream); }
.stage-action:disabled { opacity: .5; cursor: not-allowed; }
@media (max-width: 760px) { .stage-actions { margin-left: 0; width: 100%; } }
.line-starters button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--coral), var(--shadow); transform: translateY(-2px); }
.line-pill { display: flex; align-items: center; gap: 4px; width: fit-content; margin: 0 0 8px; padding: 3px 4px 3px 12px; border-radius: 999px; background: var(--coral-soft); border: 1px solid #fbd3cc; color: var(--coral-deep); font-size: 12px; }
.line-pill[hidden] { display: none; }
.line-pill select, .line-select { border: 0; background: transparent; color: inherit; font: inherit; font-weight: 600; cursor: pointer; padding: 2px 4px; border-radius: 999px; }
.line-pill select:focus-visible, .line-select:focus-visible { outline: 2px solid var(--coral); }
.line-select { color: var(--coral-deep); font-size: 13px; background: var(--coral-soft); padding: 2px 8px; }
.summary-line { grid-column: 1 / -1; }
.line-tag { display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: 4px; font-size: 10px; font-weight: 600; line-height: 17px; vertical-align: 1px; color: #fff; background: #5aa9a0; }
.line-tag.is-fund { background: #8f7ad6; }

/* ===== 供應商名冊 (supplier directory) — ported from the approved mockups ===== */
.ico { width: 14px; height: 14px; display: inline-block; vertical-align: -2px; flex-shrink: 0; }
.segmented { display: grid; grid-template-columns: 1fr 1fr 1fr; padding: 3px; background: #f6ece6; border-radius: 9px; margin: 0 0 14px; }
.segmented button { border: 0; background: transparent; padding: 7px 0; font-size: 13px; color: #7a6458; border-radius: 7px; font-weight: 500; letter-spacing: .5px; }
.segmented button[aria-selected="true"] { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px #3219081f, 0 0 0 .5px #3219080d; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 6px; padding: 8px 14px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.btn > b { font-weight: 400; color: var(--coral); font-size: 15px; line-height: 1; }
.btn:hover:not(:disabled) { border-color: var(--coral); }
.btn.primary { background: var(--coral); border-color: var(--coral); color: #fff; font-weight: 600; letter-spacing: .5px; }
.btn.primary > b { color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--coral-deep); }
.btn.small { padding: 5px 11px; font-size: 12px; }
.supplier-view { display: flex; flex-direction: column; min-width: 0; min-height: 0; flex: 1; }
.page-head { min-height: 64px; padding: 12px 28px; background: var(--paper); box-shadow: var(--shadow-soft); display: flex; align-items: center; gap: 14px; flex-shrink: 0; position: relative; z-index: 1; }
.page-title { flex: 1; min-width: 0; }
.page-title h1 { margin: 0; font-size: 19px; font-weight: 700; display: flex; align-items: center; gap: 10px; letter-spacing: .5px; }
.page-title h1 .count { font-size: 12px; font-weight: 500; background: var(--coral-soft); color: var(--coral-deep); border-radius: 999px; padding: 1px 9px; letter-spacing: 0; }
.page-title p { margin: 3px 0 0; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.page-actions { display: flex; gap: 8px; }
.sup-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.sup-body.has-detail { grid-template-columns: minmax(0, 1fr) 500px; }
.sup-list-col { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.toolbar { padding: 16px 28px 0; display: flex; flex-direction: column; gap: 12px; }
.toolbar-row { display: flex; gap: 10px; align-items: center; }
.toolbar .search, .pick-search .search { margin: 0; flex: 1; background: #fff; max-width: 420px; }
.toolbar .search input { padding: 9px 2px; }
.select { position: relative; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 0 12px; font-size: 13px; color: var(--ink); white-space: nowrap; }
.select > span { color: var(--muted); }
.select select { border: 0; background: transparent; color: var(--ink); padding: 8px 18px 8px 0; appearance: none; -webkit-appearance: none; cursor: pointer; outline: none; max-width: 150px; }
.select::after { content: '⌄'; position: absolute; right: 11px; top: 50%; transform: translateY(-62%); color: var(--muted); font-size: 13px; pointer-events: none; }
.select:focus-within { border-color: var(--coral); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { border: 1px solid var(--line); background: #fff; color: #5e4a3e; border-radius: 999px; padding: 4px 12px; font-size: 13px; white-space: nowrap; }
.chip:hover { border-color: #f0c9bf; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.pending { border-color: #f3d9b4; background: var(--amber-bg); color: var(--amber); }
.chip.pending[aria-pressed="true"] { background: var(--amber); border-color: var(--amber); color: #fff; }
.chip.pending i { font-style: normal; font-variant-numeric: tabular-nums; margin-left: 5px; opacity: .85; color: inherit; }
.chip-sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.notice-bar { margin: 14px 28px 0; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 8px; background: var(--amber-bg); border: 1px solid #f6e0c2; color: #7a5326; font-size: 13px; }
.notice-bar p { margin: 0; flex: 1; line-height: 1.6; }
.notice-bar strong { font-weight: 600; }
.notice-bar .btn { background: #fff; border-color: #efd3ad; color: var(--amber); }
.review-tip { margin: 12px 28px 0; font-size: 12px; color: var(--muted); }
.list-scroll { flex: 1; overflow: auto; padding: 14px 28px 28px; min-height: 0; scrollbar-width: thin; scrollbar-color: #f0d8cf transparent; }
.sup-table { background: #fff; border: 1px solid #f6ece6; border-radius: 10px; box-shadow: var(--shadow-soft); overflow: hidden; }
.sup-row { display: grid; grid-template-columns: minmax(0, 2.3fr) 92px minmax(0, 1fr) minmax(0, 1fr) 96px 52px; align-items: center; gap: 14px; padding: 11px 18px; border-bottom: 1px solid #f5ebe5; font-size: 13px; cursor: pointer; }
.sup-row:last-child { border-bottom: 0; }
.sup-row.head { padding-block: 9px; font-size: 11px; color: var(--muted); background: #fdf9f6; letter-spacing: .5px; cursor: default; }
.sup-row:not(.head):hover { background: #fffaf7; }
.sup-row:focus-visible { outline: 2px solid var(--coral); outline-offset: -2px; }
.sup-row.is-active { background: var(--grad-soft); box-shadow: inset 3px 0 0 var(--coral); }
.sup-table.review .sup-row { grid-template-columns: minmax(0, 2.3fr) 92px minmax(0, 1fr) minmax(0, .8fr) 92px 128px; }
.has-detail .sup-row { grid-template-columns: minmax(0, 1fr) 84px 86px; gap: 10px; padding: 11px 16px; }
.has-detail .toolbar, .has-detail .list-scroll { padding-inline: 20px; }
.has-detail .notice-bar, .has-detail .review-tip { margin-inline: 20px; }
.has-detail .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.sup-name { min-width: 0; }
.sup-name strong { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; }
.sup-name strong > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.sup-name small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sup-row > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.cell-r { text-align: right; }
.badge { display: inline-block; flex-shrink: 0; font-size: 11px; font-weight: 500; padding: 1px 8px; border-radius: 999px; background: var(--amber-bg); color: var(--amber); border: 1px solid #f6e0c2; letter-spacing: .3px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 10px 2px 8px; border-radius: 999px; background: #f8f0eb; color: #5e4a3e; white-space: nowrap; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--dot, #c8b8ae); }
.c-地接 { --dot: #fe6f60; } .c-酒店 { --dot: #f0b878; } .c-旅遊巴 { --dot: #4cc38a; } .c-餐飲 { --dot: #e8935a; } .c-景點門票 { --dot: #a58bd6; }
.c-課程 { --dot: #5aa0c8; } .c-機票 { --dot: #6c8ebf; } .c-保險 { --dot: #9aa0a6; } .c-其他 { --dot: #c8b8ae; }
.row-acts { display: flex; gap: 6px; justify-content: flex-end; }
.mini { border: 1px solid var(--line); background: #fff; color: #7a6458; border-radius: 999px; padding: 3px 11px; font-size: 12px; }
.mini:hover:not(:disabled) { border-color: #e0cfc5; }
.mini.ok { border-color: var(--coral); color: var(--coral-deep); }
.mini.ok:hover:not(:disabled) { background: var(--coral); color: #fff; }
.list-foot { text-align: center; font-size: 12px; color: #b3a49b; padding: 14px 0 0; margin: 0; }
.m-card { display: none; }
.empty { display: grid; place-items: center; text-align: center; padding: 70px 20px; }
.empty-mark { width: 64px; height: 64px; border-radius: 18px; background: var(--grad-soft); display: grid; place-items: center; color: var(--coral-deep); font-size: 28px; margin: 0 auto 18px; }
.empty h2 { margin: 0 0 8px; font-size: 18px; }
.empty p { margin: 0 auto 20px; color: var(--muted); font-size: 14px; line-height: 1.8; max-width: 380px; }
.empty .row { display: flex; gap: 10px; justify-content: center; }
.empty .btn { padding: 10px 18px; font-size: 14px; }

/* Detail panel */
.detail { background: #fff; border-left: 1px solid var(--line); box-shadow: -4px 0 18px #3219080a; overflow: auto; min-height: 0; display: flex; flex-direction: column; scrollbar-width: thin; scrollbar-color: #f0d8cf transparent; }
.m-nav { display: none; }
.detail-head { padding: 18px 24px 14px; display: flex; gap: 12px; align-items: flex-start; }
.detail-head > div { flex: 1; min-width: 0; }
.detail-head h2 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: .5px; overflow-wrap: anywhere; }
.detail-head .alias { margin: 3px 0 10px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: #5e4a3e; }
.meta .dot { color: #d6c6bc; }
.close-x { border: 0; background: #f8f0eb; color: var(--muted); width: 28px; height: 28px; border-radius: 50%; font-size: 15px; line-height: 1; display: grid; place-items: center; flex-shrink: 0; }
.internal { margin: 0 24px; padding: 8px 12px; border-radius: 8px; background: #f8f4f1; color: #6b5a50; font-size: 12px; display: flex; gap: 8px; align-items: center; }
.confirm-card { margin: 12px 24px 0; padding: 12px 14px; border-radius: 10px; background: var(--amber-bg); border: 1px solid #f6e0c2; display: flex; align-items: center; gap: 10px; font-size: 13px; color: #7a5326; }
.confirm-card p { margin: 0; flex: 1; line-height: 1.6; }
.confirm-card p small { display: block; font-size: 12px; color: #a07a4e; }
.confirm-card .btn.primary { padding: 7px 18px; }
.review-notes { margin: 6px 0 0; padding-left: 16px; font-size: 12px; color: #a07a4e; line-height: 1.6; }
.detail-body { padding: 4px 24px 24px; }
.sec { margin-top: 22px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 2px 8px; }
.sec-head h3 { margin: 0; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 1px; }
.sec-head .text-button { padding: 0; font-size: 12px; }
.group { border: 1px solid #f3e8e1; border-radius: 10px; background: #fff; overflow: hidden; }
.group-empty { padding: 12px 14px; font-size: 12px; color: var(--muted); margin: 0; }
.contact { padding: 11px 14px; border-bottom: 1px solid #f5ebe5; }
.contact:last-child { border-bottom: 0; }
.contact-name { font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.contact-name span { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 8px; }
.cfields { display: flex; flex-wrap: wrap; gap: 3px 16px; font-size: 13px; line-height: 1.6; }
.cfields i { font-style: normal; color: var(--muted); font-size: 12px; margin-right: 6px; }
.cfields a { color: var(--coral-deep); text-decoration: none; }
.field-row { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 10px; padding: 10px 14px; border-bottom: 1px solid #f5ebe5; font-size: 13px; line-height: 1.65; }
.field-row:last-child { border-bottom: 0; }
.field-row > span:first-child { color: var(--muted); font-size: 12px; line-height: 1.85; }
.field-row > span:last-child { white-space: pre-wrap; overflow-wrap: anywhere; }
.price-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.price-table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 11px; padding: 8px 6px; background: #fdf9f6; border-bottom: 1px solid #f3e8e1; white-space: nowrap; }
.price-table td { padding: 9px 6px; border-bottom: 1px solid #f5ebe5; vertical-align: top; line-height: 1.5; }
.price-table tr:last-child td { border-bottom: 0; }
.price-table th:first-child, .price-table td:first-child { padding-left: 12px; }
.price-table th:last-child, .price-table td:last-child { padding-right: 12px; }
.price-table .amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.price-table td small { display: block; }
.price-table td:nth-child(3), .price-table td:nth-child(4), .price-table td:nth-child(6) { white-space: nowrap; }
.price-table td:nth-child(6) .price-del { margin-left: 4px; }
.price-del { border: 0; background: transparent; color: #c8b8ae; font-size: 14px; padding: 0 2px; margin-left: 4px; line-height: 1; vertical-align: 0; }
.price-del:hover { color: var(--error); }
.src { display: inline-block; font-size: 11px; color: var(--coral-deep); border: 1px solid #f6d6cd; border-radius: 4px; padding: 0 5px; white-space: nowrap; text-decoration: none; max-width: 120px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.src.manual { color: var(--muted); border-color: var(--line); }
.expired td, .expired td small { color: #b3a49b; }
.expired .amt { font-weight: 500; }
.hist { display: grid; grid-template-columns: 82px minmax(0, 1fr) auto 28px; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid #f5ebe5; font-size: 13px; }
.hist:last-child { border-bottom: 0; }
.hist > span:nth-child(2) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist .date { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.hist .amt { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; white-space: nowrap; }
.hist .amt small { font-weight: 400; color: var(--muted); font-size: 11px; }
.hist .file { color: var(--coral); text-align: right; font-size: 15px; text-decoration: none; }
.mprice { display: none; }
.detail-foot { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12px; color: #b3a49b; }
.danger-link { border: 0; background: transparent; color: var(--error); font-size: 13px; padding: 4px 0; }
.danger-link:hover { text-decoration: underline; }

/* Sheets (new/edit, add price, import, picker) */
.overlay { position: fixed; inset: 0; background: #3219085c; z-index: 50; display: grid; place-items: center; padding: 28px; }
.sheet { width: min(580px, 100%); max-height: calc(100vh - 56px); max-height: calc(100dvh - 56px); background: #fff; border-radius: 14px; box-shadow: var(--sheet-shadow); display: flex; flex-direction: column; overflow: hidden; }
.sheet.wide { width: min(860px, 100%); }
.sheet-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 14px 18px; border-bottom: 1px solid #f3e8e1; }
.sheet-nav h2 { margin: 0; font-size: 16px; font-weight: 600; text-align: center; }
.sheet-nav h2 small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 2px; }
.sheet-nav .left { justify-self: start; }
.sheet-nav .right { justify-self: end; }
.nav-btn { border: 0; background: transparent; color: var(--coral-deep); font-size: 14px; padding: 4px 2px; }
.nav-btn.strong { font-weight: 600; }
.nav-btn:disabled { color: #d9c9bf; opacity: 1; }
.sheet-body { overflow: auto; padding: 6px 22px 22px; background: #fdf9f6; flex: 1; min-height: 0; }
.sheet-foot { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-top: 1px solid #f3e8e1; background: #fff; }
.sheet-foot .grow { flex: 1; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sheet-error { margin: 12px 0 0; padding: 9px 12px; border-radius: 8px; background: #fff0ee; color: var(--error); border: 1px solid #f8d0ca; font-size: 12px; line-height: 1.7; }
.form-label { margin: 18px 4px 7px; font-size: 12px; color: var(--muted); letter-spacing: .5px; display: flex; justify-content: space-between; }
.form-label em { font-style: normal; color: var(--coral-deep); font-size: 11px; }
.form-label em.soft { color: var(--muted); }
.form-label i { font-style: normal; color: var(--coral); margin-left: 2px; }
.fgroup { background: #fff; border: 1px solid #f1e4dc; border-radius: 10px; overflow: hidden; }
.fgroup + .fgroup { margin-top: 8px; }
.frow { display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: center; min-height: 44px; padding: 0 14px; border-bottom: 1px solid #f5ebe5; font-size: 14px; }
.frow:last-child { border-bottom: 0; }
.frow > label { color: var(--ink); font-size: 14px; }
.frow > label i { font-style: normal; color: var(--coral); margin-left: 2px; }
.frow input, .frow select, .frow textarea { width: 100%; min-width: 0; border: 0; outline: none; background: transparent; color: var(--ink); font-size: 14px; padding: 11px 0; }
.frow input::placeholder, .frow textarea::placeholder { color: #c0b1a8; }
.frow textarea { resize: vertical; min-height: 64px; line-height: 1.6; }
.frow.top { align-items: start; }
.frow.top > label { padding-top: 11px; }
.frow:focus-within { box-shadow: inset 0 0 0 1.5px var(--coral); border-radius: 10px; }
.frow select { appearance: none; -webkit-appearance: none; cursor: pointer; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='12'%3E%3Cpath d='M1.5 1.5 6 6l-4.5 4.5' fill='none' stroke='%23c8b8ae' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 2px center; }
.contact-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px 0; font-size: 12px; color: var(--muted); }
.contact-head button { border: 0; background: transparent; color: var(--error); font-size: 12px; padding: 0; }
.cat-pick { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px; }
.cat-pick .chip[aria-pressed="true"] { background: var(--coral); border-color: var(--coral); color: #fff; }
.form-hint { font-size: 12px; color: var(--muted); margin: 7px 4px 0; line-height: 1.6; display: flex; align-items: center; gap: 6px; }
.add-row { display: flex; align-items: center; gap: 8px; color: var(--coral-deep); font-size: 14px; padding: 12px 14px; border: 0; background: transparent; width: 100%; text-align: left; }
.add-row b { width: 20px; height: 20px; border-radius: 50%; background: var(--coral); color: #fff; display: grid; place-items: center; font-size: 14px; font-weight: 400; }
.add-row:hover { background: #fffaf7; }

/* Picker 揀地接 */
.pick-search { margin: 14px 0 4px; }
.pick-search .search { max-width: none; }
.pick-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 14px; border: 0; border-bottom: 1px solid #f5ebe5; background: #fff; width: 100%; text-align: left; color: var(--ink); }
.pick-row:last-child { border-bottom: 0; }
.pick-row:hover { background: #fffaf7; }
.pick-row[aria-checked="true"] { background: #fff7f4; }
.radio { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid #dccbc1; display: grid; place-items: center; flex-shrink: 0; }
[aria-checked="true"] > .radio, .is-on > .radio { border-color: var(--coral); background: var(--coral); }
[aria-checked="true"] > .radio::after, .is-on > .radio::after { content: ''; width: 7px; height: 7px; background: #fff; border-radius: 50%; }
.pick-row strong { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.pick-row strong > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-row small { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-price { text-align: right; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pick-price small { font-weight: 400; display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.pick-tag { font-size: 11px; color: var(--coral-deep); background: var(--coral-soft); border-radius: 999px; padding: 1px 8px; font-weight: 500; flex-shrink: 0; }
.pick-more { border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 10px 14px; width: 100%; }
.stage-action.is-key { background: var(--coral); color: #fff; font-weight: 600; box-shadow: 0 2px 8px #fe6f6033; }
.stage-action.is-key:hover:not(:disabled) { background: var(--coral-deep); }
.case-chip { display: inline-flex; align-items: center; margin-left: 8px; padding: 3px 6px 3px 11px; border-radius: 999px; background: #fff; border: 1px solid #f3c8bf; font-size: 12px; color: var(--ink); max-width: 260px; }
.case-chip:hover:not(:disabled) { border-color: var(--coral); }
.case-chip > span { color: var(--muted); flex-shrink: 0; }
.case-chip b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-chip i { font-style: normal; color: var(--muted); padding: 0 2px 0 6px; }
.switch-line { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: #5e4a3e; border: 0; background: transparent; padding: 4px 2px; }
.switch { width: 34px; height: 20px; border-radius: 999px; background: #e7dbd3; position: relative; flex-shrink: 0; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #0003; transition: left .15s; }
.switch-line[aria-checked="true"] .switch { background: #4cc38a; }
.switch-line[aria-checked="true"] .switch::after { left: 16px; }

/* Import review */
.imp { display: grid; grid-template-columns: 250px minmax(0, 1fr); flex: 1; min-height: 0; }
.imp-file { background: #f8f2ee; padding: 18px; border-right: 1px solid #f1e4dc; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.imp-file .fname { font-size: 12px; color: var(--ink); display: flex; gap: 8px; align-items: center; overflow-wrap: anywhere; }
.imp-file .fname > span { color: var(--coral); font-size: 18px; }
.imp-file .fname small { display: block; color: var(--muted); font-size: 11px; }
.paper { background: #fff; border-radius: 6px; box-shadow: 0 2px 10px #32190814; padding: 14px 14px 18px; font-size: 11px; line-height: 1.75; color: #6b5a50; overflow: auto; min-height: 0; flex: 1; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; }
.paper mark { background: #fff1c9; color: inherit; border-radius: 2px; }
.imp-body { overflow: auto; padding: 4px 22px 18px; background: #fdf9f6; min-height: 0; }
.imp-drop { padding: 30px 22px; display: grid; place-items: center; text-align: center; gap: 12px; }
.imp-drop p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.8; }
.imp-drop .busy { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 14px; }
.match { margin-top: 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.match button { display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px; background: #fff; border: 1px solid #f1e4dc; border-radius: 10px; font-size: 13px; text-align: left; color: var(--ink); }
.match button[aria-checked="true"] { border-color: var(--coral); box-shadow: 0 0 0 3px #fe6f6014; }
.match button:disabled { opacity: .5; }
.match .radio { margin-top: 1px; }
.match strong { display: block; font-weight: 600; }
.match small { color: var(--muted); font-size: 12px; }
.check { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid #dccbc1; display: inline-grid; place-items: center; font-size: 11px; color: #fff; vertical-align: middle; background: #fff; padding: 0; }
.check[aria-checked="true"] { background: var(--coral); border-color: var(--coral); }
.check[aria-checked="true"]::after { content: '✓'; }
.price-table.edit td { padding-block: 6px; vertical-align: middle; }
.price-table.edit input, .price-table.edit select { border: 1px solid #efe3db; border-radius: 5px; padding: 3px 7px; background: #fff; color: var(--ink); font-size: 13px; width: 100%; min-width: 0; outline: none; }
.price-table.edit input:focus, .price-table.edit select:focus { border-color: var(--coral); }
.price-table.edit .amt input { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.price-table.edit tr.off input, .price-table.edit tr.off select { color: #b3a49b; }
.warn-note { font-size: 12px; color: var(--amber); margin: 8px 4px 0; line-height: 1.6; }
.thinking-dot.inline { display: inline-block; flex-shrink: 0; }

@media (max-width: 1180px) and (min-width: 761px) {
  .sup-body.has-detail { grid-template-columns: minmax(0, 1fr) 440px; }
  .sup-row { grid-template-columns: minmax(0, 2fr) 92px minmax(0, 1fr) 96px 44px; }
  .sup-row > .col-contact { display: none; }
  .sup-table.review .sup-row { grid-template-columns: minmax(0, 2fr) 92px minmax(0, 1fr) 92px 128px; }
}
@media (max-width: 760px) {
  .segmented { margin-bottom: 12px; }
  .page-head { padding: 8px 10px 8px 6px; min-height: 56px; gap: 4px; }
  .page-title h1 { font-size: 18px; }
  .page-title p { display: none; }
  .page-actions .btn { padding: 7px 10px; }
  .page-actions .btn .lbl { display: none; }
  .page-actions .btn.primary .lbl { display: inline; }
  .toolbar { padding: 12px 14px 0; gap: 10px; }
  .toolbar .search { max-width: none; }
  .select select { max-width: 90px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin-right: -14px; padding-right: 14px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .notice-bar { margin: 12px 14px 0; font-size: 12px; padding: 9px 12px; }
  .review-tip { margin: 10px 14px 0; }
  .list-scroll { padding: 12px 14px 20px; }
  .sup-table { display: none; }
  .m-card { display: block; width: 100%; text-align: left; color: var(--ink); background: #fff; border: 1px solid #f6ece6; border-radius: 10px; box-shadow: var(--shadow-soft); padding: 12px 14px; margin-bottom: 8px; }
  .m-card .top { display: flex; align-items: center; gap: 8px; }
  .m-card .top strong { font-size: 15px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .m-card .mid { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: 13px; color: #5e4a3e; min-width: 0; }
  .m-card .mid > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .m-card .bot { margin-top: 6px; font-size: 12px; color: var(--muted); }
  .m-card .row-acts { margin-top: 10px; }
  .sup-body.has-detail { grid-template-columns: minmax(0, 1fr); }
  .sup-body.has-detail .sup-list-col { display: none; }
  .supplier-view.has-detail .page-head { display: none; }
  .detail { border-left: 0; box-shadow: none; }
  .m-nav { height: 52px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 12px; background: #fff; border-bottom: 1px solid #f3e8e1; flex-shrink: 0; position: sticky; top: 0; z-index: 2; }
  .m-nav .back { color: var(--coral-deep); font-size: 15px; justify-self: start; border: 0; background: transparent; padding: 4px 0; }
  .m-nav .back b { font-size: 22px; font-weight: 300; vertical-align: -2px; margin-right: 2px; }
  .m-nav .right { justify-self: end; }
  .detail-head { padding: 16px 16px 12px; }
  .detail-head .btn, .detail-head .close-x { display: none; }
  .internal { margin: 0 16px; }
  .confirm-card { margin: 12px 16px 0; }
  .detail-body { padding: 0 16px 24px; }
  .price-table { display: none; }
  .mprice { display: flex; gap: 12px; align-items: flex-start; padding: 11px 14px; border-bottom: 1px solid #f5ebe5; }
  .mprice:last-child { border-bottom: 0; }
  .mprice > div:first-child { flex: 1; min-width: 0; }
  .mprice strong { display: block; font-size: 14px; font-weight: 500; }
  .mprice small { font-size: 12px; color: var(--muted); }
  .mprice > div:first-child small { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 3px; }
  .mprice .amt { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 14px; }
  .mprice .amt small { font-weight: 400; font-size: 11px; }
  .mprice .amt .u { display: block; margin-top: 2px; }
  .mprice.expired strong, .mprice.expired .amt { color: #b3a49b; font-weight: 500; }
  .hist { display: none; }
  .cfields { flex-direction: column; }
  .overlay { padding: 0; place-items: end stretch; }
  .sheet, .sheet.wide { width: 100%; max-height: 94vh; max-height: 94dvh; border-radius: 14px 14px 0 0; }
  .sheet-body { padding: 4px 14px 18px; }
  .frow { grid-template-columns: 84px minmax(0, 1fr); }
  .frow input, .frow select, .frow textarea { font-size: 16px; }
  .imp { grid-template-columns: minmax(0, 1fr); overflow: auto; }
  .imp-file { border-right: 0; border-bottom: 1px solid #f1e4dc; max-height: 220px; }
  .imp-body { overflow: visible; padding-inline: 14px; }
  .match { grid-template-columns: 1fr; }
  .price-table.edit { display: table; }
  .price-table.edit th:nth-child(6), .price-table.edit td:nth-child(6) { display: none; }
  .case-chip { margin-left: 0; max-width: 100%; }
}
.case-view { display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; }
.m-only { display: none; }
body.sheet-open { overflow: hidden; }
@media (max-width: 760px) { .d-only { display: none; } .m-only { display: inline; } }

/* ===== 資料庫 (document library) + 依據 (citations) ===== */
.small { font-size: 12px; }
a.btn { text-decoration: none; }
.btn.center { display: flex; margin: 14px auto 0; }
.accent { color: var(--coral-deep); }
.grow { flex: 1; }

.fmt { display: inline-grid; place-items: center; width: 34px; height: 20px; border-radius: 4px; font-size: 9.5px; font-weight: 700; letter-spacing: .4px; color: #fff; flex-shrink: 0; background: #b9aaa0; }
.f-pdf { background: #e2574c; } .f-docx, .f-doc { background: #4a7cc7; } .f-xlsx, .f-xls { background: #3f9b6a; } .f-pptx, .f-ppt { background: #e08a3c; }
.fmt.faded { opacity: .4; }
.t-sq { --dot: #fe6f60; } .t-it { --dot: #5aa0c8; } .t-cq { --dot: #f0b878; } .t-sc { --dot: #a58bd6; } .t-iv { --dot: #9aa0a6; } .t-pr { --dot: #4cc38a; }
.t-ct { --dot: #6c8ebf; } .t-cs { --dot: #e8935a; } .t-rf { --dot: #c8b8ae; } .t-ts { --dot: #8f7ad6; } .t-pt { --dot: #5aa9a0; } .t-cr { --dot: #d98aa8; } .t-lt { --dot: #b0a27a; }

.chip i { font-style: normal; font-size: 11px; color: #b3a49b; margin-left: 5px; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] i { color: #ffffffa6; }
.chip.more { color: var(--muted); }
.chip.pending[aria-pressed="true"] i { color: inherit; }
.chip.pics { display: inline-flex; align-items: center; gap: 5px; }
.toolbar-row > .chip.pics { padding-block: 7px; }
.pic-badge { display: inline-flex; align-items: center; gap: 3px; margin-left: 8px; padding: 1px 6px; border-radius: 999px; background: #f6efe9; color: var(--muted); font-size: 11px; font-weight: 500; vertical-align: 1px; font-variant-numeric: tabular-nums; }
.pic-badge .ico { width: 12px; height: 12px; }
.toolbar-row > .chip.pending { padding-block: 7px; }

/* list */
.lib-body.has-detail { grid-template-columns: minmax(0, 1fr) 540px; }
.doc-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) 104px 128px 84px 54px; align-items: center; gap: 14px; padding: 11px 18px; border-bottom: 1px solid #f5ebe5; font-size: 13px; cursor: pointer; }
.doc-row:last-child { border-bottom: 0; }
.doc-row.head { padding-block: 9px; font-size: 11px; color: var(--muted); background: #fdf9f6; letter-spacing: .5px; cursor: default; }
.doc-row:not(.head):hover { background: #fffaf7; }
.doc-row:focus-visible, .m-card.doc:focus-visible { outline: 2px solid var(--coral); outline-offset: -2px; }
.doc-row.is-active { background: var(--grad-soft); box-shadow: inset 3px 0 0 var(--coral); }
.doc-row > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-name { min-width: 0; }
.doc-name strong { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-name small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-name small.snip { color: #5e4a3e; }
.doc-name mark, .m-card.doc mark, .md mark { background: #ffe9b8; color: inherit; border-radius: 2px; padding: 0 1px; }
.noread { color: var(--amber) !important; }
.cited { display: inline-block; font-size: 11px; font-weight: 600; color: var(--coral-deep); background: var(--coral-soft); border-radius: 999px; padding: 1px 8px; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.doc-row.c { grid-template-columns: 34px minmax(0, 1fr) 76px; align-items: start; gap: 12px; padding: 11px 16px; }
.doc-row.c .fmt { margin-top: 1px; }
.doc-row.c .num { padding-top: 2px; }
.result-line { margin: 12px 28px 0; font-size: 12px; color: var(--muted); }
.has-detail .result-line { margin-inline: 20px; }
.lib-body .list-scroll { padding-top: 10px; }

/* detail */
.title-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
.title-line h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: .3px; min-width: 0; overflow-wrap: anywhere; }
.title-line h2.struck { color: #b3a49b; text-decoration: line-through; text-decoration-color: #d9c9bf; }
.lib-detail .detail-head { align-items: center; }
.lib-detail .detail-head > div { align-self: flex-start; }
.lib-detail .detail-head .alias { margin: 6px 0 0; font-size: 12px; }
.sec.first { margin-top: 6px; }
.group.pad { padding: 12px 14px; }
.kv2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; margin: 0; }
.kv2 > div { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 8px; font-size: 13px; align-items: center; min-height: 24px; }
.kv2 dt { color: var(--muted); font-size: 12px; }
.kv2 dd { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary { margin: 0; font-size: 13px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.doc-box { position: relative; max-height: 300px; }
.doc-box.open { max-height: none; }
.doc-box .md { padding: 14px 16px 40px; }
.doc-box.open .md { padding-bottom: 14px; }
.fade { position: absolute; inset: auto 0 0 0; height: 72px; background: linear-gradient(#fff0, #fff 70%); display: flex; align-items: flex-end; justify-content: center; padding-bottom: 10px; }
.fade .text-button { font-size: 12px; padding: 0; }
.version-bar { margin: 8px 0 0; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 9px 12px; border-radius: 8px; background: #f2faf5; border: 1px solid #d5eee0; font-size: 12px; color: #3d6b52; }
.version-bar .text-button { margin-left: auto; padding: 0; font-size: 12px; }
.cd-body + .version-bar, .cite-drawer > .version-bar { margin: 12px 20px 0; }
.ver-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; padding: 10px 14px; border: 0; border-bottom: 1px solid #f5ebe5; background: #fff; text-align: left; font-size: 13px; color: var(--ink); }
.ver-row:last-child { border-bottom: 0; }
.ver-row:hover:not(:disabled) { background: #fffaf7; }
.ver-row:disabled { opacity: 1; cursor: default; }
.ver-row.is-current { background: #fff7f4; }
.ver-row b { font-weight: 600; font-size: 12px; color: var(--muted); }
.ver-row > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ver-row small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.case-cite { display: grid; grid-template-columns: minmax(0, 1fr) auto 14px; gap: 10px; align-items: center; width: 100%; padding: 11px 14px; border: 0; border-bottom: 1px solid #f5ebe5; background: #fff; text-align: left; color: var(--ink); }
.case-cite:last-child { border-bottom: 0; }
.case-cite:hover { background: #fffaf7; }
.case-cite > span:first-child { min-width: 0; }
.case-cite strong { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-cite small { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-cite .date { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.case-cite .go { color: #c8b8ae; font-size: 17px; text-align: right; }
.foot-acts { display: flex; gap: 16px; align-items: center; }
.foot-acts .text-button { font-size: 13px; padding: 0; display: inline-flex; gap: 4px; align-items: center; }

/* rendered document text (text nodes only) */
.md { font-size: 13px; line-height: 1.7; color: #3d2a1f; overflow-wrap: anywhere; }
.md h4 { margin: 0 0 6px; font-size: 15px; }
.md h5 { margin: 12px 0 4px; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .5px; }
.md p { margin: 0 0 6px; }
.md ul { margin: 0 0 6px; padding-left: 18px; }
.md-table { overflow-x: auto; margin: 2px 0 8px; }
.md table { width: 100%; border-collapse: collapse; font-size: 12px; }
.md th { text-align: left; font-weight: 500; color: var(--muted); font-size: 11px; background: #fdf9f6; padding: 6px 8px; border: 1px solid #f1e4dc; }
.md td { padding: 6px 8px; border: 1px solid #f1e4dc; vertical-align: top; }
.md td.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.md tr.hl td, .md tr.hl th { background: #fff1c9; border-color: #f3d98a; }
.md tr.hl > :first-child { box-shadow: inset 3px 0 0 #f0b040; }
.md p.hl, .md li.hl, .md h4.hl, .md h5.hl { background: #fff1c9; box-shadow: -6px 0 0 #fff1c9, 6px 0 0 #fff1c9, -9px 0 0 #f0b040; border-radius: 2px; }

/* scanned / unreadable */
.scan-card { margin-top: 8px; display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 18px; padding: 16px; border-radius: 12px; background: var(--amber-bg); border: 1px solid #f6e0c2; }
.scan-img { display: grid; place-items: center; }
.scan-paper { display: block; width: 118px; height: 156px; border-radius: 4px; background: #fbf8f4 repeating-linear-gradient(#fbf8f4 0 9px, #cfc6bd 9px 10px, #fbf8f4 10px 13px) 14px 46px / 86px 92px no-repeat; box-shadow: 0 2px 10px #32190826; transform: rotate(-2deg); position: relative; }
.scan-paper::before { content: ''; position: absolute; left: 14px; top: 18px; width: 46px; height: 8px; background: #8f857c; border-radius: 1px; }
.scan-paper::after { content: ''; position: absolute; right: 14px; top: 14px; width: 26px; height: 14px; border: 1.5px solid #e2574c99; border-radius: 2px; }
.scan-txt h3 { margin: 4px 0 6px; font-size: 15px; color: #7a5326; }
.scan-txt p { margin: 0 0 14px; font-size: 13px; line-height: 1.7; color: #7a5326; }
.scan-txt small { display: block; margin-top: 10px; font-size: 12px; color: #a07a4e; line-height: 1.6; }
.scan-txt .row { display: flex; gap: 8px; }

/* 依據 in chat */
.cite { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; margin: 0 1px; border-radius: 5px; background: var(--coral-soft); color: var(--coral-deep); border: 1px solid #f8cfc6; font-size: 11px; font-weight: 700; line-height: 1; vertical-align: 2px; font-variant-numeric: tabular-nums; font-family: inherit; }
.cite:hover { border-color: var(--coral); }
.cite.is-on { background: var(--coral); border-color: var(--coral); color: #fff; }
.suggest-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.suggest-pick { padding: 6px 12px; border-radius: 999px; border: 1px solid #f8cfc6; background: var(--coral-soft); color: var(--coral-deep); font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer; }
.suggest-pick:hover:not(:disabled) { border-color: var(--coral); }
.suggest-pick:disabled { opacity: .5; cursor: default; }
.suggest-pick.is-chosen { opacity: 1; background: #fff; color: var(--ink); border-color: var(--line); }
.proposal-card { margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 12px 14px; }
.proposal-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 14px; }
.proposal-state { font-size: 12px; color: var(--muted); white-space: nowrap; }
.proposal-reason { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.proposal-rows { margin: 8px 0 0; display: grid; gap: 6px; }
.proposal-row { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 10px; font-size: 13px; }
.proposal-row dt { color: var(--muted); }
.proposal-row dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
.proposal-row s { color: #b3a49b; }
.proposal-row .arrow { color: #c8b8ae; margin: 0 6px; }
.proposal-row .after { color: var(--ink); font-weight: 600; }
.proposal-acts { display: flex; gap: 8px; margin-top: 10px; }
.proposal-card.is-accepted, .proposal-card.is-rejected { background: #fdf8f5; }
.proposal-card.is-rejected .after { font-weight: 400; color: var(--muted); }
.proposal-tag { font-size: 12px; color: #3d7a55; background: #eef7f1; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.proposal-tag.is-ai { color: var(--coral-deep); background: var(--coral-soft); }
.terms-diff { margin-top: 8px; display: grid; gap: 4px; font-size: 13px; line-height: 1.5; }
.terms-line { padding: 4px 8px; border-radius: 6px; overflow-wrap: anywhere; white-space: pre-line; }
.terms-line.is-added { background: #eef7f1; color: var(--ink); }
.terms-line.is-removed { background: #fbf1ee; color: #a08f86; text-decoration: line-through; }
.terms-line.is-kept { color: var(--muted); font-size: 12px; padding-top: 0; padding-bottom: 0; }
.terms-line.is-title s { color: #b3a49b; }
.terms-line.is-title .arrow { color: #c8b8ae; margin: 0 6px; }
.terms-line.is-title .after { font-weight: 600; }
.proposal-card.is-rejected .terms-line.is-added { background: none; color: var(--muted); }
.refs { margin-top: 10px; border-top: 1px solid #f5ebe5; padding-top: 8px; font-size: 13px; }
.refs > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.refs > summary::-webkit-details-marker { display: none; }
.refs > summary::after { content: '▸'; font-size: 10px; transition: transform .15s; }
.refs[open] > summary::after { transform: rotate(90deg); }
.refs-group { margin-top: 8px; }
.refs-group h4 { margin: 0 0 2px; font-size: 11px; font-weight: 600; color: #b3a49b; letter-spacing: 1px; }
.refs-row { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 5px 8px; border: 0; border-radius: 8px; background: transparent; text-align: left; color: var(--ink); font: inherit; text-decoration: none; cursor: pointer; }
.refs-row:hover { background: #fdf6f2; }
.refs-row.is-on { background: var(--coral-soft); box-shadow: inset 0 0 0 1px #f8cfc6; }
.refs-row.is-static { cursor: default; }
.refs-row.is-static:hover { background: transparent; }
.refs-n { display: grid; place-items: center; min-width: 20px; height: 20px; border-radius: 5px; background: var(--coral-soft); color: var(--coral-deep); font-size: 11px; }
.refs-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.refs-row small { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.refs-note { display: flex; align-items: center; gap: 4px; margin: 6px 0 0; font-size: 11px; color: #b3a49b; }
.refs-note .ico { width: 12px; height: 12px; }
.sources { margin-top: 12px; border-top: 1px solid #f5ebe5; padding-top: 10px; }
.sources-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 6px; }
.sources-head > span { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 1px; }
.sources-head small { font-size: 11px; color: #b3a49b; display: inline-flex; gap: 4px; align-items: center; }
.sources-head .ico { width: 12px; height: 12px; }
.src-item { display: grid; grid-template-columns: 20px 34px minmax(0, 1fr); align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; border-radius: 8px; background: transparent; text-align: left; color: var(--ink); }
.src-item:hover { background: #fdf6f2; }
.src-item.is-on { background: var(--coral-soft); box-shadow: inset 0 0 0 1px #f8cfc6; }
.src-item > b { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; background: #f8f0eb; color: #7a6458; font-size: 11px; }
.src-item.is-on > b { background: var(--coral); color: #fff; }
.src-item > span { min-width: 0; }
.src-item strong { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; min-width: 0; }
.src-item strong .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-item small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-item.del strong .t { color: #b3a49b; text-decoration: line-through; text-decoration-color: #d9c9bf; }
.src-item.del .fmt { opacity: .4; }
.st { font-size: 10.5px; font-weight: 500; border-radius: 999px; padding: 1px 7px; text-decoration: none; display: inline-block; flex-shrink: 0; white-space: nowrap; }
.st.new { background: #e9f6ef; color: #2f8a5b; border: 1px solid #c9ead7; }
.st.del { background: #f5f1ee; color: #8a7a70; border: 1px solid #e7dbd3; }

/* chat + right-side preview drawer */
.cite-split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.cite-split.has-drawer { grid-template-columns: minmax(0, 1fr) 430px; }
.cite-left { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.has-drawer .conversation-width { padding: 0 28px 20px; }
.has-drawer .composer-area { padding: 8px 28px 14px; }
.has-drawer .composer-help { display: none; }
.cite-drawer { background: #fff; border-left: 1px solid var(--line); box-shadow: -6px 0 22px #32190812; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.cd-nav { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 6px; }
.cd-step { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.cd-step b { color: var(--ink); font-weight: 600; }
.cd-step button { border: 1px solid var(--line); background: #fff; width: 24px; height: 24px; border-radius: 6px; color: var(--muted); line-height: 1; padding: 0; }
.cd-head { padding: 4px 20px 12px; border-bottom: 1px solid #f5ebe5; }
.cd-head h2 { font-size: 17px; }
.cd-head .meta { margin-top: 8px; font-size: 12px; }
.cd-quote { margin: 12px 20px 0; padding: 10px 12px; border-radius: 8px; background: #fff8e6; border-left: 3px solid #f0b040; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; max-height: 160px; overflow: auto; flex-shrink: 0; }
.cd-quote small { display: block; font-size: 11px; color: #a07a4e; margin-bottom: 2px; }
.cd-body { flex: 1; overflow: auto; padding: 14px 20px; min-height: 0; scrollbar-width: thin; scrollbar-color: #f0d8cf transparent; }
.cd-gone { margin: 4px 0; font-size: 13px; color: var(--muted); line-height: 1.7; }
.cd-foot { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid #f5ebe5; }
.cd-foot:empty { display: none; }

/* upload sheet */
.lib-sheet { width: min(1000px, 100%); height: min(760px, calc(100dvh - 56px)); }
.lib-sheet .imp { grid-template-columns: 280px minmax(0, 1fr); }
.lib-sheet .sheet-body { display: grid; place-items: center; }
.md-paper { white-space: normal; font-size: 11px; }
.md-paper .md { font-size: 11px; line-height: 1.65; color: #6b5a50; }
.md-paper .md h4 { font-size: 12px; color: var(--ink); }
.md-paper .md table { font-size: 10px; }
.md-paper .md td, .md-paper .md th { padding: 2px 4px; border-color: #eee3dc; }
.md td.nw { white-space: nowrap; }
.dup { margin-top: 14px; padding: 12px; border-radius: 10px; background: var(--amber-bg); border: 1px solid #f6e0c2; }
.dup p { margin: 0 0 10px; font-size: 13px; color: #7a5326; }
.dup p strong { margin-right: 6px; }
.dup-pick { margin-top: 8px; width: 100%; border: 1px solid #efd3ad; border-radius: 6px; background: #fff; padding: 6px 8px; font-size: 13px; color: var(--ink); }
.match.two { margin-top: 0; }
.cat-pick .select-chip { appearance: none; -webkit-appearance: none; padding-right: 12px; cursor: pointer; font: inherit; font-size: 13px; }
.cat-pick .select-chip.on { background: var(--coral); border-color: var(--coral); color: #fff; }
.fgroup.two-col { display: grid; grid-template-columns: 1fr 1fr; }
.fgroup.two-col .frow { grid-template-columns: 64px minmax(0, 1fr); font-size: 13px; min-height: 42px; }
.fgroup.two-col .frow > label { font-size: 13px; color: var(--muted); }
.fgroup.two-col .frow:first-child { grid-column: 1 / -1; }
.fgroup.two-col .frow:nth-child(even) { border-right: 1px solid #f5ebe5; }
.fgroup.two-col .frow:nth-last-child(-n+3) { border-bottom: 0; }
.fgroup.two-col .frow input, .fgroup.two-col .frow select { font-size: 13px; }
.frow.solo { grid-template-columns: 1fr; }
.frow textarea { font-size: 13px; }
.sheet-foot .switch-line { font-size: 12px; text-align: left; }

@media (max-width: 1180px) and (min-width: 761px) {
  .lib-body.has-detail { grid-template-columns: minmax(0, 1fr) 460px; }
  .doc-row { grid-template-columns: 34px minmax(0, 1fr) 104px 110px 84px; }
  .doc-row > :nth-child(6) { display: none; }
  .cite-split.has-drawer { grid-template-columns: minmax(0, 1fr) 380px; }
}
@media (max-width: 760px) {
  .result-line { margin: 10px 14px 0; }
  .page-actions .btn.primary .lbl.d-only { display: none; }
  .m-card.doc { cursor: pointer; }
  .m-card.doc .top { gap: 8px; }
  .m-card.doc .top strong { font-size: 14.5px; }
  .m-card.doc p { margin: 6px 0 0; font-size: 12.5px; color: #5e4a3e; line-height: 1.55; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
  .m-card.doc .mid { font-size: 12px; color: var(--muted); }
  .m-card.doc .mid .pill { font-size: 11.5px; }
  .lib-body.has-detail { grid-template-columns: minmax(0, 1fr); }
  .m-nav .nav-btn { display: inline-flex; gap: 4px; align-items: center; text-decoration: none; }
  .lib-detail .title-line { align-items: flex-start; }
  .lib-detail .title-line .fmt { margin-top: 4px; }
  .lib-detail .title-line h2 { font-size: 18px; }
  .kv2 { gap: 8px 12px; }
  .kv2 > div { grid-template-columns: 44px minmax(0, 1fr); }
  .doc-box { max-height: 260px; }
  .doc-box .md { padding: 12px 12px 40px; }
  .detail-foot { flex-wrap: wrap; gap: 8px; }
  .scan-card { grid-template-columns: 1fr; }
  .scan-paper { width: 96px; height: 126px; }
  .cite-split.has-drawer { grid-template-columns: minmax(0, 1fr); }
  .cite-drawer:not([hidden]) { position: fixed; inset: 0; z-index: 45; border-left: 0; box-shadow: none; }
  .cd-foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .src-item { padding-inline: 6px; gap: 8px; }
  .lib-sheet { height: 94dvh; }
  .lib-sheet .imp { grid-template-columns: minmax(0, 1fr); }
  .fgroup.two-col { grid-template-columns: 1fr; }
  .fgroup.two-col .frow:nth-child(n) { border-right: 0; border-bottom: 1px solid #f5ebe5; }
  .fgroup.two-col .frow:nth-last-child(2) { border-bottom: 0; }
}

/* supplier name links (assistant replies, internal 地接 draft, 資料庫 供應商 field) */
.sup-link { color: var(--coral-deep); text-decoration: underline; text-decoration-color: #fe6f6055; text-decoration-thickness: 1px; text-underline-offset: 3px; cursor: pointer; }
.sup-link:hover { text-decoration-color: currentColor; }
.kv2 dd .sup-link { text-decoration: none; }
.kv2 dd .sup-link:hover { text-decoration: underline; }

/* 供應商 → 相關文件 */
.rel-doc { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto 14px; gap: 10px; align-items: center; width: 100%; padding: 10px 14px; border: 0; border-bottom: 1px solid #f5ebe5; background: #fff; text-align: left; color: var(--ink); }
.rel-doc:last-child { border-bottom: 0; }
.rel-doc:hover { background: #fffaf7; }
.rel-name { min-width: 0; }
.rel-name strong { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel-name small { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
.rel-doc .date { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.rel-doc .go { color: #c8b8ae; font-size: 17px; text-align: right; }
.rel-more { display: block; width: 100%; padding: 10px 14px; text-align: center; font-size: 13px; }
.sup-filter { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 10px; border-radius: 999px; background: var(--coral-soft); color: var(--coral-deep); font-weight: 600; }
.sup-filter .x { border: 0; background: none; color: inherit; font-size: 15px; line-height: 1; padding: 0 6px; }

/* 資料庫 → 文件內圖片 */
.img-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.img-cell { display: block; padding: 0; border: 0; background: none; text-align: left; color: var(--muted); min-width: 0; }
.img-frame { display: block; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: #f6eee8; border: 1px solid #f1e4dc; }
.img-frame img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.img-cell:hover .img-frame img { transform: scale(1.03); }
.img-cell small { display: block; margin-top: 5px; font-size: 12px; }
.lightbox { position: fixed; inset: 0; z-index: 120; background: #1a0d05e6; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.lb-stage { display: flex; align-items: center; justify-content: center; min-height: 0; overflow: hidden; padding: 56px 76px 8px; }
.lb-stage img { width: auto; height: auto; max-width: 100%; max-height: calc(100vh - 120px); max-height: calc(100dvh - 120px); object-fit: contain; border-radius: 4px; box-shadow: 0 6px 30px #0006; background: #fff; }
.lb-cap { text-align: center; color: #f3e6dc; font-size: 13px; padding: 10px 16px 18px; }
.lb-nav, .lb-close { position: absolute; border: 0; background: #ffffff1f; color: #fff; border-radius: 999px; display: grid; place-items: center; }
.lb-nav { top: 50%; transform: translateY(-50%); width: 44px; height: 44px; font-size: 28px; line-height: 1; }
.lb-nav.prev { left: 16px; }
.lb-nav.next { right: 16px; }
.lb-nav:disabled { opacity: .25; }
.lb-close { top: 12px; right: 14px; width: 40px; height: 40px; font-size: 24px; }
.lb-nav:not(:disabled):hover, .lb-close:hover { background: #ffffff38; }
body.lightbox-open { overflow: hidden; }
@media (max-width: 760px) {
  .img-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lb-stage { padding: 56px 8px 8px; }
  .lb-stage img { max-height: calc(100vh - 136px); max-height: calc(100dvh - 136px); }
  .lb-nav { top: auto; bottom: 8px; transform: none; }
  .lightbox { grid-template-rows: minmax(0, 1fr) 64px; }
  .lb-cap { padding-top: 20px; }
}

/* 拍照輸入 */
.photo-entry { display: flex; align-items: center; gap: 12px; width: 100%; margin: 4px 0 6px; padding: 13px 14px; background: #fff; border: 1px solid #f1e4dc; border-radius: 10px; color: var(--ink); text-align: left; cursor: pointer; }
.photo-entry:hover { background: #fffaf7; border-color: #f4d3c8; }
.photo-entry:focus-visible { outline: none; box-shadow: 0 0 0 3px #fe6f6026; border-color: var(--coral); }
.photo-entry .photo-ico { width: 34px; height: 34px; border-radius: 9px; background: var(--coral-soft); color: var(--coral-deep); display: grid; place-items: center; flex-shrink: 0; }
.photo-entry .photo-ico .ico { width: 18px; height: 18px; vertical-align: 0; }
.photo-entry .photo-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.photo-entry strong { font-size: 14px; font-weight: 600; }
.photo-entry small { font-size: 12px; color: var(--muted); line-height: 1.5; }
.photo-entry .chev { color: #c8b8ae; font-size: 20px; line-height: 1; }
.imp-contacts { margin-top: 4px; }
.imp-contact { padding: 10px 14px; border-bottom: 1px solid #f5ebe5; font-size: 13px; }
.imp-contact:last-child { border-bottom: 0; }
.imp-contact .who { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.imp-contact .who strong { font-weight: 600; font-size: 14px; }
.imp-contact .who small { color: var(--muted); font-size: 12px; }
.imp-contact .who .cell-muted { font-size: 11px; }
.imp-contact dl { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 2px 8px; margin: 6px 0 0; }
.imp-contact dt { color: var(--muted); }
.imp-contact dd { margin: 0; overflow-wrap: anywhere; }
