@font-face {
  font-family: Vazir;
  src: url("../fonts/Vazir.woff2") format("woff2");
  font-weight: 400;
}
@font-face {
  font-family: Vazir;
  src: url("../fonts/Vazir-Bold.woff2") format("woff2");
  font-weight: 700;
}

:root {
  color-scheme: dark;
  --bg: #0d1218;
  --surface: #151d27;
  --surface-2: #1d2835;
  --ink: #edf3f8;
  --muted: #9facbb;
  --line: #2a3745;
  --teal: #14b8a6;
  --teal-2: #14b8a6;
  --teal-3: #2dd4bf;
  --amber: #f8b84e;
  --red: #f87171;
  --green: #22c55e;
  --header-bg: rgba(21, 29, 39, .88);
  --footer-bg: rgba(21, 29, 39, .78);
  --hero-start: #18232f;
  --hero-end: #102f2d;
  --media-empty-bg: #102f2d;
  --timer-bg: #111923;
  --ring-bg-color: #2e3b49;
  --progress-bg: #2e3b49;
  --nav-hover-bg: #102f2d;
  --table-head-bg: #111923;
  --input-bg: #111923;
  --code-bg: #202b38;
  --switch-bg: #334155;
  --switch-knob: #f8fafc;
  --toast-bg: #edf3f8;
  --toast-ink: #0d1218;
  --alert-bg: #102f2d;
  --alert-border: rgba(20,184,166,.35);
  --alert-error-bg: #35171b;
  --alert-error-border: #7f1d1d;
  --alert-error-ink: #fecaca;
  --alert-success-bg: #10291d;
  --alert-success-border: #166534;
  --alert-success-ink: #bbf7d0;
  --shadow: 0 18px 42px rgba(0, 0, 0, .24);
  --radius: 8px;
  --container: 1180px;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #eef6f7;
  --ink: #172033;
  --muted: #657184;
  --line: #dce3ea;
  --teal: #0f766e;
  --teal-2: #14b8a6;
  --teal-3: #115e59;
  --amber: #f59e0b;
  --red: #dc2626;
  --green: #16a34a;
  --header-bg: rgba(255,255,255,.88);
  --footer-bg: rgba(255,255,255,.8);
  --hero-start: #ffffff;
  --hero-end: #e8f8f7;
  --media-empty-bg: #ecfeff;
  --timer-bg: #fbfcfd;
  --ring-bg-color: #e4e9ef;
  --progress-bg: #e4e9ef;
  --nav-hover-bg: #ecfeff;
  --table-head-bg: #fbfcfd;
  --input-bg: #ffffff;
  --code-bg: #eef2f7;
  --switch-bg: #d9e0e8;
  --switch-knob: #ffffff;
  --toast-bg: #172033;
  --toast-ink: #ffffff;
  --alert-bg: #ecfeff;
  --alert-border: rgba(20,184,166,.35);
  --alert-error-bg: #fef2f2;
  --alert-error-border: #fecaca;
  --alert-error-ink: #991b1b;
  --alert-success-bg: #f0fdf4;
  --alert-success-border: #bbf7d0;
  --alert-success-ink: #14532d;
  --shadow: 0 16px 40px rgba(23, 32, 51, .08);
}

* { box-sizing: border-box; }
html { font-family: Vazir, Tahoma, Arial, sans-serif; color: var(--ink); background: var(--bg); }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(15,118,110,.08), transparent 36%),
    linear-gradient(315deg, rgba(245,158,11,.08), transparent 34%);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; display: block; }
.ltr { direction: ltr; text-align: left; unicode-bidi: plaintext; }
.container { width: min(var(--container), calc(100% - 32px)); margin: 0 auto; position: relative; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.header-inner { height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; }
.brand img { width: 34px; height: 34px; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.primary-button,
.secondary-button,
.icon-button,
.icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 700;
  transition: .16s ease;
}
.primary-button { color: #fff; background: var(--teal); box-shadow: 0 10px 22px rgba(15,118,110,.2); }
.primary-button:hover { background: var(--teal-3); transform: translateY(-1px); }
.primary-button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.secondary-button, .icon-button { color: var(--ink); background: var(--surface); border-color: var(--line); }
.secondary-button:hover, .icon-button:hover, .icon-only:hover { border-color: var(--teal-2); color: var(--teal); }
.compact { min-height: 38px; padding-inline: 12px; }
.wide { width: 100%; }
.icon-only { width: 38px; height: 38px; min-height: 38px; padding: 0; background: var(--surface); border-color: var(--line); }
.danger { color: var(--red); }
.theme-toggle i { width: 1em; }
.theme-label { display: none; }

.home-hero { padding: 48px 0 20px; }
.hero-grid {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 28px;
  align-items: center;
  min-height: 250px;
}
.hero-copy h1 { margin: 0 0 14px; font-size: clamp(2rem, 4vw, 4.2rem); line-height: 1.25; letter-spacing: 0; }
.hero-copy p { margin: 0; max-width: 680px; color: var(--muted); font-size: 1.08rem; }
.hero-mark {
  border-radius: 28px;
  background: linear-gradient(180deg, var(--hero-start), var(--hero-end));
  border: 1px solid var(--line);
  padding: 36px;
  box-shadow: var(--shadow);
}
.section { padding: 28px 0 64px; }
.section-head { display: flex; align-items: end; justify-content: space-between; margin-bottom: 18px; gap: 16px; }
.section-head h2, .admin-title h1 { margin: 0 0 6px; font-size: 1.55rem; }
.section-head p, .admin-title p { margin: 0; color: var(--muted); }

.link-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.link-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: .16s ease;
}
.link-card:hover { transform: translateY(-3px); border-color: rgba(20,184,166,.7); }
.card-id {
  position: absolute;
  z-index: 2;
  top: 10px;
  left: 10px;
  max-width: calc(100% - 20px);
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(23,32,51,.84);
  color: #fff;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: .78rem;
}
.card-media { aspect-ratio: 16/9; background: var(--surface-2); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.media-empty { min-height: 130px; display: grid; place-items: center; color: var(--teal); background: var(--media-empty-bg); font-size: 2rem; }
.media-empty.large { min-height: 100%; font-size: 4rem; }
.card-body { padding: 14px; }
.card-body h3 { margin: 0 0 8px; font-size: 1.05rem; }
.card-body p { margin: 0; color: var(--muted); font-size: .92rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { border-top: 1px solid var(--line); padding: 11px 14px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: .88rem; }

.forward-shell { padding: 42px 0 70px; }
.forward-panel {
  display: grid;
  grid-template-columns: minmax(280px, 45%) 1fr;
  gap: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.forward-media { min-height: 420px; background: var(--surface-2); }
.forward-media img { width: 100%; height: 100%; object-fit: cover; }
.forward-content { padding: 30px; display: grid; align-content: center; gap: 18px; }
.forward-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: .9rem; }
.host { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(22,163,74,.12); }
.forward-content h1 { margin: 0; font-size: clamp(1.7rem, 3vw, 3rem); line-height: 1.25; }
.forward-content p { margin: 0; color: var(--muted); }
.timer-box { display: grid; justify-items: center; gap: 8px; padding: 18px; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--timer-bg); }
.timer-ring { transform: rotate(-90deg); }
.ring-bg, .ring-fg { fill: none; stroke-width: 8; }
.ring-bg { stroke: var(--ring-bg-color); }
.ring-fg { stroke: var(--teal); stroke-linecap: round; stroke-dasharray: 226 226; stroke-dashoffset: 226; transition: stroke-dashoffset .2s linear; }
.timer-box strong { font-size: 2.2rem; line-height: 1; }
.timer-box span { color: var(--muted); font-size: .9rem; text-align: center; }
.progress-line { height: 6px; background: var(--progress-bg); border-radius: 99px; overflow: hidden; }
.progress-line span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--teal), var(--amber)); transition: width .2s linear; }

.admin-shell { display: grid; grid-template-columns: 250px 1fr; gap: 18px; padding: 24px 0 64px; align-items: start; }
.admin-nav {
  position: sticky;
  top: 84px;
  display: grid;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}
.admin-user { display: flex; gap: 10px; align-items: center; padding: 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.admin-user i { color: var(--teal); font-size: 1.2rem; }
.admin-user span { display: block; color: var(--muted); font-size: .82rem; }
.nav-link { width: 100%; min-height: 42px; border: 0; border-radius: var(--radius); background: transparent; color: var(--muted); display: flex; align-items: center; gap: 10px; padding: 0 10px; cursor: pointer; }
.nav-link:hover { background: var(--nav-hover-bg); color: var(--teal); }
.admin-content { min-width: 0; display: grid; gap: 16px; }
.admin-title { display: flex; justify-content: space-between; align-items: end; gap: 16px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat, .panel-block, .table-wrap, .editor-form, .empty-state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat { padding: 18px; display: grid; gap: 8px; }
.stat i { color: var(--teal); font-size: 1.25rem; }
.stat span { color: var(--muted); }
.stat strong { font-size: 2rem; line-height: 1; }
.panel-block { padding: 18px; }
.panel-block h2 { margin: 0 0 8px; font-size: 1.15rem; }
.panel-block p { margin: 0; color: var(--muted); }
.code { padding: 2px 6px; background: var(--code-bg); border-radius: 5px; color: var(--ink); }
.toolbar { display: flex; justify-content: space-between; gap: 12px; }
.search-box { display: flex; align-items: center; gap: 8px; min-width: min(100%, 440px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 12px; }
.search-box input { width: 100%; height: 42px; border: 0; outline: 0; background: transparent; }
.table-wrap { overflow: auto; }
.admin-table { width: 100%; border-collapse: collapse; min-width: 900px; }
.admin-table th, .admin-table td { text-align: right; padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table th { color: var(--muted); font-size: .86rem; font-weight: 700; background: var(--table-head-bg); }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table small { display: block; max-width: 260px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table-thumb { width: 74px; height: 46px; object-fit: cover; border-radius: 6px; }
.thumb-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 6px; background: var(--media-empty-bg); color: var(--teal); }
.url-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions-cell { display: flex; gap: 6px; }
.switch { width: 46px; height: 26px; border: 1px solid var(--line); border-radius: 99px; background: var(--switch-bg); position: relative; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--switch-knob); transition: .16s ease; }
.switch.active { background: rgba(20,184,166,.35); border-color: var(--teal-2); }
.switch.active::after { right: 23px; }

.editor-form { padding: 18px; display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid label { display: grid; gap: 7px; color: var(--muted); font-size: .9rem; }
.form-grid .wide { grid-column: 1 / -1; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal-2); box-shadow: 0 0 0 4px rgba(20,184,166,.13); }
label small { color: var(--muted); font-size: .8rem; }
.preview-row { border: 1px dashed var(--line); border-radius: var(--radius); padding: 10px; }
.preview-row img, .preview-row .media-empty { width: 100%; max-height: 260px; object-fit: cover; border-radius: 6px; }
.upload-state { display: grid; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.upload-state[hidden] { display: none; }
.upload-details { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .88rem; }
.upload-progress { height: 8px; background: var(--progress-bg); border-radius: 99px; overflow: hidden; }
.upload-progress span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--teal), var(--amber)); transition: width .16s ease; }
.upload-state small { color: var(--muted); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.alert { padding: 12px 14px; border-radius: var(--radius); background: var(--alert-bg); border: 1px solid var(--alert-border); }
.alert.error { color: var(--alert-error-ink); background: var(--alert-error-bg); border-color: var(--alert-error-border); }
.alert.success { color: var(--alert-success-ink); background: var(--alert-success-bg); border-color: var(--alert-success-border); }
.empty-state { min-height: 260px; display: grid; place-items: center; align-content: center; gap: 10px; padding: 30px; text-align: center; }
.empty-state i { font-size: 2.5rem; color: var(--teal); }
.empty-state h1, .empty-state h3, .empty-state p { margin: 0; }
.empty-state p { color: var(--muted); }
.toast { position: fixed; bottom: 16px; inset-inline: 16px; display: grid; place-items: center; z-index: 40; pointer-events: none; }
.toast-message { background: var(--toast-bg); color: var(--toast-ink); border-radius: var(--radius); padding: 10px 14px; box-shadow: var(--shadow); pointer-events: auto; }
.site-footer { margin-top: auto; border-top: 1px solid var(--line); background: var(--footer-bg); }
.footer-inner { min-height: 62px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); gap: 12px; }

@media (max-width: 920px) {
  .hero-grid, .forward-panel, .admin-shell { grid-template-columns: 1fr; }
  .hero-mark { max-width: 180px; justify-self: start; }
  .link-grid, .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-nav { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-user { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .container { width: min(100% - 22px, var(--container)); }
  .header-inner { height: auto; padding: 10px 0; align-items: flex-start; }
  .header-actions span { display: none; }
  .home-hero { padding-top: 30px; }
  .link-grid, .stats-grid, .form-grid, .admin-nav { grid-template-columns: 1fr; }
  .forward-media { min-height: 230px; }
  .forward-content { padding: 20px; }
  .footer-inner, .admin-title { align-items: flex-start; flex-direction: column; }
}
