/* NoBorder Talk — hand-written, no framework. Logical properties for RTL. */
:root {
  --bg: #f4f7f6; --card: #ffffff; --ink: #111816; --muted: #55625e; --line: #dce4e1; --field: #c6d1cd;
  --brand: #0f766e; --brand-dark: #0b5f58; --brand-soft: #e5f3f0; --brand-ink: #ffffff;
  --accent: #f5a524; --accent-soft: #fdf2dc; --accent-ink: #7a4b00;
  --shadow: 0 18px 40px -22px rgba(16, 40, 35, .35);
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Khmer", "Khmer UI", "Leelawadee UI", "Nirmala UI", "Myanmar Text", "Noto Sans Myanmar", "Noto Sans Ethiopic", "Ebrima", "Noto Sans Sinhala", "Iskoola Pota", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1513; --card: #16201d; --ink: #e8efec; --muted: #9fb0aa; --line: #263430; --field: #3a4b46;
    --brand: #2bb3a3; --brand-dark: #7fd8cc; --brand-soft: #143430; --brand-ink: #04211d;
    --accent-soft: #3a2c10; --accent-ink: #ffd58a;
    --shadow: 0 18px 40px -22px rgba(0, 0, 0, .8);
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 17px; line-height: 1.5; color: var(--ink); background: var(--bg); overflow-wrap: anywhere; }
:lang(km), :lang(my), :lang(lo), :lang(si), :lang(th), :lang(ta), :lang(te), :lang(mr), :lang(hi), :lang(ne), :lang(bn) { line-height: 1.75; }
a { color: var(--brand-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
p { margin: 0; }
.i { width: 1.25em; height: 1.25em; flex: none; vertical-align: -.2em; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, white); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Header */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 8px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line); }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.08rem; color: var(--ink); text-decoration: none; white-space: nowrap; margin-inline-end: auto; }
.logo svg { width: 32px; height: 32px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; min-height: 44px; padding: 8px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); }
.icon-btn:hover { background: var(--brand-soft); color: var(--brand-dark); }
.install { border: 1px solid var(--line); padding: 6px 12px; font-weight: 700; font-size: .9rem; color: var(--brand-dark); }

/* Layout */
.layout { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px 120px; }
@media (min-width: 1000px) {
  .layout { display: grid; grid-template-columns: minmax(0, 1fr) 410px; gap: 28px; align-items: start; padding-bottom: 48px; }
}
main { min-width: 0; }
.intro { padding: 22px 0 6px; }
.intro h1 { font-size: clamp(1.35rem, 1.1rem + 1.2vw, 1.9rem); letter-spacing: -.01em; margin-bottom: 8px; }
.intro p { color: var(--muted); max-width: 62ch; }

/* Languages */
.langs { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: end; margin: 16px 0; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.lang span { display: block; font-size: .82rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.lang select { width: 100%; }
.swap { margin-bottom: 1px; }
@media (max-width: 520px) {
  .langs { grid-template-columns: minmax(0, 1fr) auto; }
  .langs .lang:first-child { grid-column: 1 / 2; }
  .swap { grid-column: 2; grid-row: 1 / 3; align-self: center; }
  .langs .lang:last-of-type { grid-column: 1 / 2; grid-row: 2; }
}
select, input[type=text], input[type=search], input[type=date] { min-height: 46px; padding: 10px 12px; border: 1px solid var(--field); border-radius: 11px; background: var(--card); max-width: 100%; }
select { padding-inline-end: 30px; }
input:focus, select:focus { border-color: var(--brand); }

/* Received */
.inbox { margin: 16px 0 20px; padding: 16px; background: var(--card); border: 2px solid var(--brand); border-radius: var(--radius); box-shadow: var(--shadow); }
.inbox-hd { display: flex; align-items: flex-start; gap: 8px; }
.inbox-t { flex: 1; min-width: 0; }
.inbox-hd h2 { display: flex; align-items: center; gap: 8px; font-size: 1.1rem; color: var(--brand-dark); }
.inbox-hd .pair { color: var(--muted); font-size: .88rem; margin-top: 2px; }
.bubbles { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 8px; }
.bubble { background: var(--brand-soft); border-radius: 16px; border-start-start-radius: 4px; padding: 12px 14px; }
.b-me { font-size: 1.15rem; font-weight: 600; }
.b-orig { margin-top: 6px; font-size: .9rem; color: var(--muted); }
.b-lab { font-weight: 700; }
.sugg-h { display: flex; align-items: center; gap: 8px; font-size: 1rem; margin: 18px 0 10px; }
.replies { display: grid; gap: 8px; }
.reply { display: flex; align-items: flex-start; gap: 10px; text-align: start; width: 100%; padding: 12px 14px; border: 1px solid var(--brand); border-radius: 12px; background: var(--card); color: var(--ink); min-height: 48px; }
.reply:hover { background: var(--brand-soft); }

/* Tools */
.tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 8px 0 12px; }
.seg { display: inline-flex; align-items: center; gap: 4px; padding: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; flex-wrap: wrap; }
.seg-l { font-size: .85rem; font-weight: 700; color: var(--muted); padding-inline: 8px 4px; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 999px; font-weight: 700; font-size: .92rem; color: var(--muted); min-height: 38px; }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
.search { position: relative; flex: 1 1 220px; display: flex; }
.search .i { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { width: 100%; padding-inline-start: 40px; }
.cats { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; scrollbar-width: thin; margin-inline: -2px; }
.chip { flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: .92rem; font-weight: 600; white-space: nowrap; min-height: 40px; color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--card); border-color: var(--ink); }

/* Phrase list */
.cat { margin-bottom: 18px; }
.cat-h { font-size: .95rem; font-weight: 800; color: var(--muted); margin: 6px 2px 8px; letter-spacing: .01em; }
.phr { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ph { display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); min-height: 50px; transition: border-color .15s, background .15s; }
.ph:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.ph:active { background: var(--brand-soft); }
.ph-tx { flex: 1; min-width: 0; }
.ph-ic { color: var(--brand); margin-top: .15em; }
.slot { display: inline-block; padding: 0 .45em; margin: 0 .08em; border-radius: 7px; background: var(--accent-soft); color: var(--accent-ink); border: 1px dashed color-mix(in srgb, var(--accent) 70%, transparent); font-weight: 600; font-size: .92em; line-height: 1.5; }
.val { font-weight: 700; color: var(--brand-dark); }
.typed { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; background: var(--accent-soft); color: var(--accent-ink); padding: 0 .3em; border-radius: 5px; }
.none { color: var(--muted); padding: 18px 4px; }

/* Message (composer) */
.compose { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
@media (min-width: 1000px) {
  .compose { position: sticky; top: 78px; margin-top: 22px; max-height: calc(100vh - 96px); overflow: auto; }
  #composeClose, .bar, .scrim { display: none !important; }
}
@media (max-width: 999.98px) {
  .compose { position: fixed; inset: auto 0 0 0; z-index: 50; max-height: 88vh; max-height: 88dvh; overflow: auto; border-radius: 20px 20px 0 0; padding-bottom: max(16px, env(safe-area-inset-bottom)); transform: translateY(105%); visibility: hidden; transition: transform .25s ease, visibility 0s linear .25s; }
  .compose.open { transform: none; visibility: visible; transition: transform .25s ease; }
  body.sheet-open { overflow: hidden; }
}
.compose-hd { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.compose-hd h2 { font-size: 1.1rem; display: flex; align-items: center; gap: 8px; margin-inline-end: auto; }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px; background: var(--brand); color: var(--brand-ink); font-size: .8rem; font-weight: 800; }
.sent-note { display: inline-flex; align-items: center; gap: 4px; color: var(--brand-dark); font-weight: 700; font-size: .88rem; }
.empty { color: var(--muted); padding: 10px 0 14px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }
.lg-me::before { background: var(--ink); }
.lg-them::before { background: var(--brand); }
.msg { list-style: none; margin: 0 0 12px; padding: 0; }
.mi { display: flex; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.mi-tx { flex: 1; min-width: 0; }
.mi-me { font-weight: 600; }
.mi-them { margin-top: 4px; color: var(--brand-dark); padding-inline-start: 10px; border-inline-start: 3px solid var(--brand); }
.mi-act { display: flex; align-items: flex-start; }
.mi-act .icon-btn { min-width: 40px; min-height: 40px; }
.send { display: grid; gap: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 700; text-decoration: none; line-height: 1.2; }
.btn:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 85%, black); }
.btn-small { min-height: 40px; padding: 6px 14px; font-size: .92rem; }
.send-main { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.send-main .btn:only-child, .send-main .btn[hidden] + .btn { grid-column: 1 / -1; }
.apps { display: flex; flex-wrap: wrap; gap: 6px; }
.app { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-size: .88rem; font-weight: 600; min-height: 40px; }
.app:hover { background: var(--brand-soft); }
.app .i { width: 1.1em; height: 1.1em; }
.app-wa .i { color: #25d366; } .app-tg .i { color: #26a5e4; } .app-ln .i { color: #06c755; }
.linkbtn { border: 0; background: none; color: var(--muted); text-decoration: underline; padding: 6px 0; justify-self: start; font-size: .92rem; }
.tip { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink); font-size: .9rem; }
.tip .i { margin-top: .15em; }

/* Bottom bar (phones) */
.bar { position: fixed; inset-inline: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 40; }
.bar button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-radius: 999px; border: 0; background: var(--brand); color: var(--brand-ink); font-weight: 800; box-shadow: 0 14px 30px -12px rgba(15, 118, 110, .7); min-height: 54px; }
.bar button span:first-of-type { margin-inline-end: auto; }
.bar .count { background: var(--brand-ink); color: var(--brand); }
.bar button.bump { animation: bump .35s ease; }
@keyframes bump { 40% { transform: scale(1.04); } }
.scrim { position: fixed; inset: 0; z-index: 45; background: rgba(8, 18, 16, .45); }

/* Dialogs */
.dlg { border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); background: var(--card); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .45); }
.dlg::backdrop { background: rgba(8, 18, 16, .5); }
@media (max-width: 600px) {
  .dlg { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 20px 20px 0 0; max-height: 92vh; max-height: 92dvh; }
}
.dlg form, .dlg-in { display: flex; flex-direction: column; max-height: inherit; }
.dlg-body { padding: 18px; overflow: auto; }
.dlg-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; padding-bottom: max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.dlg-foot .btn { flex: 0 1 auto; min-width: 110px; }
.dlg-hd { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px 0 18px; }
.dlg-hd h2 { font-size: 1.1rem; }
.pv { background: var(--bg); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
.pv-me { font-weight: 600; font-size: 1.05rem; }
.pv-them { margin-top: 6px; color: var(--brand-dark); border-inline-start: 3px solid var(--brand); padding-inline-start: 10px; }
.pv-lab { display: block; font-size: .78rem; font-weight: 700; color: var(--muted); margin-top: 8px; }
.fld { border: 0; margin: 0 0 16px; padding: 0; min-width: 0; }
.fld > label, .fld legend { display: block; font-weight: 700; font-size: .92rem; margin-bottom: 6px; padding: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1 1 0; min-width: 0; }
.row > select { flex: 0 1 auto; min-width: 0; max-width: 60%; }
.row > select:only-child, .row > input:only-child, .row > input[type=date] { width: 100%; max-width: none; flex: 1 1 auto; }
.row-size { flex-wrap: wrap; }
.row-size > input { flex: 1 1 64px; }
.row-size > select { flex: 1 0 100%; max-width: none; }
.times, .suffix { color: var(--muted); font-weight: 700; }
.num { text-align: end; font-variant-numeric: tabular-nums; }
.hint { font-size: .85rem; color: var(--muted); margin-top: 6px; }
.err { color: #b42318; font-weight: 700; margin: 0 0 12px; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opts-incoterm .opts, .opts-doc .opts { flex-direction: column; }
.opt { position: relative; display: inline-flex; }
.opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.opt span { display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border: 1px solid var(--field); border-radius: 999px; font-size: .95rem; min-height: 42px; }
.opts-incoterm .opt span, .opts-doc .opt span { border-radius: 12px; }
.opt input:checked + span { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); font-weight: 700; }
.opt input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--brand) 55%, white); outline-offset: 2px; }
.sw { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .25); flex: none; }
.sw-red { background: #d62828; } .sw-orange { background: #f77f00; } .sw-yellow { background: #fcbf49; } .sw-green { background: #2a9d4b; }
.sw-blue { background: #1d6fd8; } .sw-navy { background: #1d2b5a; } .sw-purple { background: #7b3fbf; } .sw-pink { background: #f28ab2; }
.sw-brown { background: #7a4a24; } .sw-beige { background: #e8d9b5; } .sw-black { background: #111; } .sw-white { background: #fff; }
.sw-gray { background: #8d9692; } .sw-natural { background: #efe6d2; background-image: repeating-linear-gradient(45deg, rgba(120, 90, 40, .25) 0 2px, transparent 2px 5px); }
.sw-multicolor { background: conic-gradient(#d62828, #fcbf49, #2a9d4b, #1d6fd8, #7b3fbf, #d62828); }

/* History */
.hist-list { display: grid; gap: 8px; }
.hist-it { display: grid; gap: 4px; text-align: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); }
.hist-it:hover { border-color: var(--brand); }
.hist-meta { display: flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700; color: var(--muted); }
.hist-it.out .hist-meta .i { color: var(--brand); }
.hist-it.in .hist-meta .i { color: var(--accent); }
.hist-tx { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Footer */
.foot { max-width: 1180px; margin: 0 auto; padding: 24px 16px 140px; color: var(--muted); font-size: .9rem; display: grid; gap: 8px; }
@media (min-width: 1000px) { .foot { padding-bottom: 32px; } }
.foot p { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.foot a { color: var(--muted); }
.foot .i { margin-top: .15em; color: var(--brand); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 70; max-width: min(92vw, 520px); padding: 10px 16px; border-radius: 12px; background: #111816; color: #fff; font-size: .95rem; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .5); opacity: 0; transform: translate(-50%, 16px); transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 1000px) { .toast { bottom: 24px; } }

/* Printable phrase list */
#printv { max-width: 1000px; margin: 0 auto; padding: 16px; background: var(--card); }
#printv h1 { font-size: 1.3rem; margin: 12px 0; }
#printv h2 { font-size: 1rem; margin: 18px 0 6px; color: var(--brand-dark); }
#printv table { width: 100%; border-collapse: collapse; font-size: .92rem; }
#printv td { border-top: 1px solid var(--line); padding: 6px 8px; vertical-align: top; }
#printv .pr-n { width: 3em; color: var(--muted); font-variant-numeric: tabular-nums; }
.pr-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.pr-foot { margin-top: 18px; color: var(--muted); font-size: .85rem; }
body.printing > :not(#printv):not(.toast):not(script) { display: none !important; }
@media print {
  :root { --card: #fff; --ink: #000; --line: #bbb; --muted: #444; --brand-dark: #0b5f58; }
  body { background: #fff; font-size: 10.5pt; }
  .pr-tools { display: none !important; }
  #printv { padding: 0; }
  #printv tr { break-inside: avoid; }
  .slot { border: 1px solid #c9a24a; background: #fff6e0; }
}

/* Loading */
body:not(.ready) .list::before { content: "…"; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
