/*
 * ApplyList design system.
 *
 * Every colour is a token below, defined once for light and once for dark.
 * Switching theme only swaps the tokens (html.dark), so components never need
 * `dark:` variants. Tailwind (CDN) is used for layout utilities only; its
 * colour names `canvas`, `surface`, `fg`, `muted`, … map onto these tokens.
 *
 * Tokens are bare RGB channels so they work with Tailwind's opacity modifier.
 */

:root {
  --canvas: 250 250 250;
  --surface: 255 255 255;
  --subtle: 244 244 245;
  --line: 228 228 231;
  --line-strong: 212 212 216;
  --fg: 24 24 27;
  --muted: 113 113 122;
  --faint: 161 161 170;

  --accent: 79 70 229;
  --accent-hover: 67 56 202;
  --accent-fg: 255 255 255;
  --accent-soft: 238 242 255;
  --accent-text: 67 56 202;

  --success: 21 128 61;
  --success-soft: 240 253 244;
  --warning: 180 83 9;
  --warning-soft: 255 251 235;
  --danger: 185 28 28;
  --danger-soft: 254 242 242;
  --info: 3 105 161;
  --info-soft: 240 249 255;

  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 1px 3px rgb(0 0 0 / 0.04);
  --shadow-lg: 0 8px 24px rgb(0 0 0 / 0.08);
  --radius: 10px;
  --radius-sm: 7px;

  color-scheme: light;
}

html.dark {
  --canvas: 9 9 11;
  --surface: 19 19 22;
  --subtle: 28 28 32;
  --line: 39 39 44;
  --line-strong: 58 58 64;
  --fg: 244 244 245;
  --muted: 161 161 170;
  --faint: 113 113 122;

  --accent: 129 140 248;
  --accent-hover: 165 180 252;
  --accent-fg: 15 15 30;
  --accent-soft: 30 30 58;
  --accent-text: 165 180 252;

  --success: 74 222 128;
  --success-soft: 20 40 28;
  --warning: 251 191 36;
  --warning-soft: 45 35 12;
  --danger: 248 113 113;
  --danger-soft: 50 20 22;
  --info: 56 189 248;
  --info-soft: 14 34 48;

  --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 8px 24px rgb(0 0 0 / 0.5);

  color-scheme: dark;
}

/* ── base ──────────────────────────────────────────────────── */

/* Self-hosted so Farsi pages don't depend on a font CDN reachable from Iran. */
@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  background: rgb(var(--canvas));
  color: rgb(var(--fg));
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", "Vazirmatn", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  /* Notch / home-indicator safe areas on iOS. */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  overflow-x: clip;
  max-width: 100%;
}
html[lang="fa"] body { font-family: "Vazirmatn", ui-sans-serif, system-ui, Tahoma, sans-serif; font-size: 14.5px; line-height: 1.75; }
html[lang="fa"] h1, html[lang="fa"] h2, html[lang="fa"] h3, html[lang="fa"] .hero-title { letter-spacing: 0; }
/* Only animate colours once the page has painted, so loading never "fades in" a theme. */
html.theme-ready body,
html.theme-ready .card,
html.theme-ready .input,
html.theme-ready .btn,
html.theme-ready .topbar { transition: background-color .15s ease, border-color .15s ease, color .15s ease; }

::selection { background: rgb(var(--accent) / 0.25); }
code, kbd, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
:focus-visible { outline: 2px solid rgb(var(--accent)); outline-offset: 2px; }

h1, h2, h3 { letter-spacing: -0.015em; }

.link { color: rgb(var(--accent-text)); text-decoration: none; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.link-muted { color: rgb(var(--muted)); }
.link-muted:hover { color: rgb(var(--fg)); text-decoration: underline; text-underline-offset: 3px; }

/* ── layout ────────────────────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgb(var(--surface) / 0.85);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid rgb(var(--line));
  padding-top: env(safe-area-inset-top);
}
/* Horizontal mobile nav under the brand row. */
.topbar-mobile-nav {
  display: flex; align-items: center; gap: .125rem;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding: 0 .75rem .5rem;
}
.topbar-mobile-nav::-webkit-scrollbar { display: none; }
.topbar-mobile-nav .nav-link {
  padding: .5rem .75rem;
  min-height: 2.25rem;
}
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 600; font-size: 15px; color: rgb(var(--fg)); }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; display: block; flex-shrink: 0;
}

.nav-link {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .4rem .7rem; border-radius: var(--radius-sm);
  color: rgb(var(--muted)); font-weight: 500; white-space: nowrap;
}
.nav-link:hover { color: rgb(var(--fg)); background: rgb(var(--subtle)); }
.nav-link.active { color: rgb(var(--fg)); background: rgb(var(--subtle)); }

.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-title { font-size: 1.5rem; line-height: 2rem; font-weight: 600; }
.page-subtitle { color: rgb(var(--muted)); margin-top: .15rem; }
.section-title { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: rgb(var(--muted)); margin-bottom: .75rem; }

.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid rgb(var(--line)); margin-bottom: 1.5rem; }
.tab {
  padding: .6rem .8rem; margin-bottom: -1px; white-space: nowrap;
  color: rgb(var(--muted)); font-weight: 500; border-bottom: 2px solid transparent;
}
.tab:hover { color: rgb(var(--fg)); }
.tab.active { color: rgb(var(--fg)); border-bottom-color: rgb(var(--fg)); }

.pills { display: inline-flex; gap: .25rem; padding: .2rem; border-radius: var(--radius); background: rgb(var(--subtle)); }
.pill { padding: .3rem .75rem; border-radius: var(--radius-sm); color: rgb(var(--muted)); font-weight: 500; }
.pill:hover { color: rgb(var(--fg)); }
.pill.active { background: rgb(var(--surface)); color: rgb(var(--fg)); box-shadow: var(--shadow); }

/* ── card ──────────────────────────────────────────────────── */

.card {
  background: rgb(var(--surface));
  border: 1px solid rgb(var(--line));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-body { padding: 1.25rem; }
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .85rem 1.25rem; border-bottom: 1px solid rgb(var(--line));
}
.card-title { font-weight: 600; }
.card-footer { padding: .85rem 1.25rem; border-top: 1px solid rgb(var(--line)); background: rgb(var(--subtle) / 0.5); border-radius: 0 0 var(--radius) var(--radius); }
a.card:hover { border-color: rgb(var(--line-strong)); }
.card-danger { border-color: rgb(var(--danger) / 0.35); }

.divide > * + * { border-top: 1px solid rgb(var(--line)); }

/* ── stats ─────────────────────────────────────────────────── */

.stat { padding: 1rem 1.1rem; }
.stat-label { font-size: .75rem; color: rgb(var(--muted)); font-weight: 500; }
.stat-value { margin-top: .2rem; font-size: 1.5rem; line-height: 2rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat-hint { font-size: .75rem; color: rgb(var(--faint)); }

/* ── buttons ───────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  height: 36px; padding: 0 .9rem; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; line-height: 1; white-space: nowrap;
  border: 1px solid transparent; cursor: pointer; user-select: none;
  background: rgb(var(--surface)); color: rgb(var(--fg));
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-sm { height: 30px; padding: 0 .65rem; font-size: 13px; }
.btn-lg { height: 42px; padding: 0 1.2rem; font-size: 15px; }
.btn-block { width: 100%; }

.btn-primary { background: rgb(var(--fg)); color: rgb(var(--canvas)); }
.btn-primary:hover:not(:disabled) { background: rgb(var(--fg) / 0.85); }
.btn-accent { background: rgb(var(--accent)); color: rgb(var(--accent-fg)); }
.btn-accent:hover:not(:disabled) { background: rgb(var(--accent-hover)); }
.btn-secondary { border-color: rgb(var(--line-strong)); box-shadow: var(--shadow); }
.btn-secondary:hover:not(:disabled) { background: rgb(var(--subtle)); }
.btn-ghost { background: transparent; color: rgb(var(--muted)); }
.btn-ghost:hover:not(:disabled) { background: rgb(var(--subtle)); color: rgb(var(--fg)); }
.btn-danger { background: rgb(var(--danger)); color: #fff; }
html.dark .btn-danger { color: rgb(var(--canvas)); }
.btn-danger:hover:not(:disabled) { background: rgb(var(--danger) / 0.88); }
.btn-danger-ghost { background: transparent; color: rgb(var(--danger)); }
.btn-danger-ghost:hover:not(:disabled) { background: rgb(var(--danger-soft)); }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border-radius: var(--radius-sm); color: rgb(var(--muted)); background: transparent; border: 1px solid transparent;
}
.icon-btn:hover { color: rgb(var(--fg)); background: rgb(var(--subtle)); }

/* ── forms ─────────────────────────────────────────────────── */

.field { display: grid; gap: .35rem; }
.label { font-size: 13px; font-weight: 500; color: rgb(var(--fg)); }
.label-optional { font-weight: 400; color: rgb(var(--faint)); }
.hint { font-size: 12px; color: rgb(var(--muted)); }

.input {
  width: 100%; height: 36px; padding: 0 .7rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgb(var(--line-strong));
  background: rgb(var(--surface)); color: rgb(var(--fg));
  font-size: 14px; box-shadow: var(--shadow);
}
/* iOS Safari zooms the page when focusing inputs under 16px. */
@media (max-width: 640px) {
  .input, textarea.input, select.input { font-size: 16px; }
  .input-sm { font-size: 16px; height: 36px; }
}
.input::placeholder { color: rgb(var(--faint)); }
.input:focus { outline: none; border-color: rgb(var(--accent)); box-shadow: 0 0 0 3px rgb(var(--accent) / 0.18); }
textarea.input { height: auto; padding: .55rem .7rem; line-height: 1.5; resize: vertical; }
select.input {
  appearance: none; -webkit-appearance: none; padding-inline-end: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .55rem center;
}
.input-sm { height: 30px; font-size: 13px; }
input[type="file"].input { height: auto; padding: .3rem; font-size: 13px; }
input[type="file"].input::file-selector-button {
  margin-inline-end: .6rem; padding: .3rem .7rem; border-radius: 5px; border: 0;
  background: rgb(var(--subtle)); color: rgb(var(--fg)); font-weight: 500; cursor: pointer;
}

.checkbox {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 16px; height: 16px; border-radius: 4px; margin: 0;
  border: 1px solid rgb(var(--line-strong)); background: rgb(var(--surface));
  display: inline-grid; place-content: center; cursor: pointer;
}
.checkbox:checked { background: rgb(var(--accent)); border-color: rgb(var(--accent)); }
.checkbox:checked::after {
  content: ""; width: 9px; height: 9px;
  background: rgb(var(--accent-fg));
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
.check { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; }

.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem; }

.bulk-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem;
  padding: .65rem 1rem; border-bottom: 1px solid rgb(var(--line));
  background: rgb(var(--accent-soft));
}
.bulk-bar.hidden { display: none; }
.table .cell-check { width: 2.5rem; vertical-align: middle; }

/* ── tables ────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: start; font-size: 12px; font-weight: 500; color: rgb(var(--muted));
  padding: .6rem 1rem; background: rgb(var(--subtle) / 0.6);
  border-bottom: 1px solid rgb(var(--line)); white-space: nowrap;
}
.table td { padding: .7rem 1rem; border-bottom: 1px solid rgb(var(--line)); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: rgb(var(--subtle) / 0.45); }
.table .num { text-align: end; font-variant-numeric: tabular-nums; }
.cell-muted { color: rgb(var(--muted)); }

/* Professors list: keep actions in reach on wide tables and phone cards. */
.table-contacts { table-layout: fixed; }
.table-contacts .contact-name {
  display: inline-flex; align-items: center; gap: .45rem; font-weight: 500; min-width: 0; max-width: 100%;
}
.table-contacts .contact-name bdi {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.contact-actions {
  display: flex; align-items: center; gap: .35rem; justify-content: flex-end; flex-wrap: nowrap;
}
.table-contacts .contact-status {
  display: inline-flex; align-items: center; flex-wrap: wrap; gap: .35rem;
}
.table-contacts .cell-uni,
.table-contacts .cell-focus,
.table-contacts .cell-email {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.table-contacts .cell-email .link {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.table-contacts .cell-check { width: 2.5rem; }
.table-contacts .cell-status { width: 9.5rem; }
.table-contacts .cell-actions,
.table .cell-actions {
  position: sticky; inset-inline-end: 0; z-index: 1;
  background: rgb(var(--surface));
  width: 7.5rem;
}
.table-contacts tbody tr:hover .cell-actions,
.table tbody tr:hover .cell-actions { background: rgb(var(--subtle) / 0.45); }

/* Options menu — positioned in the viewport so it cannot widen the page. */
.menu { position: relative; display: inline-block; }
.menu > summary {
  list-style: none; cursor: pointer;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: fixed; z-index: 60;
  min-width: 12rem; max-width: min(18rem, calc(100vw - 1.5rem)); padding: .3rem;
  background: rgb(var(--surface));
  border: 1px solid rgb(var(--line));
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 28px rgb(0 0 0 / 0.12);
  /* Fallback before JS places it; keep it on-screen. */
  inset-inline-end: .75rem; top: auto;
}
.menu-panel a,
.menu-panel button {
  display: flex; align-items: center; gap: .55rem; width: 100%;
  padding: .5rem .65rem; border-radius: calc(var(--radius-sm) - 2px);
  font-size: 13px; font-weight: 500; color: rgb(var(--fg));
  background: transparent; border: 0; text-align: start; cursor: pointer;
  white-space: nowrap;
}
.menu-panel a:hover,
.menu-panel button:hover { background: rgb(var(--subtle)); }
.menu-panel .text-danger { color: rgb(var(--danger)); }
.menu-panel form { margin: 0; }

/* ── badges ────────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  height: 22px; padding: 0 .5rem; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  background: rgb(var(--subtle)); color: rgb(var(--muted));
  border: 1px solid rgb(var(--line));
}
.badge-accent  { background: rgb(var(--accent-soft));  color: rgb(var(--accent-text)); border-color: rgb(var(--accent) / 0.25); }
.badge-success { background: rgb(var(--success-soft)); color: rgb(var(--success));     border-color: rgb(var(--success) / 0.25); }
.badge-warning { background: rgb(var(--warning-soft)); color: rgb(var(--warning));     border-color: rgb(var(--warning) / 0.25); }
.badge-danger  { background: rgb(var(--danger-soft));  color: rgb(var(--danger));      border-color: rgb(var(--danger) / 0.25); }
.badge-info    { background: rgb(var(--info-soft));    color: rgb(var(--info));        border-color: rgb(var(--info) / 0.25); }
.badge-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; border-radius: 5px; }

.dot { width: 7px; height: 7px; border-radius: 999px; display: inline-block; background: rgb(var(--line-strong)); flex: none; }
.dot-success { background: rgb(var(--success)); }
.dot-warning { background: rgb(var(--warning)); }
.dot-danger  { background: rgb(var(--danger)); }

/* A status toggle rendered as a badge-shaped button. */
.toggle-chip { cursor: pointer; }
.toggle-chip:hover { border-color: rgb(var(--line-strong)); }

/* A <select> that looks like a badge. */
.badge-select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  height: 24px; padding-block: 0; padding-inline: .55rem 1.4rem; border-radius: 999px;
  font-size: 12px; font-weight: 500;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 4.5 3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .4rem center;
}

/* ── alerts ────────────────────────────────────────────────── */

.alert {
  display: flex; gap: .65rem; align-items: flex-start;
  padding: .75rem 1rem; border-radius: var(--radius);
  border: 1px solid rgb(var(--line)); background: rgb(var(--surface));
  font-size: 14px;
}
.alert svg { flex: none; margin-top: 2px; }
.alert-success { background: rgb(var(--success-soft)); border-color: rgb(var(--success) / 0.3); color: rgb(var(--success)); }
.alert-warning { background: rgb(var(--warning-soft)); border-color: rgb(var(--warning) / 0.3); color: rgb(var(--warning)); }
.alert-error   { background: rgb(var(--danger-soft));  border-color: rgb(var(--danger) / 0.3);  color: rgb(var(--danger)); }
.alert-info    { background: rgb(var(--info-soft));    border-color: rgb(var(--info) / 0.3);    color: rgb(var(--info)); }
.alert a { text-decoration: underline; text-underline-offset: 2px; }
.alert code { font-size: 12.5px; }

/* ── misc ──────────────────────────────────────────────────── */

.empty { padding: 3rem 1.5rem; text-align: center; }
.empty-icon {
  width: 40px; height: 40px; margin: 0 auto .9rem; border-radius: 10px;
  display: grid; place-items: center;
  background: rgb(var(--subtle)); color: rgb(var(--muted)); border: 1px solid rgb(var(--line));
}
.empty-title { font-weight: 600; }
.empty-text { color: rgb(var(--muted)); margin-top: .25rem; }

.kbd {
  display: inline-block; padding: 0 .35rem; border-radius: 4px; font-size: 11px;
  border: 1px solid rgb(var(--line-strong)); color: rgb(var(--muted)); background: rgb(var(--subtle));
}

.progress { height: 6px; border-radius: 999px; background: rgb(var(--subtle)); overflow: hidden; }
.progress > span { display: block; height: 100%; background: rgb(var(--accent)); border-radius: 999px; }

.dl { display: grid; gap: .6rem; }
.dl > div { display: flex; justify-content: space-between; gap: 1rem; }
.dl dt { color: rgb(var(--muted)); }
.dl dd { font-weight: 500; text-align: end; }

.bar-chart { display: flex; align-items: flex-end; gap: 3px; height: 120px; }
.bar-chart > div { flex: 1; min-height: 2px; background: rgb(var(--accent) / 0.75); border-radius: 3px 3px 0 0; }
.bar-chart > div:hover { background: rgb(var(--accent)); }

.hero-title { font-size: clamp(2rem, 5vw, 3.25rem); line-height: 1.08; font-weight: 650; letter-spacing: -0.035em; }

.feature-icon {
  width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center;
  background: rgb(var(--accent-soft)); color: rgb(var(--accent-text));
}

/* Chat */
.bubble { max-width: 46rem; padding: .75rem 1rem; border-radius: 14px; line-height: 1.6; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble-user { background: rgb(var(--fg)); color: rgb(var(--canvas)); border-end-end-radius: 4px; }
.bubble-assistant { background: rgb(var(--surface)); border: 1px solid rgb(var(--line)); border-end-start-radius: 4px; box-shadow: var(--shadow); }
.bubble-meta { margin-top: .5rem; padding-top: .5rem; border-top: 1px solid rgb(var(--line)); display: flex; gap: .9rem; font-size: 12px; color: rgb(var(--faint)); }

.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

[x-cloak] { display: none !important; }
summary::-webkit-details-marker { display: none; }
html.dark .show-light, html:not(.dark) .show-dark { display: none; }
.show-light, .show-dark { display: inline-flex; }

.spinner {
  width: 11px; height: 11px; border-radius: 999px; flex: none; display: inline-block;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }


/* ── right-to-left ─────────────────────────────────────────── */

[dir="rtl"] select.input { background-position: left .55rem center; }
[dir="rtl"] .badge-select { background-position: left .4rem center; }
/* Directional icons (arrows) point the other way in RTL. */
[dir="rtl"] .rtl-flip { transform: scaleX(-1); }
/* Addresses, URLs and code read left-to-right inside Farsi text. */
.ltr, input[type="email"], input[type="url"], .mono, code { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] input[type="email"], [dir="rtl"] input[type="url"] { text-align: right; }
[dir="rtl"] input[type="email"]::placeholder, [dir="rtl"] input[type="url"]::placeholder { text-align: right; }

/* ── search field with an icon ─────────────────────────────── */

.search { position: relative; }
.search > svg { position: absolute; inset-inline-start: .65rem; top: 50%; transform: translateY(-50%); color: rgb(var(--faint)); pointer-events: none; }
.search > .input { padding-inline-start: 2rem; }

/* ── disclosure panels ("Add a contact") ───────────────────── */

details.panel > summary { list-style: none; cursor: pointer; }
details.panel[open] > summary .when-closed, details.panel:not([open]) > summary .when-open { display: none; }

/* ── flash dismiss ─────────────────────────────────────────── */

.alert .alert-close { margin-inline-start: auto; opacity: .6; background: none; border: 0; color: inherit; cursor: pointer; padding: 0 .1rem; }
.alert .alert-close:hover { opacity: 1; }

/* ── checklist ─────────────────────────────────────────────── */

.checklist { display: grid; gap: .1rem; }
.checklist a, .checklist div { display: flex; align-items: center; gap: .65rem; padding: .55rem .6rem; border-radius: var(--radius-sm); }
.checklist a:hover { background: rgb(var(--subtle)); }
.check-dot {
  width: 20px; height: 20px; flex: none; border-radius: 999px; display: grid; place-items: center;
  border: 1.5px solid rgb(var(--line-strong)); color: transparent;
}
.done .check-dot { background: rgb(var(--success)); border-color: rgb(var(--success)); color: rgb(var(--surface)); }
.done .check-label { color: rgb(var(--muted)); text-decoration: line-through; }

/* ── blog article body ─────────────────────────────────────── */

.prose { line-height: 1.7; color: rgb(var(--fg)); }
.prose > * + * { margin-top: 1rem; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; margin-top: 1.75rem;
}
.prose h1 { font-size: 1.5rem; }
.prose h2 { font-size: 1.25rem; }
.prose h3 { font-size: 1.1rem; }
.prose p { color: rgb(var(--muted)); }
.prose a { color: rgb(var(--accent-text)); text-decoration: underline; text-underline-offset: 2px; }
.prose ul, .prose ol { padding-inline-start: 1.35rem; color: rgb(var(--muted)); }
.prose li + li { margin-top: 0.35rem; }
.prose blockquote {
  border-inline-start: 3px solid rgb(var(--line-strong));
  padding-inline-start: 1rem; color: rgb(var(--muted)); font-style: italic;
}
.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em; background: rgb(var(--subtle)); padding: 0.1em 0.35em; border-radius: 4px;
}
.prose pre {
  background: rgb(var(--subtle)); border: 1px solid rgb(var(--line));
  border-radius: var(--radius-sm); padding: 0.9rem 1rem; overflow-x: auto; direction: ltr;
}
.prose pre code { background: none; padding: 0; }
.prose hr { border: 0; border-top: 1px solid rgb(var(--line)); margin: 1.5rem 0; }
.prose img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid rgb(var(--line));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Install prompt. Hidden until the browser can install, or until iOS needs steps. */
.pwa-install {
  position: fixed;
  z-index: 40;
  inset-inline: 1rem;
  bottom: max(1rem, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 0.9rem;
  background: rgb(var(--surface));
  color: rgb(var(--fg));
  border: 1px solid rgb(var(--line));
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.pwa-install[hidden] { display: none; }
.pwa-install p { margin: 0; flex: 1; min-width: 0; }
.pwa-install p strong { display: block; font-size: 0.875rem; }
.pwa-install p span { display: block; margin-top: 0.15rem; color: rgb(var(--muted)); font-size: 0.8rem; line-height: 1.45; }
@media (min-width: 640px) {
  .pwa-install {
    inset-inline: auto;
    left: 50%;
    transform: translateX(-50%);
    width: min(36rem, calc(100% - 2rem));
  }
}

/* ── tables that become cards on phones ────────────────────── */

@media (max-width: 720px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: .8rem 1rem; border-bottom: 1px solid rgb(var(--line)); }
  .table-stack tbody tr:last-child { border-bottom: 0; }
  .table-stack td {
    border: 0; padding: .2rem 0; max-width: none !important;
    white-space: normal !important; overflow: visible !important; text-overflow: clip !important;
  }
  .table-stack td[data-label]::before {
    content: attr(data-label); display: inline-block; min-width: 6.5rem;
    color: rgb(var(--muted)); font-size: 12px;
  }
  .table-stack td.cell-title { font-size: 15px; padding-bottom: .35rem; }
  .table-stack td.cell-actions > div { justify-content: flex-start; margin-top: .35rem; }
  .table-stack td.cell-check { padding-bottom: .5rem; }
  .table-stack td.cell-check::before { display: none !important; }
  .table-stack tbody tr:hover td { background: transparent; }

  /* Professors: name + actions on the first row; status chips stay visible. */
  .table-contacts.table-stack tr {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "check title actions"
      "status status status"
      ". uni uni"
      ". focus focus"
      ". email email";
    column-gap: .55rem;
    row-gap: .2rem;
    align-items: center;
    padding: .85rem 1rem;
  }
  .table-contacts.table-stack td {
    width: auto;
    padding: 0;
  }
  .table-contacts.table-stack td[data-label]::before { display: none; }
  .table-contacts.table-stack .cell-check {
    grid-area: check; padding: 0; align-self: center;
  }
  .table-contacts.table-stack .cell-title {
    grid-area: title; font-size: 15px; padding: 0; min-width: 0;
  }
  .table-contacts.table-stack .contact-name {
    display: flex; width: 100%;
  }
  .table-contacts.table-stack .contact-name bdi {
    flex: 1 1 auto; max-width: none;
  }
  .table-contacts.table-stack .cell-actions {
    grid-area: actions;
    position: static;
    background: transparent;
    justify-self: end;
  }
  .table-contacts.table-stack .contact-actions {
    margin: 0; justify-content: flex-end;
  }
  .table-stack .cell-actions { position: static; background: transparent; }
  .table-contacts.table-stack .cell-uni {
    grid-area: uni; color: rgb(var(--muted)); font-size: 13px;
  }
  .table-contacts.table-stack .cell-focus {
    grid-area: focus; font-size: 13px;
    overflow: hidden !important; text-overflow: ellipsis !important;
    white-space: nowrap !important; max-width: 100% !important;
  }
  .table-contacts.table-stack .cell-email {
    grid-area: email; font-size: 13px; min-width: 0;
  }
  .table-contacts.table-stack .cell-email .link {
    display: inline-block; max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;
  }
  .table-contacts.table-stack .cell-status {
    grid-area: status; margin-block: .3rem .15rem;
  }
  .table-contacts.table-stack .contact-sent-date { display: none; }
  .table-contacts.table-stack tbody tr:hover .cell-actions { background: transparent; }

  /* Toolbar search boxes: full width instead of a fixed desktop width. */
  .toolbar .search { flex: 1 1 100%; min-width: 0; }
  .toolbar .search > .input { width: 100%; }
}

/* Enamad trust seal in the site footer */
.enamad-seal {
  display: block;
  width: 80px;
  height: auto;
  cursor: pointer;
}
