/* سفرنگار — the web app (made for the iPhone's home screen; works in any recent browser). */
:root {
  --bg: #f4f5f7; --card: #fff; --ink: #1b1f24; --muted: #6b7280; --line: #e3e6ea;
  --accent: #0f766e; --accent-ink: #fff; --accent-soft: #d9f2ee; --danger: #b91c1c; --chip: #eceff3;
  --rec: #c62828; --ok: #15803d; --warn-bg: #fdecc8; --warn-ink: #5f4300;
  --tabs: 58px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1114; --card: #171b21; --ink: #e8eaed; --muted: #98a2ad; --line: #2a3038;
    --accent: #2dd4bf; --accent-ink: #062b27; --accent-soft: #123b37; --danger: #f87171; --chip: #222831;
    --rec: #ef5350; --ok: #4ade80; --warn-bg: #3d3210; --warn-ink: #fde68a;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.65 -apple-system, "SF Arabic", "Vazirmatn", "Segoe UI", Tahoma, system-ui, sans-serif;
  display: flex; flex-direction: column; overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-decoration: none; }
h2 { font-size: 17px; margin: 18px 4px 8px; }
h3 { font-size: 15px; margin: 12px 0 4px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.pad { padding: 24px 16px; }
.ltr { direction: ltr; unicode-bidi: isolate; text-align: left; }
.auto { unicode-bidi: plaintext; text-align: start; }
.error { color: var(--danger); }
.ok { color: var(--ok); }
[hidden] { display: none !important; }

/* --- frame --------------------------------------------------------------------------------------- */
#bar {
  display: flex; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; min-height: 52px;
}
#title { flex: 1; font-weight: 700; font-size: 17px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#title small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); line-height: 1.2; }
#bar-actions { display: flex; gap: 2px; align-items: center; }
button.icon { background: none; border: 0; color: var(--ink); font-size: 22px; min-width: 40px; height: 40px; border-radius: 20px; padding: 0; cursor: pointer; }
/* "‹" is a mirrored character: in a right-to-left page it is drawn pointing right by itself. */
#back { font-size: 30px; line-height: 1; }
#banner { padding: 8px 14px; font-size: 13px; background: var(--warn-bg); color: var(--warn-ink); }
#banner.info { background: var(--accent-soft); color: var(--ink); }
#main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 12px calc(var(--tabs) + env(safe-area-inset-bottom) + 20px); }
#main.notabs { padding-bottom: calc(env(safe-area-inset-bottom) + 20px); }
#tabs {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 6; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); height: calc(var(--tabs) + env(safe-area-inset-bottom));
}
#tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; color: var(--muted); font-size: 11px; }
#tabs a .i { font-size: 21px; line-height: 1.25; filter: grayscale(1); opacity: .75; }
#tabs a.on { color: var(--accent); font-weight: 700; }
#tabs a.on .i { filter: none; opacity: 1; }

/* --- pieces -------------------------------------------------------------------------------------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.card.tap { cursor: pointer; }
.card.tap:active { background: var(--chip); }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.between { justify-content: space-between; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { background: var(--chip); border-radius: 999px; padding: 2px 11px; font-size: 13px; border: 0; color: var(--ink); white-space: nowrap; }
button.chip { cursor: pointer; padding: 6px 13px; font: inherit; font-size: 14px; }
.chip.on { background: var(--accent); color: var(--accent-ink); }
.chip.good { background: var(--accent-soft); }
.chip.bad { background: #fee2e2; color: #991b1b; }
.stars { color: #d97706; letter-spacing: 1px; white-space: nowrap; }
.stars button { background: none; border: 0; font-size: 26px; color: inherit; padding: 0 3px; cursor: pointer; }
.title { font-weight: 700; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.code { font-weight: 700; color: var(--accent); min-width: 42px; }

input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], input[type=tel], input[type=email], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink);
  font-size: 16px; /* under 16px, iOS zooms the page on focus */
  -webkit-appearance: none; appearance: none;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.6; }
label { display: block; font-size: 13px; color: var(--muted); margin: 8px 2px 3px; }
.form2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); cursor: pointer; font-weight: 600; min-height: 44px; }
.btn.block { display: flex; width: 100%; }
.btn.soft { background: var(--chip); color: var(--ink); font-weight: 500; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: none; color: var(--accent); }
.btn:disabled { opacity: .5; }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.actions.three { grid-template-columns: repeat(3, 1fr); }
.actions button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); cursor: pointer; font-size: 12.5px; color: var(--ink); }
.actions button .i { font-size: 24px; line-height: 1.2; }
.actions button:active { background: var(--chip); }
.fab { position: fixed; inset-inline-end: 16px; bottom: calc(var(--tabs) + env(safe-area-inset-bottom) + 14px); z-index: 4; box-shadow: 0 4px 14px rgba(0,0,0,.22); border-radius: 26px; padding: 12px 18px; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.ai { background: var(--chip); border-radius: 12px; padding: 10px 12px; margin: 6px 0; overflow-wrap: anywhere; }
.ai ul { margin: 4px 0; padding-inline-start: 20px; }
details > summary { cursor: pointer; color: var(--accent); padding: 6px 0; }
.transcript { white-space: pre-wrap; line-height: 1.9; }
hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }
.progress { height: 4px; border-radius: 2px; background: var(--chip); overflow: hidden; margin: 6px 0; }
.progress > i { display: block; height: 100%; width: 40%; background: var(--accent); border-radius: 2px; animation: slide 1.2s infinite ease-in-out; }
@keyframes slide { 0% { margin-inline-start: -40%; } 100% { margin-inline-start: 100%; } }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- media --------------------------------------------------------------------------------------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--chip); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 26px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* A picture not fetched yet keeps its place (so it is seen coming into view) but shows nothing. */
img.lazy { opacity: 0; }
.thumb .tag { position: absolute; inset-inline-start: 4px; bottom: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; border-radius: 6px; padding: 0 6px; }
.thumb .state { position: absolute; inset-inline-end: 4px; top: 4px; font-size: 13px; background: rgba(0,0,0,.55); color: #fff; border-radius: 9px; padding: 0 5px; }
.full img, .full video { width: 100%; border-radius: 12px; background: #000; display: block; }
audio { width: 100%; margin-top: 6px; }
.cover { width: 54px; height: 54px; border-radius: 10px; object-fit: cover; background: var(--chip); flex: none; display: flex; align-items: center; justify-content: center; font-size: 22px; overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: cover; }

/* --- talk ---------------------------------------------------------------------------------------- */
.turns { display: flex; flex-direction: column; gap: 8px; padding-bottom: 150px; }
.turn { max-width: 88%; border-radius: 16px; padding: 8px 12px; border: 1px solid var(--line); background: var(--card); }
.turn.me { align-self: flex-start; background: var(--accent-soft); border-color: transparent; }
.turn.them { align-self: flex-end; }
.turn .src { color: var(--muted); font-size: 14px; }
.turn .tr { font-size: 18px; line-height: 1.6; }
.turn .foot { display: flex; gap: 10px; align-items: center; margin-top: 2px; }
.turn .foot button { background: none; border: 0; font-size: 18px; padding: 2px 4px; cursor: pointer; color: var(--muted); }
.talkbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 7; background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px); display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.talkbar .who { border: 0; border-radius: 18px; padding: 14px 8px; font-size: 16px; font-weight: 700; cursor: pointer; min-height: 72px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.3; }
.talkbar .who small { font-weight: 400; font-size: 12px; opacity: .85; }
.talkbar .me { background: var(--accent); color: var(--accent-ink); }
.talkbar .them { background: #1d4ed8; color: #fff; }
.talkbar .who.rec { background: var(--rec); color: #fff; animation: pulse 1.1s infinite; }
.talkbar .who:disabled { opacity: .45; }
.talkbar .status { grid-column: 1 / -1; text-align: center; font-size: 13px; color: var(--muted); min-height: 20px; }
@keyframes pulse { 50% { opacity: .78; } }

.mic { width: 132px; height: 132px; border-radius: 66px; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 50px; cursor: pointer; display: block; margin: 18px auto 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); transition: transform .08s; }
.mic.rec { background: var(--rec); color: #fff; }
.mic:disabled { opacity: .5; }
.timer { font-size: 34px; font-variant-numeric: tabular-nums; text-align: center; direction: ltr; }
.level { height: 6px; background: var(--chip); border-radius: 3px; overflow: hidden; margin: 8px auto; max-width: 260px; }
.level > i { display: block; height: 100%; width: 0; background: var(--rec); transition: width .08s linear; }

/* --- sheet, toast -------------------------------------------------------------------------------- */
#sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
#sheet .box { background: var(--card); width: 100%; max-width: 640px; max-height: 92%; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 14px 16px calc(env(safe-area-inset-bottom) + 16px); }
#sheet .box h2 { margin: 2px 0 8px; }
#toast { position: fixed; inset-inline: 16px; bottom: calc(var(--tabs) + env(safe-area-inset-bottom) + 76px); z-index: 30; background: #1f2937; color: #fff; padding: 10px 14px; border-radius: 12px; text-align: center; font-size: 14px; box-shadow: 0 6px 18px rgba(0,0,0,.3); }
.login { max-width: 420px; margin: 6vh auto 0; }
.login h1 { font-size: 26px; margin: 0 0 4px; }
@media (min-width: 720px) {
  #main { max-width: 760px; margin: 0 auto; width: 100%; }
  .grid { grid-template-columns: repeat(5, 1fr); }
}

/* A meeting's minutes, printed (or saved as a PDF from the print sheet): only them, on white paper. */
#print { display: none; }
@media print {
  @page { size: A4; margin: 18mm 16mm; }
  html, body { background: #fff !important; }
  body > *:not(#print) { display: none !important; }
  #print { display: block; color: #111; font-size: 11pt; line-height: 1.65; }
  #print h1 { font-size: 18pt; color: #00695c; margin: 0 0 4pt; }
  #print h2 { font-size: 14pt; margin: 0 0 8pt; }
  #print h3 { font-size: 12pt; color: #00695c; margin: 14pt 0 4pt; break-after: avoid; }
  #print .meta { font-size: 10pt; color: #444; }
  #print hr { border: 0; border-top: 1px solid #bbb; margin: 10pt 0; }
  #print li { margin: 2pt 0; }
  #print footer { margin-top: 18pt; font-size: 8.5pt; color: #888; text-align: center; }
}
