:root {
  --bg: #F8F7F4;
  --card-bg: #FFFFFF;
  --ink: #1a1a1a;
  --ink-secondary: #4a4a4a;
  --ink-muted: #737373;
  --accent: #FF4D00;
  --accent-hover: #E04400;
  --accent-soft: rgba(255, 77, 0, 0.08);
  --border: #1a1a1a;
  --border-light: rgba(26, 26, 26, 0.15);
  --shadow-main: 6px 6px 0px #1a1a1a;
  --shadow-lg: 8px 8px 0px #1a1a1a;
  --shadow-sm: 3px 3px 0px #1a1a1a;
  --font-main: 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Courier New', Courier, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-main);
  background-color: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
}

.hidden {
  display: none !important;
}

.meta-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin-bottom: 0.5rem;
  display: block;
}

.accent-text {
  color: var(--accent);
}

/* ================= Auth Gate ================= */
#authGate {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.auth-card {
  width: 100%;
  max-width: 480px;
  background: var(--card-bg);
  border: 2px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem 2rem;
}

.auth-head {
  text-align: center;
  margin-bottom: 1.75rem;
}

.logo-mark {
  width: 64px;
  height: 64px;
  margin: 0.75rem auto 1rem;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  border-radius: 12px;
}

.auth-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand-logo-img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid var(--border);
  box-shadow: 1.5px 1.5px 0px var(--border);
}

.auth-title {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  margin-bottom: 0.25rem;
  color: var(--ink);
}

.auth-sub {
  font-size: 0.95rem;
  color: var(--ink-secondary);
  line-height: 1.4;
}

.mode-banner {
  background: #FFF2EB;
  border: 2px solid var(--accent);
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--ink);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  line-height: 1.4;
}

.seg-tabs {
  display: flex;
  border: 2px solid var(--border);
  background: #f1f0eb;
  padding: 3px;
  margin-bottom: 1.5rem;
}

.seg-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--ink-muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 10px 0;
  cursor: pointer;
  transition: all 0.15s ease;
}

.seg-tab.active {
  background: var(--ink);
  color: #ffffff;
}

.alert {
  padding: 12px 16px;
  border: 2px solid var(--border);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
  line-height: 1.4;
  font-weight: 600;
}

.alert-error {
  background: #fee2e2;
  border-color: #ef4444;
  color: #991b1b;
}

.alert-success {
  background: #dcfce7;
  border-color: #10b981;
  color: #166534;
}

.field {
  margin-bottom: 1.25rem;
}

.field label {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.4rem;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap input, .url-input, .cookie-url-input {
  width: 100%;
  background: #ffffff;
  border: 2px solid var(--border);
  padding: 12px 42px 12px 14px;
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-wrap input:focus, .url-input:focus, .cookie-url-input:focus, .textarea-flat:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 3px 3px 0px var(--accent);
}

.lead-ico {
  position: absolute;
  right: 14px;
  color: var(--ink-muted);
  font-size: 15px;
  pointer-events: none;
}

.has-eye input {
  padding-left: 42px;
}

.eye-btn {
  position: absolute;
  left: 10px;
  background: none;
  border: none;
  color: var(--ink-muted);
  cursor: pointer;
  font-size: 15px;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.eye-btn:hover {
  color: var(--ink);
}

.strength {
  margin-top: 6px;
}

.strength-bar {
  height: 6px;
  background: #e5e5e5;
  border: 1px solid var(--border);
  position: relative;
}

.strength-bar::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: var(--strength-width, 0%);
  background: var(--strength-color, var(--accent));
  transition: width 0.2s ease;
}

.strength-label {
  font-size: 0.75rem;
  font-weight: 700;
  margin-top: 4px;
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.remember {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-secondary);
  cursor: pointer;
  user-select: none;
  font-weight: 600;
}

.remember input[type="checkbox"] {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
}

/* ================= Buttons ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  padding: 12px 24px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 2px solid var(--border);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}

.btn-primary {
  width: 100%;
  background: var(--ink);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent);
  border-color: var(--border);
  color: #ffffff;
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0px var(--border);
}

.btn-primary:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0px var(--border);
}

.btn-secondary {
  background: #ffffff;
  color: var(--ink);
}

.btn-secondary:hover {
  background: #f1f0eb;
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0px var(--border);
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 1.5rem 0;
  position: relative;
}

.divider::before {
  content: '';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
}

.divider span {
  position: relative;
  background: var(--card-bg);
  padding: 0 12px;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--ink-muted);
  margin: 0 auto;
}

.btn-google {
  width: 100%;
  background: #ffffff;
  color: var(--ink);
}

.btn-google:hover {
  background: #faf8f5;
  border-color: var(--border);
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0px var(--border);
}

.btn-google svg {
  width: 20px;
  height: 20px;
}

.auth-switch {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--ink-secondary);
}

.auth-switch button {
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  margin-right: 4px;
}

.auth-switch button:hover {
  text-decoration: underline;
}

.auth-foot {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--ink-muted);
  line-height: 1.6;
  border-top: 1px solid var(--border-light);
  padding-top: 1rem;
}

.auth-foot a {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.auth-foot a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ================= App Screen ================= */
#appScreen {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  border-bottom: 2px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
}

.brand-name {
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cookies-btn {
  background: #ffffff;
  border: 2px solid var(--border);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  padding: 7px 14px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cookies-btn:hover {
  background: #f1f0eb;
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0px var(--border);
}

.cookies-badge {
  background: var(--accent);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 1px 7px;
  font-family: var(--font-mono);
}

.avatar-btn {
  width: 40px;
  height: 40px;
  border: 2px solid var(--border);
  box-shadow: var(--shadow-sm);
  background: #ffffff;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.15s ease;
}

.avatar-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0px var(--border);
}

.avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 230px;
  background: #ffffff;
  border: 2px solid var(--border);
  box-shadow: var(--shadow-main);
  padding: 8px;
  z-index: 60;
}

.dd-info {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 6px;
}

.dd-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--ink);
}

.dd-email {
  font-size: 0.8rem;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dd-item {
  width: 100%;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--ink);
  transition: background 0.15s ease;
}

.dd-item:hover {
  background: #f1f0eb;
}

.dd-item.danger {
  color: #dc2626;
}

.dd-item.danger:hover {
  background: #fee2e2;
}

/* ================= Main Content ================= */
.app-main {
  flex: 1;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 3.5rem 1.5rem 5rem;
}

.hero {
  text-align: center;
  margin-bottom: 2.5rem;
}

.hero h1 {
  font-size: clamp(2.2rem, 5.5vw, 3.6rem);
  font-weight: 900;
  line-height: 1.35;
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
  color: var(--ink);
  text-wrap: balance;
}

.hero h1 .accent-text {
  display: inline-block;
  margin-top: 0.35rem;
}

.hero p {
  font-size: 1.05rem;
  color: var(--ink-secondary);
  max-width: 600px;
  margin: 0 auto;
  font-weight: 500;
}

.dl-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  margin-bottom: 2rem;
}

.url-row {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 1.25rem;
}

.url-input {
  width: 100%;
  background: #ffffff;
  border: 2px solid var(--border);
  padding: 14px 18px 14px 54px;
  color: var(--ink);
  font-family: inherit;
  font-size: 1.05rem;
}

.mini-btn {
  position: absolute;
  left: 10px;
  background: #f1f0eb;
  border: 1px solid var(--border);
  color: var(--ink);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mini-btn:hover {
  background: var(--accent);
  color: #ffffff;
}

.format-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.fmt-pill {
  background: #ffffff;
  border: 2px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 12px 16px;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.fmt-pill:hover {
  background: #f5f4ef;
}

.fmt-pill:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0px var(--border);
}

.fmt-pill * {
  pointer-events: none;
}

.fmt-pill.active {
  background: var(--accent) !important;
  color: #ffffff !important;
  border-color: var(--border) !important;
  box-shadow: var(--shadow-sm) !important;
}

/* Cookies list in modal */
.cookies-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 140px;
  overflow-y: auto;
}

.cookie-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: #f8f7f4;
  border: 1px solid var(--border-light);
  font-size: 0.85rem;
}

.cookie-item-domain {
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
}

.cookie-item-count {
  font-size: 0.75rem;
  color: var(--ink-muted);
  font-family: var(--font-mono);
}

.btn-del-cookie {
  background: none;
  border: 1px solid transparent;
  color: #ef4444;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 0.8rem;
  border-radius: 2px;
  transition: all 0.15s ease;
}

.btn-del-cookie:hover {
  background: #fee2e2;
  border-color: #ef4444;
}

.no-cookies-msg {
  font-size: 0.8rem;
  color: var(--ink-muted);
  text-align: center;
  padding: 8px;
}

.cta-btn {
  font-size: 1.15rem;
  padding: 15px 28px;
}

/* ================= Result Card ================= */
.result-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-head {
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.5rem;
  margin-bottom: 1.25rem;
}

.result-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.5rem;
  align-items: center;
}

@media (max-width: 640px) {
  .result-grid {
    grid-template-columns: 1fr;
  }
}

.thumb-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: #f1f0eb;
  border: 2px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.thumb-skel {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #f1f0eb 25%, #e5e5e5 50%, #f1f0eb 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.thumb-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.badge-platform {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 0.75rem;
  font-weight: 800;
  color: white;
  padding: 2px 8px;
  border: 1px solid var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-duration {
  position: absolute;
  bottom: 6px;
  left: 6px;
  font-size: 0.75rem;
  font-weight: 800;
  font-family: var(--font-mono);
  background: var(--ink);
  color: white;
  padding: 2px 6px;
}

.result-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge-format {
  background: #FFF2EB;
  color: var(--accent);
  border: 1px solid var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  font-family: var(--font-mono);
  padding: 2px 8px;
}

.result-uploader {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-secondary);
}

.result-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.progress-box {
  background: #f8f7f4;
  border: 2px solid var(--border);
  padding: 12px 14px;
}

.progress-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.stage-text {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-secondary);
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #e5e5e5;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.percent-text {
  font-size: 1rem;
  font-weight: 900;
  font-family: var(--font-mono);
  color: var(--accent);
}

.progress-track {
  width: 100%;
  height: 10px;
  background: #e5e5e5;
  border: 1px solid var(--border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.25s ease;
}

.save-btn {
  margin-top: 4px;
  background: var(--accent);
  color: #ffffff;
}

.save-btn:hover {
  background: var(--ink);
}

/* ================= Footer ================= */
.app-footer {
  border-top: 2px solid var(--border);
  background: var(--bg);
  padding: 2rem 0;
  margin-top: auto;
}

.footer-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--ink-secondary);
}

.apps-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
}

.apps-link:hover {
  color: var(--accent);
}

.footer-links {
  display: flex;
  gap: 10px;
  align-items: center;
}

.footer-links a {
  color: var(--ink-secondary);
  text-decoration: none;
  font-weight: 600;
}

.footer-links a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.copyright {
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

/* ================= Modals ================= */
.modal-overlay, .browser-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: 100%;
  background: #ffffff;
  border: 2px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 16px;
  left: 16px;
  background: #f1f0eb;
  border: 1px solid var(--border);
  color: var(--ink);
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.modal-close:hover {
  background: var(--accent);
  color: #ffffff;
}

.modal-head {
  margin-bottom: 1.5rem;
}

.modal-head h2 {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--ink);
  margin-bottom: 0.25rem;
}

.modal-head p {
  font-size: 0.85rem;
  color: var(--ink-secondary);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-title {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--ink);
}

.panel-title-soft {
  margin-top: 4px;
}

.textarea-flat {
  width: 100%;
  min-height: 120px;
  background: #ffffff;
  border: 2px solid var(--border);
  padding: 10px 12px;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  direction: ltr;
  text-align: left;
  resize: vertical;
}

/* ================= Browser Panel ================= */
.browser-panel {
  width: 100%;
  max-width: 920px;
  height: 85vh;
  background: #ffffff;
  border: 2px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.browser-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #f1f0eb;
  border-bottom: 2px solid var(--border);
}

.browser-close {
  background: none;
  border: none;
  color: var(--ink);
  cursor: pointer;
  font-size: 16px;
}

.browser-close:hover {
  color: var(--accent);
}

.browser-url {
  flex: 1;
  background: #ffffff;
  border: 1px solid var(--border);
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-secondary);
  direction: ltr;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.browser-popout {
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
}

.browser-popout:hover {
  color: var(--accent);
}

.browser-frame-wrap {
  flex: 1;
  background: #ffffff;
}

#browserFrame {
  width: 100%;
  height: 100%;
  border: none;
}

.browser-note {
  padding: 10px 16px;
  background: #f8f7f4;
  border-top: 1px solid var(--border-light);
  font-size: 0.8rem;
  color: var(--ink-secondary);
  line-height: 1.4;
}

/* ================= Toast Notifications ================= */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}

.toast {
  background: #ffffff;
  border: 2px solid var(--border);
  color: var(--ink);
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-main);
  animation: slideInLeft 0.2s ease;
  min-width: 260px;
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-16px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast.success { border-left: 6px solid #10b981; }
.toast.error { border-left: 6px solid #ef4444; }
.toast.info { border-left: 6px solid var(--accent); }

/* =========================================================
   Mobile UI Responsive Layout & Architecture (<= 768px & <= 480px)
   ========================================================= */

@media (max-width: 768px) {
  :root {
    --shadow-main: 4px 4px 0px #1a1a1a;
    --shadow-lg: 5px 5px 0px #1a1a1a;
    --shadow-sm: 2.5px 2.5px 0px #1a1a1a;
  }

  .header-inner {
    padding: 0.9rem 1.15rem;
  }

  .brand-name {
    font-size: 1.35rem;
  }

  .cookies-btn {
    padding: 6px 10px;
    font-size: 0.8rem;
    gap: 6px;
  }

  .avatar-btn {
    width: 36px;
    height: 36px;
  }

  .app-main {
    padding: 1.75rem 1rem 3.5rem;
  }

  .hero {
    margin-bottom: 1.5rem;
  }

  .hero h1 {
    font-size: clamp(1.65rem, 6.8vw, 2.2rem);
    line-height: 1.3;
    margin-bottom: 0.5rem;
  }

  .hero h1 .accent-text {
    display: block;
    margin-top: 0.25rem;
  }

  .dl-card {
    padding: 1.25rem 1rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-lg);
  }

  .url-row {
    margin-bottom: 0.85rem;
  }

  .url-input {
    padding: 12px 14px 12px 46px;
    font-size: 0.95rem;
  }

  .mini-btn {
    width: 34px;
    height: 34px;
    left: 6px;
  }

  .format-row {
    gap: 0.65rem;
    margin-bottom: 0.85rem;
  }

  .fmt-pill {
    padding: 10px 8px;
    font-size: 0.85rem;
    gap: 6px;
    min-height: 46px;
    text-align: center;
  }

  .fmt-pill small {
    display: block;
    font-size: 0.7rem;
    margin-top: 1px;
  }

  .cta-btn {
    font-size: 1rem;
    padding: 13px 18px;
    min-height: 48px;
  }

  .result-card {
    padding: 1.25rem 1rem;
    box-shadow: var(--shadow-lg);
  }

  .result-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .result-title {
    font-size: 1rem;
  }

  .progress-box {
    padding: 10px 12px;
  }

  .save-btn {
    min-height: 48px;
    font-size: 0.95rem;
    padding: 12px 16px;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
    gap: 12px;
    justify-content: center;
  }

  .footer-links {
    justify-content: center;
    gap: 10px;
  }

  .apps-link {
    justify-content: center;
  }

  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 16px;
    align-items: center;
  }

  .toast {
    width: 100%;
    max-width: 380px;
    min-width: 0;
    padding: 10px 14px;
    font-size: 0.85rem;
  }
}

@media (max-width: 640px) {
  .app-main {
    padding: 2.5rem 1rem 4rem;
  }

  .hero {
    margin-top: 1.5rem;
    margin-bottom: 2rem;
    padding-top: 1rem;
  }

  .hero h1 {
    font-size: 1.85rem;
    line-height: 1.4;
    margin-top: 0.5rem;
    margin-bottom: 1.25rem;
  }
}

@media (max-width: 480px) {
  .app-main {
    padding: 2.75rem 0.85rem 3.5rem;
  }

  .hero {
    margin-top: 2rem;
    margin-bottom: 1.75rem;
    padding-top: 0.75rem;
  }

  .hero h1 {
    font-size: 1.65rem;
    line-height: 1.45;
  }

  #authGate {
    padding: 1rem 0.75rem;
    align-items: flex-start;
    padding-top: 2.5rem;
  }

  .auth-card {
    padding: 1.5rem 1.15rem;
    box-shadow: 4px 4px 0px var(--border);
  }

  .logo-mark {
    width: 52px;
    height: 52px;
    margin: 0.25rem auto 0.65rem;
    border-radius: 10px;
  }

  .auth-title {
    font-size: 1.6rem;
  }

  .auth-sub {
    font-size: 0.85rem;
  }

  .seg-tabs {
    margin-bottom: 1.15rem;
  }

  .seg-tab {
    padding: 8px 0;
    font-size: 0.85rem;
  }

  .input-wrap input, .cookie-url-input {
    padding: 11px 38px 11px 12px;
    font-size: 0.9rem;
  }

  .lead-ico {
    right: 12px;
    font-size: 13px;
  }

  .form-row {
    margin-bottom: 1.15rem;
    font-size: 0.8rem;
  }

  .btn {
    padding: 11px 16px;
    font-size: 0.95rem;
  }

  .cookies-btn-text {
    display: none;
  }

  .cookies-btn {
    padding: 6px 8px;
  }

  .format-row {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .fmt-pill {
    flex-direction: row;
    padding: 10px 8px;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 800;
  }

  .fmt-pill span {
    font-size: 0.9rem;
    line-height: 1.2;
    display: inline;
  }

  .modal-overlay, .browser-overlay {
    padding: 12px;
  }

  .modal {
    padding: 1.25rem 1rem;
    box-shadow: 4px 4px 0px var(--border);
  }

  .modal-head h2 {
    font-size: 1.15rem;
  }

  .browser-panel {
    height: 92vh;
    max-height: 92vh;
  }
}

/* ================= SEO & GEO Content Block ================= */
.seo-section {
  width: 100%;
  max-width: 760px;
  margin: 2.5rem auto 1.5rem;
  background: var(--card-bg);
  border: 2px solid var(--border);
  box-shadow: var(--shadow-main);
  padding: 2rem;
  border-radius: 12px;
}

.seo-head {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px dashed var(--border-light);
}

.seo-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.seo-subtitle {
  font-size: 0.95rem;
  color: var(--ink-secondary);
  line-height: 1.5;
}

.seo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.seo-card {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 1.25rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.seo-card:hover {
  transform: translateY(-2px);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.seo-card-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
}

.seo-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--ink);
}

.seo-card p {
  font-size: 0.88rem;
  color: var(--ink-secondary);
  line-height: 1.5;
}

.keywords-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 2px dashed var(--border-light);
}

.kw-badge {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(255, 77, 0, 0.2);
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.faq-section {
  margin-top: 2rem;
}

.faq-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 1rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.faq-item {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}

.faq-item h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.4rem;
}

.faq-item p {
  font-size: 0.88rem;
  color: var(--ink-secondary);
  line-height: 1.5;
}

@media (max-width: 640px) {
  .seo-grid {
    grid-template-columns: 1fr;
  }
  .seo-section {
    padding: 1.25rem;
    margin: 1.5rem 0;
  }
}

@media (max-width: 360px) {
  .format-row {
    grid-template-columns: 1fr;
  }

  .fmt-pill {
    flex-direction: row;
    padding: 10px 12px;
    justify-content: center;
  }

  .fmt-pill span {
    flex-direction: row;
    gap: 6px;
  }
}

/* ================= Cookies Manager & Modal ================= */
.btn-cookie-header {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border: 2px solid var(--border);
  box-shadow: 2px 2px 0px var(--border);
  padding: 6px 14px;
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.btn-cookie-header:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0px var(--border);
  background: #FFF5F0;
}

.cookie-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  background: var(--accent);
  color: #FFFFFF;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 800;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-container {
  background: var(--card-bg);
  border: 2px solid var(--border);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 2px solid var(--border);
  background: #FAFAF8;
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ink);
  margin: 0;
}

.modal-subtitle {
  font-size: 0.8rem;
  color: var(--ink-secondary);
  margin: 2px 0 0 0;
}

.modal-close-btn {
  background: none;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--ink-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.modal-close-btn:hover {
  background: #FEE2E2;
  color: #DC2626;
  border-color: #DC2626;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.cyber-notice {
  background: #F0FDF4;
  border: 1.5px solid #16A34A;
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
  color: #14532D;
  line-height: 1.5;
}

.cyber-notice-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #15803D;
  margin-bottom: 6px;
  font-size: 0.92rem;
}

.cyber-steps {
  margin: 8px 1.25rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cyber-steps li {
  font-size: 0.84rem;
}

.code-tag {
  background: #DCFCE7;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  direction: ltr;
  display: inline-block;
}

.cookie-fields-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

#cookieDataInput {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: 6px;
  resize: vertical;
  background: #FAFAF8;
  color: var(--ink);
  direction: ltr;
  text-align: left;
}

#cookieDataInput:focus {
  outline: none;
  border-color: var(--accent);
  background: #FFFFFF;
}

.btn-outline {
  background: #FFFFFF;
  border: 2px solid var(--border);
  box-shadow: 2px 2px 0px var(--border);
  padding: 8px 14px;
  font-weight: 700;
  font-family: var(--font-main);
  font-size: 0.86rem;
  color: var(--ink);
  cursor: pointer;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-outline:hover {
  background: #F3F4F6;
  transform: translate(-1px, -1px);
}

.btn-outline-danger {
  background: #FFFFFF;
  border: 2px solid #EF4444;
  box-shadow: 2px 2px 0px #EF4444;
  padding: 8px 14px;
  font-weight: 700;
  font-family: var(--font-main);
  font-size: 0.86rem;
  color: #DC2626;
  cursor: pointer;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-outline-danger:hover {
  background: #FEF2F2;
  transform: translate(-1px, -1px);
}

.cookies-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cookie-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #FAFAF8;
  border: 1.5px solid var(--border-light);
  border-radius: 6px;
  transition: all 0.15s;
}

.cookie-item:hover {
  border-color: var(--border);
  background: #FFFFFF;
}

.cookie-item-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cookie-item-domain {
  font-weight: 700;
  color: var(--ink);
  direction: ltr;
  text-align: left;
}

.empty-cookies-placeholder {
  text-align: center;
  padding: 24px 12px;
  color: var(--ink-secondary);
  font-size: 0.9rem;
}

/* ================= Engine Meta Bar & Updater ================= */
.engine-meta-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.82rem;
  color: var(--ink-secondary);
}

.engine-meta-bar strong {
  color: var(--ink);
  font-weight: 800;
}

.mono-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.result-head-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--ink-secondary);
}

.cancel-btn {
  margin-top: 10px;
  width: 100%;
  border: 1.5px dashed var(--border);
  font-size: 0.88rem;
  padding: 10px 16px;
}

.updater-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: #F8F7F4;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 1.15rem;
}

.updater-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
}

.updater-sub {
  font-size: 0.8rem;
  color: var(--ink-secondary);
  margin-top: 3px;
}

.saved-count-text {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
}

.cookie-action-btn {
  background: #ffffff;
  border: 1.5px solid var(--border);
  color: var(--ink);
  width: 34px;
  height: 34px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cookie-action-btn:hover {
  background: #F1F0EB;
}

.cookie-action-btn.danger {
  color: #DC2626;
  border-color: #DC2626;
}

.cookie-action-btn.danger:hover {
  background: #FEE2E2;
}

/* ================= Delete App & Account UI ================= */
.dd-divider {
  border: 0;
  border-top: 1px solid var(--border-light);
  margin: 6px 0;
}

.footer-danger-link {
  background: none;
  border: none;
  font-family: inherit;
  font-size: inherit;
  font-weight: 700;
  color: #DC2626;
  cursor: pointer;
  padding: 0;
}

.footer-danger-link:hover {
  text-decoration: underline;
}

.delete-app-list {
  margin: 0 1.25rem 1rem 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--ink);
}

.delete-confirm-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: #FEF2F2;
  border: 1.5px solid #EF4444;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #991B1B;
  cursor: pointer;
  user-select: none;
}

.delete-confirm-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #DC2626;
  cursor: pointer;
}

.btn-danger-solid {
  background: #DC2626;
  color: #ffffff;
  border: 2px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 10px 18px;
  font-size: 0.92rem;
}

.btn-danger-solid:hover:not(:disabled) {
  background: #B91C1C;
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0px var(--border);
}

.btn-danger-solid:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#appDeletedScreen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.deleted-icon-wrap {
  width: 68px;
  height: 68px;
  margin: 0 auto 1.25rem;
  border-radius: 14px;
  border: 2px solid var(--border);
  box-shadow: var(--shadow-sm);
  background: #FEF2F2;
  color: #DC2626;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
}

/* ================= Legal Pages (/سياسات-الخصوصية & /المستخدم) ================= */
.legal-main {
  flex: 1;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.legal-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem 2.25rem;
}

.legal-head {
  border-bottom: 2px solid var(--border);
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
}

.legal-kicker {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.legal-title {
  font-size: clamp(1.6rem, 3.5vw, 2.25rem);
  font-weight: 900;
  color: var(--ink);
  line-height: 1.3;
  margin-bottom: 0.75rem;
}

.legal-lead {
  font-size: 1.02rem;
  color: var(--ink-secondary);
  line-height: 1.7;
}

.legal-section {
  margin-bottom: 1.75rem;
}

.legal-section:last-child {
  margin-bottom: 0;
}

.legal-section h2 {
  font-size: 1.18rem;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 0.65rem;
}

.legal-section p {
  font-size: 0.96rem;
  color: var(--ink-secondary);
  line-height: 1.75;
  margin-bottom: 0.65rem;
}

.legal-section ul {
  margin: 0.5rem 1.35rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--ink-secondary);
  font-size: 0.95rem;
  line-height: 1.7;
}

.legal-section code {
  background: #F1F0EB;
  border: 1px solid var(--border-light);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  color: var(--ink);
  direction: ltr;
  display: inline-block;
}

@media (max-width: 640px) {
  .legal-card {
    padding: 1.5rem 1.25rem;
  }
  .cookie-fields-row {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ================= Cloudflare Encrypted Vault Sync Box ================= */
.cf-vault-box {
  background: #FFFFFF;
  border: 2px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cf-vault-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.cf-vault-head .updater-info {
  flex: 1 1 240px;
  min-width: 0;
}

.cf-vault-head .btn {
  width: auto;
  flex-shrink: 0;
}

.cf-vault-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.cf-vault-actions .btn {
  width: auto;
  flex: 1 1 200px;
}




