@font-face {
  font-family: Yasham Arabic;
  src: url('/assets/arabic.ttf') format('truetype');
  font-weight: 200 1000;
  font-display: swap;
}

:root {
  color-scheme: dark;
  font-family: 'Yasham Arabic', Cairo, 'Segoe UI', Tahoma, sans-serif;
  color: var(--ink);
  background: var(--page);
  --ink: #edf5ff;
  --page: #070b15;
  --surface: #0d1524;
  --surface-raised: #101a2a;
  --surface-subtle: #111b2c;
  --surface-hover: #182841;
  --sidebar: #0a101d;
  --field: #0a111f;
  --outline: #29384e;
  --outline-strong: #35445c;
  --outline-hover: #43627e;
  --muted: #a3b4ca;
  --placeholder: #8c9db5;
  --accent: #53ddf5;
  --accent-hover: #91efff;
  --accent-ink: #05121d;
  --accent-text: #53ddf5;
  --accent-subtle: #13283a;
  --accent-border: #1e4558;
  --danger: #ff9ca7;
  --danger-ink: #1a0710;
  --danger-hover: #ffbdc5;
  --danger-subtle: #3a1b27;
  --danger-border: #6a3947;
  --green: #92e3c0;
  --green-subtle: #143c36;
  --green-border: #326853;
  --draft: #c8d6e8;
  --draft-subtle: #283348;
  --feature: #90e8ff;
  --feature-subtle: #19384d;
  --focus: #80e9ff;
  --glow-main: #10314b90;
  --glow-secondary: #131e4d75;
  --glow-grid: #70bbff10;
  --workspace-glow: #11274670;
  --card-top: #13213a;
  --card-bottom: #0d1626;
  --shadow: #01050d78;
  --backdrop: #020714b8;
}

:root[data-theme='light'] {
  color-scheme: light;
  --ink: #122b42;
  --page: #edf3f8;
  --surface: #fff;
  --surface-raised: #f8fbfe;
  --surface-subtle: #edf3f8;
  --surface-hover: #e2edf7;
  --sidebar: #f7fbff;
  --field: #fff;
  --outline: #cedbe6;
  --outline-strong: #9eb2c4;
  --outline-hover: #7794af;
  --muted: #495f73;
  --placeholder: #536b81;
  --accent: #086986;
  --accent-hover: #005470;
  --accent-ink: #fff;
  --accent-text: #075d79;
  --accent-subtle: #dceef6;
  --accent-border: #afd4e7;
  --danger: #9e3547;
  --danger-ink: #fff;
  --danger-hover: #802339;
  --danger-subtle: #f9e5e8;
  --danger-border: #e0aeb9;
  --green: #1b604b;
  --green-subtle: #dfefe9;
  --green-border: #b5d5c7;
  --draft: #38536a;
  --draft-subtle: #e7edf4;
  --feature: #075a76;
  --feature-subtle: #dceef6;
  --focus: #087ba5;
  --glow-main: #9fd3ef8c;
  --glow-secondary: #b3cafa76;
  --glow-grid: #40709e1c;
  --workspace-glow: #b2d8f369;
  --card-top: #fff;
  --card-bottom: #eff6fc;
  --shadow: #173b5c2c;
  --backdrop: #152c4972;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { min-width: 280px; margin: 0; font-size: 1rem; line-height: 1.65; }
h1, h2, h3, p, dl, dd { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
button:disabled { cursor: wait; opacity: .64; }

.visually-hidden, .skip:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  white-space: nowrap;
  clip-path: inset(50%);
  border: 0;
}

.skip:focus {
  position: fixed;
  inset: 12px 12px auto auto;
  z-index: 10;
  padding: 10px 16px;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 8px;
}

.wordmark { display: inline-flex; align-items: center; gap: 11px; align-self: flex-start; }
.brand-mark { position: relative; display: inline-block; width: 38px; height: 38px; border-radius: 10px; overflow: hidden; background: #fff; flex: 0 0 auto; }
.brand-mark img { position: absolute; width: 162%; height: 162%; max-width: none; top: -10.5%; left: -31%; }
.brand-type { display: grid; font: 750 1.06rem/1.12 'Segoe UI', sans-serif; letter-spacing: .14em; }
.brand-type span { color: var(--muted); font-size: .69rem; letter-spacing: .18em; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6em;
  min-height: 44px;
  padding: .55rem 1rem;
  border: 1px solid transparent;
  border-radius: 9px;
  color: inherit;
  background: transparent;
  font-size: .93rem;
  font-weight: 650;
  white-space: nowrap;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.primary { color: var(--accent-ink); background: var(--accent); }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.secondary { border-color: var(--outline); background: var(--surface-subtle); }
.secondary:hover:not(:disabled) { border-color: var(--outline-hover); background: var(--surface-hover); }
.danger { color: var(--danger-ink); background: var(--danger); }
.danger:hover:not(:disabled) { background: var(--danger-hover); }
.text-danger { color: var(--danger); }
.text-danger:hover:not(:disabled) { background: var(--danger-subtle); }
.preferences { display: flex; gap: 6px; flex-wrap: wrap; }
.preferences .button { padding-inline: .65rem; }

.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 76% 7%, var(--glow-main), transparent 48%),
    radial-gradient(ellipse at 17% 90%, var(--glow-secondary), transparent 45%),
    repeating-linear-gradient(0deg, transparent 0 67px, var(--glow-grid) 67px 68px),
    repeating-linear-gradient(90deg, transparent 0 67px, var(--glow-grid) 67px 68px),
    var(--page);
}

.auth-card {
  position: relative;
  width: min(100%, 445px);
  display: grid;
  gap: 15px;
  padding: clamp(24px, 6vw, 43px);
  border: 1px solid var(--outline-strong);
  border-radius: 21px;
  background: linear-gradient(150deg, var(--card-top), var(--surface-raised) 70%);
  box-shadow: 0 32px 100px var(--shadow);
}

.auth-card::before {
  position: absolute;
  content: '';
  inset: -1px 32px auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-text), transparent);
}

.auth-card .wordmark { justify-self: start; }
.auth-card .preferences { margin-bottom: 9px; }
.auth h1 { font-size: clamp(1.65rem, 7vw, 2.3rem); line-height: 1.22; }
.auth-description, .subtitle { color: var(--muted); }
.auth form { display: grid; gap: 12px; }
.auth form .button { margin-top: 4px; }
.auth-home { width: fit-content; margin-top: 4px; color: var(--accent-text); }
.auth-home:hover { text-decoration: underline; }

.workspace { display: grid; grid-template-columns: minmax(178px, 226px) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  inset-block-start: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  height: fit-content;
  gap: 44px;
  padding: 30px 22px 24px;
  border-inline-end: 1px solid var(--outline);
  background: var(--sidebar);
}

.admin-navigation { display: grid; gap: 8px; }
.navigation-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 11px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  font-size: .92rem;
}

.navigation-link:hover { color: var(--ink); background: var(--surface-hover); }
.navigation-link.current { color: var(--accent-text); background: var(--accent-subtle); border-color: var(--accent-border); }
.grid-icon { width: 1em; height: 1em; display: inline-block; border: 1px solid currentColor; border-radius: 3px; background: linear-gradient(90deg, transparent 45%, currentColor 45% 53%, transparent 53%), linear-gradient(0deg, transparent 45%, currentColor 45% 53%, transparent 53%); }
.sidebar-actions { display: grid; gap: 9px; margin-top: auto; }

.workspace-body {
  min-width: 0;
  width: min(100%, 1460px);
  justify-self: center;
  padding: clamp(26px, 5vw, 64px) clamp(18px, 5vw, 64px);
  background: radial-gradient(ellipse at 89% 0, var(--workspace-glow), transparent 62%);
}
:root[dir='ltr'] .workspace-body { background-position: left; background-image: radial-gradient(ellipse at 11% 0, var(--workspace-glow), transparent 62%); }

.workspace-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.section-context { color: var(--accent-text); font-weight: 650; font-size: .875rem; }
.workspace-header h1 { margin-block: 3px 6px; font-size: clamp(2.3rem, 5vw, 4.2rem); line-height: 1.08; letter-spacing: -.025em; }
.add-project > span[aria-hidden] { font-size: 1.3em; line-height: .8; }

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(7px, 2vw, 18px);
  margin-block: clamp(24px, 4vw, 43px);
}

.metric {
  min-width: 0;
  padding: clamp(10px, 2vw, 24px);
  border: 1px solid var(--outline);
  border-radius: 13px;
  background: linear-gradient(145deg, var(--card-top), var(--card-bottom) 75%);
}

.metric dt { color: var(--muted); font-size: .875rem; line-height: 1.3; }
.metric dd { margin-top: .35rem; font-size: clamp(1.65rem, 4vw, 2.65rem); font-weight: 700; line-height: 1.08; }
.metric:nth-child(2) dd { color: var(--accent-text); }

.collection { overflow: hidden; border: 1px solid var(--outline); border-radius: 15px; background: var(--surface); }
.collection-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 13px 24px; padding: clamp(16px, 2vw, 24px); }
.collection h2 { font-size: 1.22rem; }
.tool-bar { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.search-field, .select-field { position: relative; }
.search-field { width: min(100%, 17rem); }
.search-icon { position: absolute; inset-block-start: 15px; inset-inline-start: 13px; width: 11px; height: 11px; border: 1px solid var(--muted); border-radius: 50%; pointer-events: none; }
.search-icon::after { content: ''; position: absolute; width: 5px; inset-block-end: -2px; inset-inline-end: -4px; border-top: 1px solid var(--muted); transform: rotate(-45deg); }
:root[dir='ltr'] .search-icon::after { transform: rotate(45deg); }
.select-field::after { content: ''; position: absolute; width: 7px; height: 7px; inset-block-end: 20px; inset-inline-end: 13px; border-inline-end: 1px solid currentColor; border-block-end: 1px solid currentColor; transform: rotate(45deg); pointer-events: none; }

input:not([type='checkbox']), textarea, select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: .55rem .7rem;
  border: 1px solid var(--outline-strong);
  border-radius: 8px;
  color: var(--ink);
  background: var(--field);
  caret-color: var(--accent-text);
  font-size: 1rem;
}

.search-field input { padding-inline-start: 34px; }
select { appearance: none; padding-inline-end: 31px; cursor: pointer; }
input::placeholder { color: var(--placeholder); opacity: 1; }
input:disabled, select:disabled, textarea:disabled { opacity: .7; }
textarea { resize: vertical; }
input[type='checkbox'] { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }

table { width: 100%; border-collapse: collapse; text-align: start; }
thead { color: var(--muted); background: var(--surface-subtle); }
th, td { padding: 13px clamp(10px, 1.5vw, 22px); text-align: start; }
thead th { font-size: .875rem; font-weight: 600; }
tbody tr { border-block-start: 1px solid var(--outline); }
tbody tr:hover, tbody tr:focus-within { background: var(--surface-raised); }
tbody th { width: 45%; max-width: 290px; font-weight: 500; }
.project-name, .project-summary { display: block; overflow-wrap: anywhere; }
.project-name { font-weight: 700; }
.project-summary { color: var(--muted); font-size: .875rem; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.project-category { color: var(--muted); font-size: .89rem; }
.project-states, .project-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.project-actions { flex-wrap: nowrap; }
.project-actions .button { padding-inline: .65rem; }
.status-chip, .featured-chip { display: inline-flex; align-items: center; white-space: nowrap; padding: .15rem .55rem; border-radius: 6px; font-size: .875rem; font-weight: 600; }
.status-chip { color: var(--draft); background: var(--draft-subtle); }
.status-chip.is-published { color: var(--green); background: var(--green-subtle); }
.featured-chip { color: var(--feature); background: var(--feature-subtle); }

.empty-state { display: grid; justify-items: center; gap: 8px; padding: 30px 20px 34px; text-align: center; border-block-start: 1px solid var(--outline); }
.empty-state p { color: var(--muted); }
.empty-state button { margin-top: 5px; }
.notice { color: var(--muted); }
.notice.is-error { color: var(--danger); }
.list-notice { padding: 18px 21px; }
.notification { width: fit-content; margin-block-start: 20px; padding: 10px 15px; border: 1px solid var(--green-border); border-radius: 9px; color: var(--green); background: var(--green-subtle); }
.notification.is-error { color: var(--danger); background: var(--danger-subtle); border-color: var(--danger-border); }

.modal {
  width: min(100% - 2rem, 690px);
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  padding: 0;
  border: 1px solid var(--outline-strong);
  border-radius: 16px;
  overflow: hidden;
  color: var(--ink);
  background: var(--surface-raised);
  box-shadow: 0 25px 95px var(--shadow);
}

.modal::backdrop { background: var(--backdrop); backdrop-filter: blur(4px); }
.modal form { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; max-height: calc(100dvh - 2rem - 2px); }
.modal-header, .modal-body, .modal-footer { padding: clamp(14px, 3vw, 22px); }
.modal-header, .modal-footer { display: flex; align-items: center; gap: 9px; }
.modal-header { justify-content: space-between; border-block-end: 1px solid var(--outline); }
.modal-header h2 { font-size: 1.4rem; line-height: 1.3; }
.modal-header p { margin-top: 4px; color: var(--muted); font-size: .9rem; }
.modal-body { overflow-y: auto; overscroll-behavior: contain; }
.modal-body .notice { margin-top: 9px; }
.modal-footer { border-block-start: 1px solid var(--outline); }
.icon-button { height: 44px; width: 44px; flex: 0 0 44px; border-radius: 9px; background: var(--surface-subtle); color: var(--ink); border: 1px solid var(--outline); font: 1.5rem/1 'Segoe UI', sans-serif; }
.icon-button:hover { background: var(--surface-hover); }
fieldset { display: grid; gap: 13px; margin: 0; padding: 0; border: 0; min-inline-size: 0; }
.modal label { display: grid; min-width: 0; gap: 5px; font-size: .94rem; font-weight: 600; }
.field-row, .toggles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.project-locales { align-items: start; }
.language-fields { gap: 9px; padding: 10px; border: 1px solid var(--outline); border-radius: 9px; }
.language-fields legend { padding-inline: 5px; color: var(--accent-text); font-size: .9rem; font-weight: 700; }
.translation-hint { line-height: 1.45; }
.field-hint { color: var(--muted); font-size: .875rem; font-weight: 400; }
.toggles label { display: flex; align-items: center; gap: 9px; min-height: 64px; padding: 8px 10px; border: 1px solid var(--outline); border-radius: 8px; background: var(--surface-subtle); cursor: pointer; }
.toggles span { min-width: 0; }
.toggles small { display: block; color: var(--muted); font-size: .84rem; font-weight: 400; line-height: 1.3; }
.delete-modal { max-width: 460px; }

@media (max-width: 800px) {
  .workspace { display: block; }
  .sidebar { position: static; min-height: auto; display: flex; flex-wrap: wrap; flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; padding: 14px clamp(16px, 5vw, 34px); border-inline-end: 0; border-block-end: 1px solid var(--outline); }
  .sidebar .wordmark { align-self: center; }
  .admin-navigation { display: flex; }
  .admin-navigation .current { display: none; }
  .sidebar-actions { display: flex; flex-wrap: wrap; margin: 0; }
}

@media (max-width: 560px) {
  .sidebar .admin-navigation { display: none; }
  .collection-header, .tool-bar { align-items: stretch; }
  .tool-bar { flex: 1 1 100%; flex-wrap: nowrap; }
  .search-field { flex: 1 1 0; min-width: 0; }
  .select-field { flex: 0 1 auto; }
  th, td { padding: 0; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table, tbody { display: block; }
  tbody tr { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px 13px; padding: 13px 15px; }
  tbody th { grid-column: 1 / -1; width: auto; max-width: none; }
  tbody td:nth-child(3) { grid-column: 2; grid-row: 2; }
  tbody td:last-child { grid-column: 1 / -1; }
  .project-actions .button { min-height: 44px; }
  .field-row { grid-template-columns: 1fr; }
}

@media (max-width: 355px) {
  .tool-bar { flex-wrap: wrap; }
  .search-field { flex-basis: 100%; }
  .toggles { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
