/* assets/css/components.css */
/* Scope: reusable UI components (buttons, inputs, cards, pills, headings) */

/* -----------------------------
   Headings (class-based)
----------------------------- */
.h1 {
  font-size: var(--fs-4);
  font-weight: var(--fw-bold);
  margin: 0;
  letter-spacing: -0.2px;
}

.h2 {
  font-size: var(--fs-2);
  font-weight: var(--fw-bold);
  margin: 0;
}

/* -----------------------------
   Card
----------------------------- */
.card {
  background: var(--surface-1);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-1);
}
/* materials list: clickable cards should not show ugly link focus/tap artifacts */
.material-card {
  -webkit-tap-highlight-color: transparent; /* iOS tap flash */
  text-decoration: none;
  color: inherit;
}

.material-card:focus,
.material-card:focus-visible {
  outline: none;
}
/* -----------------------------
   Input / Select
----------------------------- */
.input {
  width: 100%;
  height: var(--control-h);
  padding: 0 var(--control-pad-x);
  border-radius: var(--control-radius);
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-main);
  font-size: 16px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.input::placeholder {
  color: var(--color-ink-300);
  opacity: 1;
}

.input:hover {
  border-color: var(--border-soft);
}

.input:focus-visible {
  border-color: var(--color-line-focus);
  box-shadow: var(--focus-ring);
}
.input--center {
  text-align: center;
}
.input:disabled {
  opacity: 1;
  color: var(--text-muted);
  background: var(--surface-2);
  border-color: var(--border-soft);
  cursor: not-allowed;
}

.input:read-only,
.input[readonly] {
  background: var(--color-neutral-50);
  border-color: var(--border-soft);
}

/* -----------------------------
   Search helpers
----------------------------- */
.search-row{
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.search-clear{
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 12px;
  font-size: 18px;
  line-height: 1;
}
.search-meta{
  font-size: 12px;
  white-space: nowrap;
  margin-inline-start: auto;
}
mark.search-hl{
  background: rgba(229, 170, 23, 0.28);
  border-radius: 4px;
  padding: 0 2px;
}

/* textarea (if needed later) */
.textarea {
  width: 100%;
  min-height: 120px;
  padding: var(--space-3);
  border-radius: var(--control-radius);
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-main);
  font-size: 16px;
  resize: vertical;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.textarea::placeholder {
  color: var(--color-ink-300);
  opacity: 1;
}

.textarea:hover {
  border-color: var(--border-soft);
}

.textarea:focus-visible {
  border-color: var(--color-line-focus);
  box-shadow: var(--focus-ring);
}

.textarea:disabled {
  opacity: 1;
  color: var(--text-muted);
  background: var(--surface-2);
  border-color: var(--border-soft);
  cursor: not-allowed;
}

.textarea:read-only,
.textarea[readonly] {
  background: var(--color-neutral-50);
  border-color: var(--border-soft);
}

/* -----------------------------
   Button
----------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  height: var(--control-h);
  padding: 0 var(--space-4);
  border-radius: var(--control-radius);

  font-size: var(--fs-2);
  font-weight: var(--fw-bold);

  user-select: none;
  border: 1px solid transparent;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.72;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn--primary {
  background: var(--accent);
  color: var(--color-ink-900);
  box-shadow: var(--shadow-1);
  border-color: rgba(157, 112, 14, 0.32);
}

.btn--primary:hover {
  filter: brightness(0.98);
}

.btn--primary:focus-visible {
  box-shadow: var(--shadow-1), var(--focus-ring);
}

.btn--secondary {
  background: var(--surface-2);
  color: var(--text-main);
  border-color: var(--border);
}

.btn--secondary:focus-visible {
  box-shadow: var(--focus-ring);
}

.btn--ghost {
  background: transparent;
  color: var(--text-main);
  border-color: var(--border);
}

.btn--ghost:hover {
  background: rgba(42, 38, 33, 0.04);
}

.btn--ghost:focus-visible {
  box-shadow: var(--focus-ring);
}

.btn--primary:disabled,
.btn--secondary:disabled,
.btn--ghost:disabled {
  color: var(--text-muted);
  border-color: var(--border-soft);
}

.btn--primary:disabled,
.btn--secondary:disabled {
  background: var(--surface-2);
}

.btn--locked {
  opacity: 0.72;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  color: var(--text-muted);
  border-color: var(--border-soft);
  background: var(--surface-2);
}
.btn--locked:active {
  transform: none;
}

/* -----------------------------
   Pill / Badge
----------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  height: 28px;
  padding: 0 var(--space-3);

  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  color: var(--text-main);
  font-size: var(--fs-1);
  font-weight: var(--fw-bold);
}

.pill--accent {
  background: rgba(229, 170, 23, 0.18);
  color: var(--color-ink-900);
}

.pill--warning {
  background: rgba(245, 158, 11, 0.16);
  color: #7a4a00;
}

.pill--danger {
  background: rgba(239, 68, 68, 0.12);
  color: #8f1d1d;
}

/* -----------------------------
   Topbar (light header)
----------------------------- */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
     gap: var(--space-3);
  }
}
/* -----------------------------
   App Header (fixed glass material)
----------------------------- */
.app-head-mat{
  position: fixed;
  top: var(--app-head-offset-top, 0px);
  inset-inline: 0;
  height: calc(env(safe-area-inset-top, 0px) + var(--space-3) + var(--app-head-h, 56px) + var(--sub-hint-h, 0px));
  z-index: 1000;
  pointer-events: none;
  transition: height 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  /* backdrop-filter اینجا روی خودِ fixed element است — مثل bottom nav —
     تا Android Chrome بتواند محتوای صفحه را بلور کند.
     روی children با position:absolute این کار نمی‌کند (compositing layer جدا).
     ⚠️ contain اینجا نگذارید: یک backdrop root می‌سازد و blur را می‌شکند. */
  -webkit-backdrop-filter: blur(var(--app-head-blur, 8px)) saturate(var(--app-head-saturation, 150%)) brightness(1.06);
  backdrop-filter: blur(var(--app-head-blur, 8px)) saturate(var(--app-head-saturation, 150%)) brightness(1.06);
}

.app-head-veil{
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgb(250 249 246 / var(--app-head-veil-top-alpha, .10)) 0%,
    rgb(250 249 246 / var(--app-head-veil-bottom-alpha, .32)) 100%
  );
  opacity: var(--app-head-veil-opacity, 1);
  transition:
    opacity .24s ease,
    background .24s ease;
}

.app-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: var(--space-3);

  width: calc(100% - var(--space-4) - var(--space-4));
  max-width: calc(1100px - var(--space-4) - var(--space-4));
  margin-inline: auto;

  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255,255,255,0.45);
  background: rgb(255 255 255 / var(--app-head-bg-alpha, .26));
  box-shadow:
    0 8px 32px rgba(42,38,33,0.12),
    0 1px 3px rgba(42,38,33,0.08),
    inset 0 1px 0.5px rgba(255,255,255,0.90),
    inset 0 -1px 0.5px rgba(255,255,255,0.28),
    inset 1px 0 0.5px rgba(255,255,255,0.22),
    inset -1px 0 0.5px rgba(255,255,255,0.22);
  /* بلور محتوا توسط .app-head-mat (والدِ fixed) انجام می‌شود — نه اینجا.
     این عنصر فقط visual chrome (پس‌زمینه، border، shadow، border-radius) است. */
  position: absolute;
  inset-inline: 0;
  top: calc(var(--space-3) + env(safe-area-inset-top));
  z-index: 3;
  pointer-events: auto;
  overflow: hidden;
  isolation: isolate;

  transition:
    opacity .25s ease,
    transform .25s ease,
    box-shadow .25s ease,
    background .25s ease;
}

.app-head::before{
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(255,255,255,0.24) 0px,
    rgba(255,255,255,0.06) 6px,
    rgba(255,255,255,0) 18px
  );
}

.app-head > *{
  position: relative;
  z-index: 1;
}

.app-head__offline{
  font-size: 11px;
  color: #92400e;
  opacity: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex: 1;
  justify-content: center;
  transition: opacity .35s ease, color .35s ease;
}
.app-head__offline.is-visible{ opacity: .9; }
.app-head__offline::before{
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #d97706;
  flex-shrink: 0;
  animation: offline-pulse 1.8s ease-in-out infinite;
  transition: background .35s ease;
}
.app-head__offline.is-restored{ color: #166534; }
.app-head__offline.is-restored::before{
  background: #16a34a;
  animation: none;
}
.app-head__offline[hidden]{ display: none; }
@keyframes offline-pulse{
  0%,100%{ opacity: 1; }
  50%{ opacity: .35; }
}
.app-head.is-offline{
  background: rgb(253 244 234 / var(--app-head-bg-alpha, .72));
  border-color: rgba(217,119,6,.18);
  transition: background .4s ease, border-color .4s ease;
}

.app-head.is-compact{
  opacity: .72;
  transform: translateY(-2px);
  box-shadow: var(--shadow-1);
  background: rgb(255 255 255 / var(--app-head-compact-bg-alpha, .34));
}

.app-head.is-overlapping{
  box-shadow:
    0 14px 40px rgba(42,38,33,0.16),
    0 2px 6px rgba(42,38,33,0.10),
    inset 0 1px 0.5px rgba(255,255,255,0.90),
    inset 0 -1px 0.5px rgba(255,255,255,0.28),
    inset 1px 0 0.5px rgba(255,255,255,0.22),
    inset -1px 0 0.5px rgba(255,255,255,0.22);
}

/* Subscription hint bar — slides out below app-head when user taps locked button */
.sub-hint-bar {
  position: absolute;
  inset-inline: var(--space-4);
  bottom: 0;
  height: 0;
  overflow: hidden;
  transition: height 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
}
.sub-hint-bar.is-open {
  height: var(--sub-hint-h, 0px);
}
.sub-hint-bar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 10px var(--space-4);
  height: 100%;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: rgb(255 255 255 / 0.55);
  border: 1px solid rgba(255,255,255,0.45);
  border-top: none;
  box-shadow: 0 8px 16px rgba(42,38,33,0.08);
  box-sizing: border-box;
}
.sub-hint-bar__msg {
  flex: 1;
  font-size: var(--text-xs, 0.75rem);
  color: var(--text-2);
}
.sub-hint-bar__action {
  flex-shrink: 0;
  font-size: var(--text-xs, 0.75rem);
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: var(--radius-md);
  white-space: nowrap;
}
.sub-hint-bar__action:active {
  opacity: 0.7;
}

.app-head__ws{
  display:flex;
  flex-direction: column;
  align-items:flex-start;
  min-width:0;
  gap:4px;
}

.app-head__ws-title{
  font-weight:700;
  font-size:13px;
  color: var(--text-main);
  text-decoration: none;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.app-head__ws-title:hover{
  color: var(--color-ink-700);
}
.app-head__ws-title:focus-visible{
  box-shadow: var(--focus-ring);
  border-radius: 10px;
}
.app-head__title{
  font-size:12px;
  opacity:.75;
  line-height:1.2;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.app-head__profile{
  display:flex;
  align-items:center;
}

.app-profile{
  display:inline-flex;
  align-items:center;
  gap:0;
  padding: var(--space-1);
  position: relative;
  overflow: visible;
  border-radius: var(--radius-lg);
  text-decoration:none;
  color:inherit;
  background: transparent;
  border: 0;
  transition: color 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}
.app-profile:hover{
  color: var(--text-main);
}
.app-profile:focus-visible{
  box-shadow: var(--focus-ring);
}

.app-profile__avatar{
  width: var(--space-8);
  height: var(--space-8);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.app-profile__avatar-image{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
}
.app-profile__avatar:not(.app-profile__avatar--has-image) .app-profile__avatar-image{
  display: none;
}
.app-profile__avatar-char{
  font-size: var(--fs-2);
  font-weight: var(--fw-medium);
  line-height: 1;
  color: var(--text-main);
}
.app-profile__avatar.app-profile__avatar--has-image .app-profile__avatar-char{
  display: none;
}
.app-profile__avatar.avatar--premium{
  box-shadow: 0 0 0 1.5px rgba(229, 170, 23, 0.28);
}
.app-profile__avatar.avatar--premium::after{
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 999px;
  background:
    conic-gradient(
      from 0deg,
      rgba(229, 170, 23, 0.20) 0turn,
      rgba(229, 170, 23, 0.20) calc(var(--sub-progress, 0) * 1turn),
      var(--accent) calc(var(--sub-progress, 0) * 1turn),
      var(--accent) 1turn
    );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.4px), #000 calc(100% - 1.4px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2.4px), #000 calc(100% - 1.4px));
  opacity: 0.94;
  pointer-events: none;
  z-index: 2;
}
.app-profile__avatar.avatar--premium::before{
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 999px;
  background:
    conic-gradient(
      from -90deg,
      rgba(229, 170, 23, 0.10) 0turn,
      rgba(229, 170, 23, 0.10) 1turn
    );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.4px), #000 calc(100% - 1.4px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2.4px), #000 calc(100% - 1.4px));
  pointer-events: none;
  z-index: 1;
}

.app-profile__support-badge{
  position: absolute;
  top: -1px;
  inset-inline-end: -3px;
  z-index: 5;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  border: 2px solid var(--surface-1);
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: var(--fw-bold);
  line-height: 1;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(42, 38, 33, 0.18);
  transform: scale(1);
  opacity: 1;
  transform-origin: center;
  transition: transform 180ms ease, opacity 180ms ease;
}

.app-profile:hover .app-profile__support-badge{
  transform: translateY(-1px) scale(1.03);
}

@media (max-width: 640px) {
  .app-head{
    width: calc(100% - var(--space-3) - var(--space-3));
    max-width: calc(1100px - var(--space-3) - var(--space-3));
    padding:10px var(--space-3);
  }
  .app-profile__support-badge{
    top: -2px;
    inset-inline-end: -2px;
    min-width: 17px;
    height: 17px;
    padding: 0 3px;
    border-width: 1.5px;
    font-size: 9px;
  }
}
@media (prefers-reduced-motion: reduce){
  .app-head{
    transition: none;
  }
  .app-head-mat {
    transition: none;
  }
  .sub-hint-bar {
    transition: none;
  }
  .app-profile__support-badge{
    transition: none;
  }
}
/* -----------------------------------------
   Glass FAB (shared: products + materials)
------------------------------------------ */
.glass-fab{
  width: 60px;
  height: 60px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: rgba(250,249,246,.65);
  -webkit-backdrop-filter: blur(36px) saturate(210%);
  backdrop-filter: blur(36px) saturate(210%);
  box-shadow:
    inset 0 1.5px 0  rgba(255,255,255,.95),
    inset 0 -0.5px 0 rgba(0,0,0,.06),
    inset 0 0 0 0.5px rgba(255,255,255,.42),
    0 20px 60px      rgba(42,38,33,.18),
    0 2px 8px        rgba(42,38,33,.10),
    0 0 0 0.5px      rgba(42,38,33,.06);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  isolation: isolate;
  transition:
    box-shadow .22s ease,
    transform .2s ease,
    background .22s ease;
}
.glass-fab::before{
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 50%;
  background: linear-gradient(
    180deg,
    rgba(255,255,255,.62) 0%,
    rgba(255,255,255,.18) 40%,
    rgba(255,255,255,0)   72%
  );
  pointer-events: none;
}
.glass-fab > *{
  position: relative;
  z-index: 1;
}
.glass-fab:hover{
  box-shadow:
    inset 0 1.5px 0  rgba(255,255,255,1),
    inset 0 -0.5px 0 rgba(0,0,0,.06),
    inset 0 0 0 0.5px rgba(255,255,255,.52),
    0 24px 64px      rgba(42,38,33,.22),
    0 4px 12px       rgba(42,38,33,.12),
    0 0 0 0.5px      rgba(42,38,33,.06);
  transform: translateY(-1px);
}
.glass-fab:active{
  transform: scale(.94);
  box-shadow:
    inset 0 1px 0    rgba(255,255,255,.85),
    inset 0 -0.5px 0 rgba(0,0,0,.05),
    inset 0 0 0 0.5px rgba(255,255,255,.35),
    0 6px 18px       rgba(42,38,33,.12),
    0 1px 4px        rgba(42,38,33,.08),
    0 0 0 0.5px      rgba(42,38,33,.05);
}
.glass-fab__icon{
  width: 24px;
  height: 24px;
  display: block;
  color: #e5aa17;
  flex: none;
}

/* -----------------------------------------
   Workspace Empty State Invitation Card
------------------------------------------ */
.ws-empty-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 36px 24px 32px;
  margin: 32px auto;
  max-width: 380px;
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  text-align: center;
}

.ws-empty-card__title {
  margin: 0;
  font-size: var(--fs-2);
  font-weight: var(--fw-bold);
  color: var(--text-main);
}

.ws-empty-card__body {
  margin: 0;
  font-size: var(--fs-1);
  color: var(--text-muted, var(--color-ink-300));
  line-height: 1.7;
}

.ws-empty-card__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
}

.ws-empty-card__actions .btn {
  width: 100%;
  justify-content: center;
}

.ws-empty-card__hint {
  margin: 0;
  font-size: var(--fs-0, 12px);
  color: var(--color-ink-300);
}

.ws-empty-card__seed-btn.is-loading {
  opacity: 0.6;
  pointer-events: none;
}

/* ws-empty-card as a centered modal (home first-touch) — overlays without
   pushing page content down. */
.ws-empty-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ws-empty-modal.is-hidden {
  display: none;
}
.ws-empty-modal__backdrop {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(15, 23, 42, 0.55);
  cursor: pointer;
}
.ws-empty-card--modal {
  position: relative;
  z-index: 1;
  margin: 0;
  animation: wsEmptyModalIn 0.18s ease-out;
}
.ws-empty-card__close {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted, var(--color-ink-300));
  cursor: pointer;
}
.ws-empty-card__close svg {
  width: 18px;
  height: 18px;
}
.ws-empty-card__close:hover {
  background: var(--surface-2, rgba(0, 0, 0, 0.05));
}
@keyframes wsEmptyModalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* Sample-data banner + badges (shown while is_sample rows exist) */
.ws-sample-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 14px;
  margin: 0 0 14px;
  background: rgba(245, 158, 11, 0.07);
  border: 1px solid rgba(245, 158, 11, 0.18);
  border-radius: 14px;
}
.ws-sample-banner__dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.16);
}
.ws-sample-banner__text {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12.5px;
  color: var(--text-muted, var(--color-ink-300));
  line-height: 1.55;
}
.ws-sample-clear {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #b45309;
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}
.ws-sample-clear:hover { background: rgba(245, 158, 11, 0.12); }
.ws-sample-clear:active { background: rgba(245, 158, 11, 0.18); }
.ws-sample-clear__icon { width: 15px; height: 15px; flex: 0 0 auto; }
.ws-sample-clear.is-loading { opacity: 0.6; pointer-events: none; }
.ws-sample-badge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.7;
  color: #b45309;
  background: rgba(245, 158, 11, 0.14);
  transition: opacity .32s ease, transform .32s ease;
}
.ws-sample-badge.is-removing {
  opacity: 0;
  transform: scale(.75);
  pointer-events: none;
}
/* keep the sample badge inline with the material title */
.mat-name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Custom confirm dialog (Karmet-styled, replaces window.confirm) */
.ws-confirm {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ws-confirm[hidden] {
  display: none;
}
.ws-confirm__backdrop {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(15, 23, 42, 0.55);
  cursor: pointer;
}
.ws-confirm__dialog {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 24px 22px 20px;
  background: var(--surface-1, #fff);
  border: 1px solid var(--border-soft, rgba(0, 0, 0, 0.06));
  border-radius: 18px;
  box-shadow: var(--shadow-2, 0 12px 40px rgba(0, 0, 0, 0.18));
  animation: wsEmptyModalIn 0.18s ease-out;
}
.ws-confirm__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: #dc2626;
  background: rgba(220, 38, 38, 0.10);
}
.ws-confirm__icon svg {
  width: 24px;
  height: 24px;
}
.ws-confirm__title {
  margin: 0;
  font-size: var(--fs-2, 16px);
  font-weight: var(--fw-bold, 800);
  color: var(--text-main, #1f2937);
}
.ws-confirm__body {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-muted, var(--color-ink-300));
}
.ws-confirm__actions {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
}
.ws-confirm__actions .btn {
  flex: 1 1 0;
  justify-content: center;
}
.ws-confirm__danger {
  color: #fff;
  background: #dc2626;
  border: 1px solid #dc2626;
}
.ws-confirm__danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}
.ws-confirm__danger.is-loading {
  opacity: 0.7;
  pointer-events: none;
}

/* -----------------------------------------
   Bottom Nav (Telegram-inspired / Minimal Glass)
------------------------------------------ */

:root{
  --bn-blur: 22px;
  --bn-bg: rgba(255, 255, 255, 0.18);
  --bn-text: rgba(42, 38, 33, 0.62);
  --bn-text-active: var(--accent);
  --bn-active-bg: rgba(229, 170, 23, 0.1);
  --bn-dot: rgba(229, 170, 23, 0.86);
  --bn-veil-blur: 14px;
}

.calc-bottom-nav-veil{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: env(safe-area-inset-bottom, 0px);
  z-index: 997;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(250,249,246,.05) 0%, rgba(250,249,246,.55) 60%, rgba(250,249,246,.80) 100%);
  -webkit-backdrop-filter: blur(var(--bn-veil-blur)) saturate(145%);
  backdrop-filter: blur(var(--bn-veil-blur)) saturate(145%);
}

.calc-bottom-nav{
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: env(safe-area-inset-bottom, 0px);
  z-index: 999;

  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;

  padding: 8px;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,0.42);

  background: var(--bn-bg);
  -webkit-backdrop-filter: blur(var(--bn-blur)) saturate(190%) brightness(1.06);
  backdrop-filter: blur(var(--bn-blur)) saturate(190%) brightness(1.06);
  border-color: rgba(255,255,255,0.45);

  box-shadow:
    0 10px 34px rgba(42,38,33,0.14),
    0 2px 8px rgba(42,38,33,0.08),
    inset 0 1px 0.5px rgba(255,255,255,0.90),
    inset 0 -1px 0.5px rgba(255,255,255,0.28),
    inset 1px 0 0.5px rgba(255,255,255,0.22),
    inset -1px 0 0.5px rgba(255,255,255,0.22);
  overflow: hidden;
}

.calc-bottom-nav.has-impact{
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

html.keyboard-open .calc-bottom-nav{
  opacity: 0;
  pointer-events: none;
  transform: translateY(120%);
  display: none;
}

html.keyboard-open .calc-bottom-nav-veil{
  opacity: 0;
  pointer-events: none;
  display: none;
}

.calc-bottom-nav::before{
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(255,255,255,0.38) 0px,
    rgba(255,255,255,0.10) 6px,
    rgba(255,255,255,0) 20px
  );
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))){
  .app-head-mat{
    background: rgba(255,255,255,0.92);
  }
  .app-head-veil{
    background: rgba(250,249,246,.48);
  }
  .calc-bottom-nav-veil{
    background: rgba(250,249,246,.48);
  }
  .calc-bottom-nav{
    background: rgba(250,249,246,0.94);
  }
  .calc-bottom-nav::before{
    display: none;
  }
  .app-head{
    background: rgba(255,255,255,0.94);
  }
  .app-head::before{
    display: none;
  }
}

.calc-bottom-nav .bn-item{
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  gap: 3px;
  padding: 6px 4px 10px;
  border-radius: 14px;

  text-decoration: none;
  color: var(--bn-text);
  background: transparent;
  border: 1px solid transparent;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;

  transition: color .14s ease, background-color .14s ease, border-color .14s ease, transform .12s ease;
}

.calc-bottom-nav .bn-ico{
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.calc-bottom-nav .bn-ico .bn-svg{
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.calc-bottom-nav .bn-txt{
  font-size: 11px;
  font-weight: var(--fw-medium);
  line-height: 1.15;
  white-space: nowrap;
  color: inherit;
}

.calc-bottom-nav .bn-item.is-active{
  color: var(--bn-text-active);
  background: var(--bn-active-bg);
  border-color: rgba(229, 170, 23, 0.18);
}

.calc-bottom-nav .bn-item.is-active::after{
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  transform: translateX(-50%);
  background: var(--bn-dot);
}

.calc-bottom-nav .bn-item:active{
  transform: scale(0.98);
}

.calc-bottom-nav .bn-item:focus-visible{
  outline: none;
  box-shadow: var(--focus-ring);
}

@media (max-width: 360px){
  .calc-bottom-nav{
    left: 6px;
    right: 6px;
    border-radius: 20px;
    padding: 7px;
  }
  .calc-bottom-nav .bn-item{
    min-height: 50px;
    padding: 5px 3px 9px;
  }
  .calc-bottom-nav .bn-txt{
    font-size: 9px;
  }
}

@media (min-width: 900px){
  .calc-bottom-nav-veil{
    display: none;
  }
  .calc-bottom-nav{
    display: none;
  }
}
[hidden] { display: none !important; }
.toast{
  position: fixed;
  left: 12px;
  right: 12px;
  top: calc(10px + env(safe-area-inset-top));
  z-index: 9999;

  padding: 12px 14px;
  border-radius: var(--radius-lg);

  /* Liquid glass */
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));

  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-3);

  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  overflow: hidden;
}

.toast::before{
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.62), rgba(255,255,255,.2));
  opacity: .7;
}

.toast > *{
  position: relative;
  z-index: 1;
}

.toast.is-show{
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.toast--ok{
  border-color: rgba(46,157,91,.35);
}
.toast--err{
  border-color: rgba(199,74,69,.4);
  background: rgba(255,240,238,.92);
  color: #74211f;
}
@media (prefers-color-scheme: dark){
  .toast{
    background: rgba(20,20,20,.80);
    border-color: rgba(255,255,255,.10);
    color: rgba(255,255,255,.92);
  }
  .toast::before{
    background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.02));
  }
  .toast--err{
    background: rgba(60,20,20,.78);
    border-color: rgba(255,120,120,.35);
    color: rgba(255,220,220,.95);
  }
}

/* اگر blur پشتیبانی نشود */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))){
  .toast{
    background: rgba(255,255,255,.96);
  }
  .toast--err{
    background: rgba(255,240,238,.96);
  }
}

.toast--bottom{
  top: auto;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateY(10px);
}
.toast--bottom.is-show{
  transform: translateY(0);
}
.toast--bottom::before{
  background: linear-gradient(0deg, rgba(255,255,255,.62), rgba(255,255,255,.2));
}

.toast__row{
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}
.toast__msg{
  flex: 1;
  font-size: .875rem;
  line-height: 1.4;
}
.toast__action{
  flex-shrink: 0;
  font-size: .8rem;
  font-weight: 600;
  color: var(--accent-dark, #7a5500);
  text-decoration: none;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(0,0,0,.06);
  transition: background .15s;
}
.toast__action:hover{
  background: rgba(0,0,0,.12);
}
