@font-face {
  font-family: "Vazirmatn";
  src: url("/fonts/vazirmatn/vazirmatn-arabic-variable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0600-06FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE80-FEFC;
}

@font-face {
  font-family: "Vazirmatn";
  src: url("/fonts/vazirmatn/vazirmatn-latin-variable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --sand: #efe4d4;
  --paper: #fff8ef;
  --ink: #241c16;
  --ink-soft: #5a4a3c;
  --clay: #c24b32;
  --clay-deep: #9a331e;
  --brass: #c0944a;
  --indigo: #3b4a6b;
  --line: rgba(36, 28, 22, 0.14);
  --stamp: 6px 6px 0 var(--ink);
  --radius-sheet: 28px 10px 28px 10px;
  --radius-pill: 999px;
  --shadow-soft: 0 18px 40px rgba(36, 28, 22, 0.08);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
html {
  background: var(--sand);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  color: var(--ink);
  font-family: Vazirmatn, Tahoma, sans-serif;
  background:
    radial-gradient(900px 420px at 12% -8%, rgba(194, 75, 50, 0.16), transparent 55%),
    radial-gradient(700px 380px at 110% 8%, rgba(59, 74, 107, 0.12), transparent 50%),
    repeating-linear-gradient(-18deg, rgba(36, 28, 22, 0.035) 0 1px, transparent 1px 14px),
    var(--sand);
  line-height: 1.7;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}
img { display: block; max-width: 100%; }
a { color: inherit; }
button, input { font-family: inherit; }
button { cursor: pointer; }
h1, h2, h3 { line-height: 1.25; margin: 0; }

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--clay);
  font-weight: 700;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  padding: 11px 18px;
  border-radius: 12px 4px 12px 4px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn-stamp {
  background: var(--clay);
  color: #fff8ef;
  border-color: var(--ink);
  min-height: 52px;
  padding-inline: 22px;
}
.btn-stamp:hover { background: var(--clay-deep); }
.btn-ghost {
  background: transparent;
  box-shadow: none;
  min-height: 44px;
}
.btn-tiny {
  padding: 7px 12px;
  font-size: 13px;
  box-shadow: 3px 3px 0 var(--ink);
  min-height: 36px;
}
.btn-danger {
  background: #f4e1d8;
  color: var(--clay-deep);
}
.btn-edit { background: #ece6d8; }

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 700;
  font-size: 13px;
}
.field span { color: var(--ink-soft); }
.field input {
  width: 100%;
  border: 2px solid var(--ink);
  background: #fffdf9;
  color: var(--ink);
  border-radius: 14px 6px 14px 6px;
  padding: 13px 14px;
  font-size: 16px;
  outline: none;
}
.field input:focus {
  box-shadow: 4px 4px 0 var(--brass);
  background: #fff;
}
.slug-shell {
  display: flex;
  align-items: center;
  border: 2px solid var(--ink);
  background: #fffdf9;
  border-radius: 14px 6px 14px 6px;
  overflow: hidden;
  direction: ltr;
}
.slug-shell em {
  font-style: normal;
  background: #efe0cc;
  padding: 13px 12px;
  color: var(--indigo);
  font-weight: 800;
  white-space: nowrap;
  border-right: 2px solid var(--ink);
}
.slug-shell input {
  border: 0;
  border-radius: 0;
  box-shadow: none !important;
  text-align: left;
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--ink-soft);
}
.check input { width: 18px; height: 18px; accent-color: var(--clay); }
.stack-form { display: grid; gap: 16px; }

.page-login { min-height: 100vh; }
.login-stage {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 36px 20px;
  padding-top: max(36px, env(safe-area-inset-top));
}
.sheet-card {
  width: min(460px, 100%);
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--radius-sheet);
  box-shadow: var(--stamp);
  padding: 32px 28px 28px;
  position: relative;
}
.brand-mark {
  flex-shrink: 0;
  display: block;
  object-fit: contain;
  background: #fff;
  border-radius: 14px;
}
.bar-brand .brand-mark,
.sheet-brand .brand-mark,
.missing-card .brand-mark {
  border: 2px solid var(--ink);
}
.missing-card .brand-mark {
  margin: 0 auto 14px;
  border-radius: 18px;
}
.sheet-card::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  right: -8px;
  width: 16px;
  background:
    radial-gradient(circle at 8px 14px, var(--sand) 6px, transparent 7px),
    radial-gradient(circle at 8px 44px, var(--sand) 6px, transparent 7px),
    radial-gradient(circle at 8px 74px, var(--sand) 6px, transparent 7px),
    radial-gradient(circle at 8px 104px, var(--sand) 6px, transparent 7px);
}
.sheet-brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 10px;
}
.sheet-brand h2 { font-size: 1.35rem; font-weight: 900; }
.sheet-intro { color: var(--ink-soft); margin: 0 0 22px; }

.captcha-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: stretch;
}
.captcha-refresh {
  padding: 0;
  border: 2px solid var(--ink);
  background: #fff;
  border-radius: 14px 6px 14px 6px;
  overflow: hidden;
  box-shadow: 3px 3px 0 var(--ink);
  line-height: 0;
}
.captcha-refresh img {
  display: block;
  width: 180px;
  height: 58px;
  object-fit: cover;
}
.captcha-row input {
  letter-spacing: 0.28em;
  text-transform: uppercase;
  text-align: center;
  font-weight: 800;
  direction: ltr;
}
.captcha-row input::placeholder {
  letter-spacing: 0;
  text-transform: none;
  font-weight: 700;
  font-size: 14px;
  direction: rtl;
}

.atelier-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 28px;
  padding-top: max(16px, env(safe-area-inset-top));
  background: var(--paper);
  border-bottom: 3px solid var(--ink);
  position: sticky;
  top: 0;
  z-index: 20;
}
.bar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.bar-brand strong { display: block; font-size: 1.1rem; }
.bar-brand small { color: var(--ink-soft); }
.bar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bar-nav a,
.bar-nav button {
  text-decoration: none;
  border: 0;
  background: transparent;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  color: var(--ink);
}
.bar-nav a.is-on,
.bar-nav a:hover,
.bar-nav button:hover {
  background: #f0d9c8;
}
.studio {
  width: min(1080px, calc(100% - 32px));
  margin: 28px auto 64px;
  display: grid;
  gap: 22px;
}
.studio-narrow { width: min(640px, calc(100% - 32px)); }
.ledger-hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
}
.ledger-hero h1 { font-size: clamp(1.8rem, 3vw, 2.6rem); font-weight: 900; }
.ledger-hero p { margin: 8px 0 0; color: var(--ink-soft); max-width: 36rem; }
.stat-pills {
  display: flex;
  gap: 12px;
}
.stat-pills article {
  min-width: 132px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 18px 6px 18px 6px;
  padding: 14px 16px;
  box-shadow: 4px 4px 0 var(--indigo);
}
.stat-pills strong { display: block; font-size: 1.8rem; line-height: 1; }
.stat-pills span { color: var(--ink-soft); font-size: 13px; }

.ticket-card {
  background: var(--paper);
  border: 2px dashed var(--ink);
  border-radius: 22px;
  padding: 22px;
  position: relative;
  box-shadow: var(--shadow-soft);
}
.ticket-card::after,
.ticket-card::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  background: var(--sand);
  border: 2px solid var(--ink);
  border-radius: 50%;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
.ticket-card::before { right: -12px; }
.ticket-card::after { left: -12px; }
.ticket-form {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto;
  gap: 14px;
  align-items: end;
}
.grow { min-width: 0; }
.settings-card { border-style: solid; }
.settings-card::before,
.settings-card::after { display: none; }

.ledger {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 24px 8px 24px 8px;
  box-shadow: var(--stamp);
  overflow: hidden;
}
.ledger-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 2px solid var(--ink);
  background:
    repeating-linear-gradient(var(--paper), var(--paper) 27px, rgba(194, 75, 50, 0.08) 28px);
}
.ledger-head h2 { font-size: 1.15rem; }
.search-form { display: flex; gap: 8px; }
.search-form input {
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  padding: 10px 14px;
  min-width: 240px;
  background: #fffdf9;
  font-size: 16px;
}
.link-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px dashed var(--line);
  align-items: center;
}
.link-row:last-of-type { border-bottom: 0; }
.link-main { min-width: 0; }
.short-chip {
  display: inline-flex;
  text-decoration: none;
  background: #f7e4d6;
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-weight: 800;
  color: var(--clay-deep);
  direction: ltr;
}
.long-url {
  margin: 8px 0 4px;
  color: var(--indigo);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: ltr;
  text-align: right;
}
.meta { margin: 0; color: var(--ink-soft); font-size: 13px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-actions form { margin: 0; }
.empty-ledger {
  padding: 42px 20px;
  text-align: center;
  color: var(--ink-soft);
}
.empty-ledger strong { display: block; color: var(--ink); margin-bottom: 6px; }

.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-top: 2px solid var(--ink);
}
.pager-btn {
  text-decoration: none;
  border: 2px solid var(--ink);
  padding: 6px 12px;
  border-radius: 10px;
  font-weight: 700;
  background: #fff;
}
.pager-btn.is-off { opacity: 0.4; }
.pager-status { color: var(--ink-soft); font-size: 13px; }

.sheet-dialog {
  border: 2px solid var(--ink);
  border-radius: var(--radius-sheet);
  background: var(--paper);
  padding: 0;
  width: min(480px, calc(100% - 24px));
  max-height: min(90vh, 90dvh);
  overflow: auto;
  box-shadow: var(--stamp);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}
.sheet-dialog::backdrop {
  background: rgba(36, 28, 22, 0.45);
}
.sheet-dialog form { padding: 22px; }
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.page-missing { min-height: 100vh; }
.missing-stage {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}
.missing-card {
  width: min(520px, 100%);
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 32px 12px 32px 12px;
  box-shadow: 8px 8px 0 var(--clay);
  padding: 36px 28px;
  text-align: center;
}
.torn-mark { width: 180px; margin: 0 auto 8px; }
.missing-card h1 { font-size: 2rem; font-weight: 900; margin-bottom: 10px; }
.missing-card p { color: var(--ink-soft); }
.missing-card .btn { margin-top: 8px; }

@media (max-width: 960px) {
  .ticket-form { grid-template-columns: 1fr; }
  .ticket-card::before,
  .ticket-card::after { display: none; }
  .ledger-hero, .ledger-head, .link-row {
    flex-direction: column;
    align-items: stretch;
  }
  .search-form { width: 100%; }
  .search-form input { min-width: 0; width: 100%; }
  .bar-nav { flex-wrap: wrap; }
  .row-actions { width: 100%; }
  .row-actions .btn,
  .row-actions form { flex: 1; }
  .row-actions form .btn { width: 100%; }
  .stat-pills { width: 100%; }
  .stat-pills article { flex: 1; min-width: 0; }
}

@media (max-width: 720px) {
  .login-stage {
    padding: 16px 12px;
    padding-top: max(16px, env(safe-area-inset-top));
    align-items: stretch;
  }
  .sheet-card {
    width: 100%;
    padding: 22px 16px 18px;
    box-shadow: 4px 4px 0 var(--ink);
  }
  .sheet-card::before { display: none; }
  .sheet-brand {
    gap: 10px;
  }
  .sheet-brand h2 { font-size: 1.12rem; }
  .captcha-row {
    grid-template-columns: 1fr;
  }
  .captcha-refresh,
  .captcha-refresh img {
    width: 100%;
    height: auto;
  }
  .captcha-refresh img { height: 64px; object-fit: contain; background: #fff; }
  .atelier-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 14px;
    padding-top: max(12px, env(safe-area-inset-top));
    gap: 10px;
  }
  .bar-nav {
    justify-content: space-between;
    gap: 4px;
  }
  .bar-nav a,
  .bar-nav button {
    flex: 1;
    text-align: center;
    padding: 10px 8px;
    font-size: 13px;
  }
  .studio,
  .studio-narrow {
    width: calc(100% - 20px);
    margin: 16px auto 40px;
    gap: 16px;
  }
  .ledger-hero h1 { font-size: 1.45rem; }
  .ticket-card { padding: 16px; }
  .btn-stamp { width: 100%; }
  .ledger {
    border-radius: 16px 6px 16px 6px;
    box-shadow: 4px 4px 0 var(--ink);
  }
  .ledger-head { padding: 14px; }
  .link-row { padding: 14px; }
  .long-url { white-space: normal; word-break: break-all; }
  .missing-card {
    padding: 24px 16px;
    box-shadow: 5px 5px 0 var(--clay);
  }
  .missing-card h1 { font-size: 1.45rem; }
  .sheet-dialog {
    width: calc(100% - 16px);
    max-height: calc(100dvh - 16px);
  }
}

@media (max-width: 420px) {
  .bar-brand small { display: none; }
  .stat-pills { flex-direction: column; }
}
