/* ========== متغیرهای تم ========== */
:root {
  --bg-primary: #eef1f8;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e4e9f2;
  --bg-card: #ffffff;
  --text-primary: #1a1d26;
  --text-secondary: #5a6270;
  --text-muted: #8b93a7;
  --border: #d5dbe8;
  --accent: #4f6ef7;
  --accent-hover: #3b5bdb;
  --accent-soft: rgba(79, 110, 247, 0.12);
  --danger: #e74c3c;
  --danger-hover: #c0392b;
  --danger-soft: rgba(231, 76, 60, 0.12);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 10px 32px rgba(0, 0, 0, 0.14);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.16);
  --glow: 0 0 24px rgba(79, 110, 247, 0.25);
  --glow-soft: 0 0 40px rgba(79, 110, 247, 0.12);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --font: "Vazirmatn", "Tahoma", "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  --bg-primary: #0c0e14;
  --bg-secondary: #161922;
  --bg-tertiary: #1e2230;
  --bg-card: #1a1d28;
  --text-primary: #eef0f4;
  --text-secondary: #9ba3b5;
  --text-muted: #6b7280;
  --border: #2a2e3d;
  --accent: #6b8aff;
  --accent-hover: #8ba3ff;
  --accent-soft: rgba(107, 138, 255, 0.15);
  --danger: #ff6b6b;
  --danger-hover: #ff5252;
  --danger-soft: rgba(255, 107, 107, 0.15);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 10px 32px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);
  --glow: 0 0 28px rgba(107, 138, 255, 0.35);
  --glow-soft: 0 0 48px rgba(107, 138, 255, 0.18);
}

/* تم طوسی خوش‌رنگ */
[data-theme="slate"] {
  --bg-primary: #2a2d35;
  --bg-secondary: #353942;
  --bg-tertiary: #40454f;
  --bg-card: #383c46;
  --text-primary: #f0f1f3;
  --text-secondary: #b0b5c0;
  --text-muted: #858b98;
  --border: #4a4f5a;
  --accent: #8b9dc3;
  --accent-hover: #a8b8d8;
  --accent-soft: rgba(139, 157, 195, 0.18);
  --danger: #e88a8a;
  --danger-hover: #f0a0a0;
  --danger-soft: rgba(232, 138, 138, 0.15);
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 10px 36px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  --glow: 0 0 28px rgba(139, 157, 195, 0.3);
  --glow-soft: 0 0 48px rgba(139, 157, 195, 0.15);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px 48px;
}

/* ========== هدر ========== */
.header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 18px 0;
  margin-bottom: 16px;
}
.header-right { flex-shrink: 0; }
.header-center { flex: 1; max-width: 480px; margin: 0 auto; }
.header-left {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

/* لوگو — ۸۰٪ بزرگ‌تر */
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 2.4rem;
}
.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
  border-radius: 16px;
  font-size: 1.9rem;
  box-shadow: var(--glow), 0 4px 16px rgba(79, 110, 247, 0.3);
  position: relative;
}
.logo-icon::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  opacity: 0.35;
  filter: blur(10px);
  z-index: -1;
}
.logo-text {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 12px rgba(79, 110, 247, 0.25));
}

/* لوگوی تصویری — سمت چپ صفحه */
.logo-img-link {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
}
.logo-img {
  height: 78px;
  width: auto;
  max-width: 240px;
  object-fit: contain;
  border-radius: 10px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.logo-img:hover {
  transform: scale(1.05);
  opacity: 0.92;
}

/* ساعت عقربه‌ای + تاریخ شمسی */
.clock-date-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px 6px 6px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow), var(--glow-soft);
}

.analog-clock {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
}
.clock-face {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.2), transparent 50%),
    linear-gradient(145deg, var(--bg-tertiary), var(--bg-secondary));
  border: 2px solid var(--border);
  box-shadow:
    inset 0 2px 6px rgba(0,0,0,0.08),
    0 0 16px rgba(79, 110, 247, 0.15);
  position: relative;
}
.clock-mark {
  position: absolute;
  width: 2px;
  height: 5px;
  background: var(--text-muted);
  left: 50%;
  top: 4px;
  margin-left: -1px;
  transform-origin: 50% 22px;
  transform: rotate(calc(var(--i) * 30deg));
  border-radius: 1px;
  opacity: 0.7;
}
.clock-mark:nth-child(1),
.clock-mark:nth-child(4),
.clock-mark:nth-child(7),
.clock-mark:nth-child(10) {
  height: 7px;
  width: 2.5px;
  background: var(--accent);
  opacity: 1;
}
.hand {
  position: absolute;
  left: 50%;
  bottom: 50%;
  transform-origin: 50% 100%;
  border-radius: 3px;
  background: var(--text-primary);
}
.hour-hand {
  width: 3px;
  height: 12px;
  margin-left: -1.5px;
  background: var(--text-primary);
  z-index: 2;
}
.minute-hand {
  width: 2.5px;
  height: 16px;
  margin-left: -1.25px;
  background: var(--text-secondary);
  z-index: 3;
}
.second-hand {
  width: 1.5px;
  height: 18px;
  margin-left: -0.75px;
  background: var(--accent);
  z-index: 4;
  box-shadow: 0 0 6px var(--accent);
}
.clock-center {
  position: absolute;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  left: 50%;
  top: 50%;
  margin: -3px 0 0 -3px;
  z-index: 5;
  box-shadow: 0 0 8px var(--accent);
}

.jalali-date {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.jalali-weekday {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.jalali-full {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

/* جستجو */
.search-box { position: relative; display: flex; align-items: center; }
.search-icon {
  position: absolute;
  right: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  padding: 11px 44px 11px 40px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  transition: all var(--transition);
  outline: none;
}
.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-box input::placeholder { color: var(--text-muted); }
.search-clear {
  position: absolute;
  left: 12px;
  background: var(--bg-tertiary);
  border: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.search-clear:hover { background: var(--danger); color: #fff; }
.search-clear.hidden { display: none; }

.theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all var(--transition);
  box-shadow: var(--shadow);
}
.theme-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: rotate(15deg);
  box-shadow: var(--glow-soft);
}

/* ========== نوار ابزار ========== */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #7c5cfc);
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 110, 247, 0.35), var(--glow-soft);
  position: relative;
  overflow: hidden;
}
.btn-primary::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transform: translateX(-100%);
  transition: none;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79, 110, 247, 0.5), var(--glow);
}
.btn-primary:hover::after {
  animation: btnShine 0.7s ease;
}
@keyframes btnShine {
  to { transform: translateX(100%); }
}
.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent);
}
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 5px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all var(--transition);
  line-height: 1;
}
.btn-icon:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.btn-icon.danger:hover { color: var(--danger); background: var(--danger-soft); }

/* ========== نوار افقی دسته‌بندی‌ها — ۳ بعدی ========== */
.categories-bar-wrap {
  margin-bottom: 28px;
  overflow-x: auto;
  padding: 8px 4px 16px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.categories-bar {
  display: flex;
  gap: 12px;
  flex-wrap: nowrap;
  min-width: min-content;
  perspective: 800px;
}

.cat-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.25s cubic-bezier(0.34, 1.4, 0.64, 1);
  /* افکت ۳ بعدی */
  box-shadow:
    0 4px 0 rgba(0, 0, 0, 0.2),
    0 6px 16px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transform: translateY(0);
  flex-shrink: 0;
}

.cat-chip:hover {
  transform: translateY(-3px);
  box-shadow:
    0 7px 0 rgba(0, 0, 0, 0.2),
    0 12px 24px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.cat-chip:active {
  transform: translateY(2px);
  box-shadow:
    0 2px 0 rgba(0, 0, 0, 0.2),
    0 3px 8px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.cat-chip.active {
  transform: translateY(-4px) scale(1.04);
  box-shadow:
    0 8px 0 rgba(0, 0, 0, 0.25),
    0 14px 28px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 0 0 3px rgba(255, 255, 255, 0.3);
  z-index: 2;
}

.cat-chip .cat-count {
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
}

.cat-chip .cat-delete {
  background: rgba(0, 0, 0, 0.2);
  border: none;
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: all 0.15s;
  margin-right: -4px;
}
.cat-chip .cat-delete:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.45);
  transform: scale(1.15);
}

/* ========== محتوا ========== */
.content { min-height: 400px; }

.content-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}
.content-header h2 {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.badge {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 700;
}

/* ========== گرید کارت‌ها — استایل آیکونی درخشان ========== */
.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.link-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  aspect-ratio: 1.25 / 1;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
}

/* حاشیه درخشان */
.link-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  background: linear-gradient(135deg, transparent 30%, var(--accent) 50%, transparent 70%);
  background-size: 200% 200%;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  z-index: 3;
}
.link-card:hover::before {
  opacity: 0.8;
  animation: borderShine 2.2s linear infinite;
}
@keyframes borderShine {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.link-card:hover {
  transform: translateY(-5px) scale(1.01);
  box-shadow: var(--shadow-hover), var(--glow);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
}

/* ناحیه آیکون — وسط و درخشان */
.link-card-icon-area {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 45%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 65%),
    var(--bg-card);
  overflow: hidden;
}

/* هاله نوری پشت آیکون */
.link-card-icon-area::before {
  content: "";
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 35%, transparent), transparent 70%);
  filter: blur(20px);
  opacity: 0.7;
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}
.link-card:hover .link-card-icon-area::before {
  opacity: 1;
  transform: scale(1.25);
}

.link-card-icon {
  position: relative;
  z-index: 1;
  width: 88px;
  height: 88px;
  border-radius: 22px;
  object-fit: contain;
  background: transparent;
  filter: drop-shadow(0 0 18px color-mix(in srgb, var(--accent) 45%, transparent));
  transition: transform 0.35s ease, filter 0.35s ease;
}
.link-card:hover .link-card-icon {
  transform: scale(1.08);
  filter: drop-shadow(0 0 28px color-mix(in srgb, var(--accent) 60%, transparent));
}

.link-card-icon.cover {
  width: 100%;
  height: 100%;
  border-radius: 0;
  object-fit: cover;
  filter: none;
}
.link-card:hover .link-card-icon.cover {
  transform: scale(1.05);
  filter: none;
}

.link-card-icon-fallback {
  position: relative;
  z-index: 1;
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.2rem;
  filter: drop-shadow(0 0 16px color-mix(in srgb, var(--accent) 40%, transparent));
  transition: transform 0.35s ease;
}
.link-card:hover .link-card-icon-fallback {
  transform: scale(1.1);
}

/* بدنه پایین کارت */
.link-card-body {
  flex-shrink: 0;
  padding: 12px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  position: relative;
  z-index: 2;
}

.link-card-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.link-card-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.link-card-sparkle {
  flex-shrink: 0;
  font-size: 0.85rem;
  opacity: 0.85;
}

.link-card-url {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: ltr;
  text-align: right;
  margin-bottom: 6px;
}

.link-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.link-card-cat {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  color: #fff;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.link-card-actions {
  display: flex;
  gap: 4px;
  opacity: 0.55;
  transition: opacity var(--transition);
}
.link-card:hover .link-card-actions { opacity: 1; }

.link-card-actions .btn-icon {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--bg-tertiary);
}

/* حالت خالی */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.empty-state.hidden { display: none; }
.empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-title { font-size: 1.15rem; font-weight: 700; color: var(--text-secondary); margin-bottom: 4px; }
.empty-desc { font-size: 0.9rem; }

/* همگام‌سازی */
.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  white-space: nowrap;
}
.sync-status.ok { color: #27ae60; }
.sync-status.err { color: var(--danger); }
.sync-status.syncing { color: var(--accent); }

.sync-intro {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.7;
}
.sync-steps {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 18px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.8;
}
.sync-steps a { color: var(--accent); font-weight: 600; }
.sync-steps code {
  background: var(--bg-tertiary);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
  direction: ltr;
  display: inline-block;
}
.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 600 !important;
  color: var(--text-primary) !important;
}
.checkbox-label input { width: auto !important; accent-color: var(--accent); }
.sync-message {
  padding: 10px 14px;
  border-radius: var(--radius-xs);
  font-size: 0.85rem;
  margin-bottom: 12px;
}
.sync-message.hidden { display: none; }
.sync-message.ok { background: rgba(39, 174, 96, 0.12); color: #27ae60; }
.sync-message.err { background: var(--danger-soft); color: var(--danger); }
.sync-footer { flex-wrap: wrap; }
.sync-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0 14px;
}
.sync-backup .hint { margin-bottom: 10px; }
.sync-backup-btns { display: flex; gap: 10px; flex-wrap: wrap; }

/* ========== مودال ========== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}
.modal-content {
  position: relative;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  border: 1.5px solid var(--border);
  animation: modalIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-content.modal-sm { max-width: 400px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-24px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 1;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  background: var(--bg-tertiary);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 1rem;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--danger-soft); color: var(--danger); }
.modal-body { padding: 22px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.92rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-group textarea { resize: vertical; min-height: 64px; }
.hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

/* پیش‌نمایش عکس */
.image-preview-area {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding: 14px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--border);
}
.image-preview {
  width: 96px;
  height: 96px;
  border-radius: 14px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  border: 1.5px solid var(--border);
}
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.preview-placeholder { font-size: 2rem; opacity: 0.4; }
.image-inputs { flex: 1; min-width: 0; }
.image-inputs .form-group { margin-bottom: 8px; }

/* تب‌های منبع عکس */
.image-source-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.img-tab {
  flex: 1;
  padding: 7px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}
.img-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.img-tab:hover:not(.active) { border-color: var(--accent); color: var(--accent); }
.img-panel.hidden { display: none; }

/* دراپ فایل */
.file-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 18px 12px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}
.file-drop:hover, .file-drop.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.file-drop-text { font-size: 0.88rem; font-weight: 600; color: var(--text-primary); }
.file-drop-hint { font-size: 0.72rem; color: var(--text-muted); }

/* انتخابگر رنگ */
.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  padding: 0;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--bg-secondary);
}

/* ========== ریسپانسیو ========== */
/* ========== موبایل ========== */
@media (max-width: 700px) {
  .app { padding: 0 12px 28px; }
  .header {
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 0;
  }
  .header-center { order: 3; max-width: 100%; width: 100%; }
  .logo { font-size: 1.5rem; gap: 8px; }
  .logo-icon { width: 44px; height: 44px; font-size: 1.3rem; border-radius: 12px; }
  .logo-img { height: 60px; max-width: 180px; }
  .clock-date-wrap { padding: 4px 8px 4px 4px; gap: 6px; border-radius: 12px; }
  .analog-clock { width: 40px; height: 40px; }
  .clock-mark { transform-origin: 50% 16px; top: 3px; height: 4px; }
  .hour-hand { height: 9px; }
  .minute-hand { height: 12px; }
  .second-hand { height: 14px; }
  .jalali-weekday { font-size: 0.65rem; }
  .jalali-full { font-size: 0.7rem; }
  .theme-btn { width: 38px; height: 38px; font-size: 1.05rem; }
  .toolbar { flex-direction: column; gap: 8px; margin-bottom: 14px; }
  .btn { width: 100%; justify-content: center; padding: 12px 16px; }
  .categories-bar-wrap { margin-bottom: 18px; padding: 4px 2px 12px; }
  .cat-chip { padding: 10px 14px; font-size: 0.82rem; border-radius: 12px; }
  .content-header { margin-bottom: 14px; }
  .content-header h2 { font-size: 1.1rem; }

  /* دو ستون روی موبایل */
  .links-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .link-card {
    aspect-ratio: 1 / 1.05;
    border-radius: 16px;
  }
  .link-card-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
  }
  .link-card-icon-fallback { width: 56px; height: 56px; font-size: 2.2rem; }
  .link-card-icon-area::before { width: 80px; height: 80px; }
  .link-card-body { padding: 10px 10px 10px; }
  .link-card-title { font-size: 0.82rem; }
  .link-card-url { font-size: 0.65rem; margin-bottom: 4px; }
  .link-card-cat { font-size: 0.62rem; padding: 3px 8px; }
  .link-card-actions .btn-icon { width: 28px; height: 28px; font-size: 0.85rem; }
  /* روی موبایل دکمه‌ها همیشه دیده شوند */
  .link-card-actions { opacity: 0.85; }

  .image-preview-area { flex-direction: column; align-items: center; }
  .modal-content { max-width: 100%; border-radius: 16px; }
  .modal { padding: 12px; }
}

/* موبایل خیلی کوچک — یک ستون */
@media (max-width: 380px) {
  .links-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .link-card { aspect-ratio: 1.3 / 1; max-width: 320px; margin: 0 auto; width: 100%; }
  .link-card-icon { width: 72px; height: 72px; }
  .link-card-icon-fallback { width: 72px; height: 72px; font-size: 2.8rem; }
}

/* تبلت */
@media (min-width: 701px) and (max-width: 900px) {
  .links-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
  }
}
