/* اپ اصلاح متن تماس‌ها: تیره، فارسی، راست‌به‌چپ. خط زمان صدا همیشه چپ‌به‌راست است. */
@font-face { font-family: 'Vazirmatn'; src: url('/fonts/vazirmatn.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #0b1120; --bg-2: #0f172a; --s1: #131c31; --s2: #18233d; --s3: #1f2c4b; --line: #26344f; --line-2: #33456a;
  --t1: #e7ecf6; --t2: #a9b4cb; --t3: #7383a3;
  --blue: #4c8dff; --blue-s: rgba(76, 141, 255, .16); --green: #31c48d; --green-s: rgba(49, 196, 141, .16);
  --amber: #f5b13d; --amber-s: rgba(245, 177, 61, .22); --red: #f26d6d; --red-s: rgba(242, 109, 109, .2);
  --agent: #4c8dff; --cust: #31c48d; --other: #a78bfa;
  --r: 12px; --font: 'Vazirmatn', Tahoma, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--t1); font-family: var(--font); font-size: 15px; line-height: 1.7; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
.boot { padding: 40px; text-align: center; color: var(--t3); }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--t3); }
.small { font-size: 12.5px; }
.hide { display: none !important; }

/* دکمه‌ها */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--s2); border-radius: 10px; padding: 6px 14px; cursor: pointer; transition: background .15s, border-color .15s; white-space: nowrap; }
.btn:hover { background: var(--s3); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 700; }
.btn.primary:hover { background: #3d7cf0; }
.btn.green { background: var(--green); border-color: var(--green); color: #052e1f; font-weight: 700; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--s2); }
.btn.sm { padding: 3px 10px; font-size: 13px; border-radius: 8px; }
.btn.big { padding: 12px 26px; font-size: 17px; border-radius: 14px; }
.btn .k { font-size: 11px; color: var(--t3); border: 1px solid var(--line-2); border-radius: 5px; padding: 0 5px; direction: ltr; }
.btn.primary .k, .btn.green .k { color: inherit; border-color: rgba(255,255,255,.4); opacity: .8; }
.btn.on { background: var(--blue-s); border-color: var(--blue); color: #cfe0ff; }
kbd { font-family: var(--font); font-size: 12px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px; padding: 0 6px; background: var(--s1); direction: ltr; display: inline-block; }

/* قاب کلی */
.top { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--bg-2); position: sticky; top: 0; z-index: 20; }
.top .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.top .brand img { width: 28px; height: 28px; }
.top .sp { flex: 1; }
.page { max-width: 1180px; margin: 0 auto; padding: 22px 18px 60px; }
.card { background: var(--s1); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 860px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 14px 0 6px; }
.stat { display: flex; flex-direction: column; }
.stat b { font-size: 24px; font-weight: 800; }
.stat span { color: var(--t3); font-size: 13px; }
.bar { height: 10px; background: var(--s3); border-radius: 6px; overflow: hidden; position: relative; }
.bar i { position: absolute; inset-block: 0; inset-inline-start: 0; background: var(--blue); border-radius: 6px; }
.bar i.g { background: var(--green); }
.bar .tick { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--amber); }
.prow { display: grid; grid-template-columns: 150px 1fr 170px; gap: 12px; align-items: center; margin: 8px 0; }
.chip { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 1px 10px; font-size: 12.5px; background: var(--s3); color: var(--t2); white-space: nowrap; }
.chip.test { background: rgba(245, 177, 61, .18); color: #ffd58f; }
.chip.dev { background: rgba(167, 139, 250, .18); color: #d6c9ff; }
.chip.train { background: var(--blue-s); color: #bcd3ff; }
.chip.kind { background: var(--green-s); color: #a7f0d1; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th, table.t td { text-align: start; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t th { color: var(--t3); font-weight: 600; font-size: 12.5px; }
.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--t2); }
input.in, select.in { background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 12px; outline: none; }
input.in:focus, select.in:focus { border-color: var(--blue); }
.err { color: var(--red); font-size: 13px; min-height: 1em; }
.notice { border-radius: 10px; padding: 10px 14px; background: var(--blue-s); border: 1px solid rgba(76,141,255,.35); }
.notice.amber { background: var(--amber-s); border-color: rgba(245,177,61,.4); }

/* ورود */
.login { max-width: 380px; margin: 9vh auto; }
.login .card { padding: 26px; }
.login h1 { display: flex; align-items: center; gap: 10px; }
.login h1 img { width: 34px; height: 34px; }

/* اعلان‌ها */
#toasts { position: fixed; bottom: 18px; inset-inline-start: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--s3); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.4); max-width: 420px; }
.toast.red { border-color: var(--red); }
.toast.green { border-color: var(--green); }

/* ویرایشگر */
.ed { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; max-width: 1400px; margin: 0 auto; padding: 14px 18px 40px; }
@media (max-width: 1100px) { .ed { grid-template-columns: 1fr; } }
.ed-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.ed-head .t { font-weight: 800; font-size: 16px; }
.wave { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r); padding: 8px; direction: ltr; user-select: none; }
.wave canvas { display: block; width: 100%; }
.wave .ov { height: 44px; cursor: pointer; }
.wave .dt { height: 120px; cursor: crosshair; margin-top: 6px; }
.wave .tl { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--t3); padding: 2px 2px 0; }
.segbox { margin-top: 12px; }
.seg-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.seg-tools .sep { width: 1px; height: 22px; background: var(--line-2); margin: 0 4px; }
.spk-agent { --c: var(--agent); }
.spk-customer { --c: var(--cust); }
.spk-other { --c: var(--other); }
.btn.spk.on { background: color-mix(in srgb, var(--c) 22%, transparent); border-color: var(--c); color: #fff; }
.btn.flag.on { background: var(--red-s); border-color: var(--red); color: #ffd1d1; }

.tx { position: relative; border: 1px solid var(--line-2); border-radius: 12px; background: var(--bg-2); }
.tx:focus-within { border-color: var(--blue); }
.tx .bd, .tx textarea { font-family: var(--font); font-size: 21px; line-height: 2.05; padding: 12px 16px; margin: 0; border: 0; white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; letter-spacing: 0; text-align: right; direction: rtl; }
.tx .bd { position: absolute; inset: 0; color: transparent; pointer-events: none; overflow: hidden; }
.tx textarea { position: relative; display: block; width: 100%; min-height: 110px; resize: none; background: transparent; outline: none; color: var(--t1); overflow: hidden; caret-color: #fff; }
.tx .bd mark { color: transparent; background: none; border-radius: 4px; }
.tx .bd mark.lo { background: var(--amber-s); box-shadow: inset 0 -2px 0 var(--amber); }
.tx .bd mark.df { box-shadow: inset 0 -3px 0 var(--red); }
.tx .bd mark.lo.df { background: var(--amber-s); box-shadow: inset 0 -3px 0 var(--red); }
.tx .bd mark.now { background: rgba(76, 141, 255, .45); box-shadow: none; }
.alt { margin-top: 8px; font-size: 15.5px; color: var(--t2); line-height: 1.9; }
.alt .lb { font-size: 12px; color: var(--t3); margin-inline-end: 8px; }
.alt mark { background: var(--red-s); color: #ffd1d1; border-radius: 4px; padding: 0 2px; cursor: pointer; }
.hint { margin-top: 8px; font-size: 13px; color: var(--t3); display: flex; gap: 14px; flex-wrap: wrap; }
.hint .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-inline-end: 4px; }
.sugg { margin-top: 8px; padding: 8px 12px; border-radius: 10px; background: var(--red-s); border: 1px solid rgba(242,109,109,.4); font-size: 14.5px; }
.times { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--t2); direction: ltr; }
.seg-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.seg-actions .sp { flex: 1; }
.other { margin-top: 10px; border: 1px dashed var(--line-2); border-radius: 10px; padding: 8px 12px; font-size: 15px; }
.other .lb { font-size: 12px; color: var(--t3); }
.other ins { background: var(--green-s); text-decoration: none; border-radius: 3px; }

.list { background: var(--s1); border: 1px solid var(--line); border-radius: var(--r); max-height: calc(100vh - 120px); overflow: auto; position: sticky; top: 70px; }
@media (max-width: 1100px) { .list { position: static; max-height: 420px; } }
.list .hd { position: sticky; top: 0; background: var(--s1); padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; z-index: 2; }
.row { display: grid; grid-template-columns: 30px 1fr 18px; gap: 8px; padding: 7px 10px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13.5px; align-items: start; }
.row:hover { background: var(--s2); }
.row.cur { background: var(--blue-s); }
.row .n { color: var(--t3); font-size: 12px; text-align: center; padding-top: 2px; }
.row .x { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row .x::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--t3)); margin-inline-end: 6px; }
.row .st { font-size: 13px; text-align: center; }
.row .st.done { color: var(--green); }
.row .st.draft { color: var(--amber); }
.row.bad .x { text-decoration: line-through; color: var(--t3); }

/* راهنما */
.guide h2 { margin-top: 22px; }
.guide li { margin: 4px 0; }
.guide .ex { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; background: var(--bg-2); border-radius: 10px; padding: 10px 14px; margin: 6px 0; }
.guide .ex .no { color: #ffb4b4; text-decoration: line-through; }
.guide .ex .yes { color: #a7f0d1; }
.keys { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; align-items: center; }

/* پنجره‌ی میان‌صفحه */
.modal-bg { position: fixed; inset: 0; background: rgba(3, 7, 18, .7); display: flex; align-items: center; justify-content: center; z-index: 90; }
.modal { background: var(--s1); border: 1px solid var(--line-2); border-radius: 16px; padding: 20px 22px; width: min(560px, 94vw); max-height: 88vh; overflow: auto; }
.modal h2 { display: flex; justify-content: space-between; align-items: center; }
.secret { font-size: 22px; font-weight: 800; letter-spacing: 2px; direction: ltr; text-align: center; background: var(--bg-2); border-radius: 10px; padding: 10px; margin: 10px 0; user-select: all; }

/* چند نفر هم‌زمان، گوشی و لپ‌تاپ */
.ed-head .grow { flex: 1; }
.speeds { display: inline-flex; gap: 4px; }
.wave { margin-top: 10px; }
.mbar { display: none; }
.linkbox { direction: ltr; font-size: 13px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px; word-break: break-all; user-select: all; margin: 8px 0; }
.feed .it { border-bottom: 1px solid var(--line); padding: 8px 2px; font-size: 14px; }
.feed .it .meta { color: var(--t3); font-size: 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.feed del { color: #ffb4b4; text-decoration: line-through; }
.feed ins { color: #a7f0d1; text-decoration: none; background: var(--green-s); border-radius: 3px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-inline-end: 4px; }
.dot.off { background: var(--t3); }
.scroll-x { overflow-x: auto; }
@media (hover: none) { .k { display: none; } }
@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .top { padding: 8px 10px; gap: 4px; flex-wrap: wrap; }
  .top .brand { font-size: 14px; }
  .page { padding: 14px 12px 40px; }
  h1 { font-size: 19px; }
  .ed { padding: 8px 8px 96px; gap: 10px; }
  .ed-head { gap: 6px; }
  .ed-head .t { font-size: 14px; flex-basis: 100%; order: -1; }
  .desk-only, .seg-actions, .hint { display: none !important; }
  .wave { padding: 6px; }
  .wave .ov { height: 30px; }
  .wave .dt { height: 96px; }
  .card { padding: 12px; }
  .tx .bd, .tx textarea { font-size: 19px; line-height: 2; padding: 10px 12px; }
  .seg-tools { gap: 5px; }
  .seg-tools .sep { display: none; }
  .seg-tools .times { flex-basis: 100%; justify-content: center; }
  .mbar { display: grid; grid-template-columns: 1fr 1fr 1.2fr 1.7fr; gap: 8px; position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); background: var(--bg-2); border-top: 1px solid var(--line); }
  .mbar .btn { justify-content: center; padding: 13px 4px; font-size: 15px; border-radius: 12px; }
  .mbar .btn.play { background: var(--s3); font-weight: 700; }
  .list { max-height: 45vh; position: static; }
  .prow { grid-template-columns: 96px 1fr; }
  .prow > span:last-child { grid-column: 1 / -1; }
  #toasts { bottom: 96px; inset-inline: 12px; }
  .btn.big { padding: 12px 18px; font-size: 16px; }
}
