/* Shared base for the three previews. Each version restyles these through its own CSS. */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.55; }
h1, h2, h3, p, ol, ul, blockquote { margin: 0; padding: 0; }
ol, ul { list-style: none; }
button, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
.ic { width: 18px; height: 18px; flex: none; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.link { color: var(--link-c, var(--primary)); font-weight: 500; text-decoration: underline; text-underline-offset: 2px; text-align: left; }

/* Logo: white tile; the crop trims only the PNG's white margin. */
.tile { display: inline-block; flex: none; width: 70px; height: 40px; background: var(--chat-logo-tile-bg); border-radius: var(--radius-sm); overflow: hidden; }
.tile img { display: block; width: 100%; height: 100%; object-fit: cover; transform: scale(1.18); }
/* Header logo: the tightly cropped mark, pre-sized (128 px for 1x and zoomed screens, 256 px for 2x) and drawn at its
   own size; no scale() blow-up, which blurred the small text under the mark. */
.tile:has(> img.brand-mark) { display: inline-grid; place-items: center; }
.tile img.brand-mark { width: calc(100% - 6px); height: auto; object-fit: contain; transform: none; }

.icon-btn { display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: var(--radius-sm); }
.icon-btn:hover { background: var(--hover, var(--surface-hover)); }
.ic-sun { display: none; }
:root[data-theme="dark"] .ic-sun { display: block; }
:root[data-theme="dark"] .ic-moon { display: none; }

/* Language switch */
.lang { display: inline-flex; flex: none; gap: 2px; padding: 2px; border: 1px solid var(--lang-line, var(--border-input)); border-radius: var(--lang-r, var(--radius-full)); }
.lang button { min-width: 36px; height: 30px; padding: 0 8px; border-radius: inherit; font-size: 12.5px; font-weight: 600; letter-spacing: .03em; color: var(--lang-fg, var(--text-2)); }
.lang button:hover { background: var(--hover, var(--surface-hover)); }
.lang button[aria-pressed="true"] { background: var(--lang-on, var(--primary)); color: var(--lang-on-fg, var(--on-primary)); }

/* AI notice: always visible */
.notice-in { display: flex; gap: 8px; align-items: flex-start; }
.notice-in .ic { margin-top: 1px; }
.n-short { display: none; }

/* Composer */
.composer { width: 100%; }
.modes { display: inline-flex; gap: 2px; }
.mode { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; font-size: 13.5px; font-weight: 500; color: var(--text-2); }
.mode .ic { width: 15px; height: 15px; }
.mode:hover { color: var(--primary); }
.field { display: flex; align-items: flex-end; gap: 8px; background: var(--paper); }
.field textarea { flex: 1; min-width: 0; min-height: 44px; max-height: 160px; padding: 10px 4px; border: 0; background: transparent; resize: none; outline: none; font-size: 16px; line-height: 24px; color: var(--text); }
.field textarea::placeholder { color: var(--muted); opacity: 1; }
.send { display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none; min-width: 44px; height: 44px; background: var(--primary); color: var(--on-primary); }
.send:hover { background: var(--primary-strong); }
.send-text { display: none; font-weight: 600; }
.hint { color: var(--muted); font-size: 12.5px; line-height: 18px; }

/* Shared lists */
.hist-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.hist-head h2 { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-2); }
.hist-head span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.hist-empty { padding: 16px 8px; text-align: center; font-size: 14px; color: var(--text-2); }
.hist-empty strong { display: block; color: var(--text); margin-bottom: 4px; }
.hist-empty .ghost { margin-top: 12px; }
.hist-item { display: block; width: 100%; padding: 8px 10px; border-radius: var(--radius-sm); text-align: left; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.hist-item:hover { background: var(--hover, var(--surface-hover)); }
.hist-item[aria-current] { font-weight: 600; box-shadow: inset 3px 0 0 var(--accent-decor); }
.contact { display: grid; gap: 6px; font-size: 13.5px; }
.contact h2 { font-size: 13.5px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.contact a { display: inline-flex; align-items: center; gap: 8px; color: var(--link-c, var(--primary)); text-decoration: none; }
.contact a:hover { text-decoration: underline; }
.contact .ic { width: 15px; height: 15px; }
.phone-actions { display: none; gap: 6px; margin-top: 4px; }
.ghost { min-height: 36px; padding: 0 14px; border: 1px solid var(--ghost-line, var(--border-input)); border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; color: var(--ghost-fg, var(--primary)); }
.ghost:hover { background: var(--hover, var(--surface-hover)); }
.guest-acts { display: flex; flex-wrap: wrap; gap: 8px; }

/* Suggestions */
.sug { display: flex; flex-direction: column; justify-content: flex-start; width: 100%; text-align: left; }
.sug-topic, .sug-q { display: block; }

/* Conversation */
.msg .answer { font-size: 15.5px; line-height: 1.65; }
.answer p + p, .answer p + ul, .answer ul + p { margin-top: 10px; }
.answer ul { display: grid; gap: 4px; padding-left: 20px; list-style: disc; }
.answer strong { font-weight: 700; color: var(--heading); }
.cite { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 3px; padding: 0 4px; border-radius: var(--radius-xs); background: var(--chat-citation-bg); color: var(--chat-citation-fg); font-size: 12px; font-weight: 700; vertical-align: 1px; line-height: 1; }
.cite:hover { background: var(--primary); color: var(--on-primary); }
.sources { margin-top: 12px; }
.sources-title { display: none; }
.sources-toggle { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; font-size: 13.5px; font-weight: 600; color: var(--primary); }
.sources-toggle .ic { width: 14px; height: 14px; transition: transform var(--duration); }
.sources[data-open] .sources-toggle .ic { transform: rotate(90deg); }
.source { display: none; gap: 10px; margin-top: 6px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--paper); font-size: 14px; line-height: 1.5; }
.sources[data-open] .source { display: flex; }
.source:focus { outline: 2px solid var(--border-focus); outline-offset: 1px; }
.source-n { flex: none; display: grid; place-items: center; width: 20px; height: 20px; border-radius: var(--radius-xs); background: var(--chat-citation-bg); color: var(--chat-citation-fg); font-size: 12px; font-weight: 700; }
.source strong { display: block; color: var(--heading); }
.source-where { display: block; color: var(--text-2); }
.source blockquote { margin-top: 8px; color: var(--text-2); }
.source-lang { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.actions { display: flex; gap: 2px; margin-top: 6px; }
.act { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm); color: var(--muted); }
.act:hover { background: var(--surface-hover); color: var(--primary); }
.act[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); }
.act .ic { width: 16px; height: 16px; }
.dots { display: inline-flex; gap: 5px; padding: 12px 0; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); animation: pulse 1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }

/* View switching */
[data-view="welcome"] [data-thread], [data-view="welcome"] .chat-only { display: none !important; }
[data-view="chat"] .welcome-only { display: none !important; }

/* Drawer + backdrop + toast */
.backdrop { position: fixed; inset: 0; z-index: var(--z-overlay); background: var(--overlay); opacity: 0; visibility: hidden; transition: opacity var(--duration); }
[data-drawer="open"] .backdrop { opacity: 1; visibility: visible; }
.drawer { position: fixed; inset: 0 auto 0 0; z-index: var(--z-modal); display: flex; flex-direction: column; gap: 16px; width: min(330px, 88vw); padding: 16px; background: var(--paper); transform: translateX(-102%); visibility: hidden; transition: transform var(--duration-slow) var(--ease-out), visibility var(--duration-slow); }
[data-drawer="open"] .drawer { transform: none; visibility: visible; }
.drawer-head { display: flex; align-items: center; gap: 10px; }
.drawer-head strong { flex: 1; font-family: var(--font-heading); font-size: 15px; color: var(--heading); }
.drawer [data-slot="history"] { flex: 1; min-height: 0; overflow: auto; }
.drawer-new { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border-radius: var(--radius-sm); background: var(--primary); color: var(--on-primary); font-weight: 600; }
.drawer-new:hover { background: var(--primary-strong); }
#toast { position: fixed; left: 50%; bottom: 24px; z-index: var(--z-toast); max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: var(--radius-sm); background: var(--tdtu-blue-900); color: var(--text-inverse); font-size: 14px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none; transition: opacity var(--duration), transform var(--duration); }
#toast[data-show] { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  .n-long { display: none; }
  .n-short { display: inline; }
  .phone-actions { display: grid; }
  .only-wide { display: none !important; }
}
@media (max-width: 400px) { .only-mid { display: none !important; } }
@media (min-width: 641px) { .only-phone { display: none !important; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .dots i { opacity: .7; }
}
