@font-face {
  font-family: "Vazirmatn";
  src:
    url("/static/fonts/Vazirmatn.woff2") format("woff2-variations"),
    url("/static/fonts/Vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;

  --bg: #f3f5f0;
  --fg: #1a302c;
  --card: #fff;
  --surface-2: #f0f5f0;
  --surface-3: #e2eee6;
  --field-bg: #fafbf8;
  --primary: #176451;
  --primary-fg: #fff;
  --primary-hover: #105644;
  --muted-fg: #566a62;
  --border: #e0e7df;
  --border-strong: #cbd9cf;
  --ring: #267c66;
  --brand: #176451;
  --success: #286447;
  --destructive: #a03431;
  --placeholder: #63766d;
  --accent-surface: #e4efe6;
  --accent-border: #c8dfcd;
  --accent-text: #16533f;
  --accent-well: #f0f7ee;
  --drop-border: #91b5a3;
  --drop-hover: #e6f3e9;
  --info-surface: #edf4fa;
  --info-border: #cadde9;
  --info-text: #285879;
  --warning-surface: #fbf6e5;
  --warning-border: #e6d9ac;
  --warning-text: #64511c;
  --danger-surface: #fcf0ed;
  --danger-border: #edceca;
  --danger-hover: #fae4de;
  --composer-glow: #f5faf3;
  --auth-glow: #e4efe3;

  --radius-control: 10px;
  --radius-field: 10px;
  --radius-surface: 20px;
  --surface-highlight: 0 12px 32px -24px rgb(21 55 43 / 32%);
  --motion: 200ms;
  --motion-ease: cubic-bezier(0.2, 0, 0, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101916;
  --fg: #e7f0eb;
  --card: #18251f;
  --surface-2: #203128;
  --surface-3: #294036;
  --field-bg: #121e18;
  --primary: #93d8af;
  --primary-fg: #112a1d;
  --primary-hover: #a9e6bf;
  --muted-fg: #acbfb3;
  --border: #2d4337;
  --border-strong: #416052;
  --ring: #91dcb4;
  --brand: #a0dcba;
  --success: #a9dbb7;
  --destructive: #ffc0b7;
  --placeholder: #91ab9c;
  --accent-surface: #263d31;
  --accent-border: #3e6150;
  --accent-text: #b6e5c5;
  --accent-well: #1e3228;
  --drop-border: #5a8d74;
  --drop-hover: #263e31;
  --info-surface: #203744;
  --info-border: #395769;
  --info-text: #c0dfee;
  --warning-surface: #39321f;
  --warning-border: #635535;
  --warning-text: #efdb9e;
  --danger-surface: #402825;
  --danger-border: #6e453e;
  --danger-hover: #53312c;
  --composer-glow: #203329;
  --auth-glow: #1e3328;
  --surface-highlight: 0 16px 34px -27px rgb(0 0 0 / 80%);
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "Vazirmatn", Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.8;
  letter-spacing: 0;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--fg);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.icon {
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.container {
  max-width: 1376px;
  margin-inline: auto;
  padding: 24px 16px 56px;
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.narrow-container {
  width: 100%;
  max-width: 480px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-surface);
  box-shadow: var(--surface-highlight);
  margin-bottom: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.25;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-surface);
  border: 1px solid var(--accent-border);
  color: var(--brand);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-surface);
  box-shadow: var(--surface-highlight);
  padding: 24px;
  margin-bottom: 20px;
}

.card-sub {
  background: var(--surface-2);
  border-radius: 14px;
  padding: 16px;
}

.card-title {
  margin: 0 0 12px;
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.3;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.row-between { justify-content: space-between; }
.row-end { justify-content: flex-end; }
.row-nowrap { flex-wrap: nowrap; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

label {
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--muted-fg);
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: var(--radius-field);
  border: 1px solid var(--border-strong);
  background: var(--field-bg);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.94rem;
  line-height: 1.5;
  transition: border-color var(--motion) var(--motion-ease), box-shadow var(--motion) var(--motion-ease);
}

@supports (-webkit-touch-callout: none) {
  input, select, textarea {
    font-size: 1rem;
  }
}

input::placeholder,
textarea::placeholder {
  color: var(--placeholder);
}

input.ltr,
textarea.ltr {
  direction: ltr;
  text-align: left;
}

textarea {
  min-height: 132px;
  resize: vertical;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.btn:focus-visible,
.tab-btn:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.input-group {
  direction: ltr;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 6px;
}

.input-eye-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--field-bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-field);
  color: var(--muted-fg);
  cursor: pointer;
}

.input-eye-btn:hover,
.input-eye-btn[aria-pressed="true"] {
  color: var(--fg);
  background: var(--surface-2);
}

.input-eye-btn:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.input-eye-btn .eye-slash { display: none; }
.input-group input::-ms-reveal { display: none; }
.input-eye-btn[aria-pressed="true"] .eye-slash { display: inline; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--fg);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.5;
  text-decoration: none;
  transition:
    background var(--motion) var(--motion-ease),
    border-color var(--motion) var(--motion-ease),
    transform var(--motion) var(--motion-ease),
    opacity var(--motion) var(--motion-ease);
}

.btn:hover {
  background: var(--surface-3);
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
}

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

.btn-danger {
  background: var(--danger-surface);
  border-color: var(--danger-border);
  color: var(--destructive);
}

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

.btn-sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.82rem;
}

.theme-toggle[hidden] { display: none; }
.topbar-identity { align-items: center; }
.theme-toggle[aria-pressed="true"] {
  background: var(--accent-surface);
  border-color: var(--accent-border);
  color: var(--accent-text);
}

.btn-icon {
  min-height: 44px;
  min-width: 44px;
  padding: 0;
}

.tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--field-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 18px;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 9px;
  border: 0;
  background: transparent;
  color: var(--muted-fg);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.4;
  transition: background var(--motion) var(--motion-ease), color var(--motion) var(--motion-ease);
}

.tab-btn:hover {
  color: var(--fg);
}

.tab-btn.active {
  background: var(--accent-surface);
  color: var(--accent-text);
  box-shadow: var(--surface-highlight);
}

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: 14px;
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  margin-bottom: 16px;
  background: var(--field-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: border-color var(--motion) var(--motion-ease), background var(--motion) var(--motion-ease);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--brand);
  background: var(--drop-hover);
}

.dropzone-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--brand);
}

.advanced-options {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  background: var(--field-bg);
}

.advanced-options summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted-fg);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.advanced-options[open] summary {
  margin-bottom: 12px;
  color: var(--fg);
}

.progress-wrap {
  width: 100%;
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0;
}

.progress-compact {
  margin: 0;
  height: 6px;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--brand);
  transition: width 0.2s var(--motion-ease);
}

.disk-bar {
  min-width: 240px;
  flex: 1;
  max-width: 380px;
}

.disk-text {
  font-size: 0.8rem;
  color: var(--muted-fg);
  margin-bottom: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--fg);
}

.badge-gap { margin-inline-start: 6px; }
.badge-public { color: var(--success); border-color: var(--accent-border); background: var(--accent-well); }
.badge-accounts { color: var(--info-text); border-color: var(--info-border); background: var(--info-surface); }
.badge-admin { color: var(--warning-text); border-color: var(--warning-border); background: var(--warning-surface); }
.badge-danger { color: var(--destructive); border-color: var(--danger-border); background: var(--danger-surface); }

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: start;
  vertical-align: middle;
}

th {
  color: var(--muted-fg);
  font-weight: 600;
  white-space: nowrap;
  font-size: 0.82rem;
}

tbody tr:hover {
  background: var(--field-bg);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  direction: ltr;
  unicode-bidi: isolate;
}

.inline-ltr-math {
  display: inline-block;
  direction: ltr;
  unicode-bidi: isolate;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--brand);
  font-weight: 700;
}

.pre-box {
  background: var(--field-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  direction: auto;
  max-height: 60vh;
  overflow: auto;
}

.alert {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
  font-size: 0.88rem;
  line-height: 1.7;
}

.alert-error {
  background: var(--danger-surface);
  border: 1px solid var(--danger-border);
  color: var(--destructive);
}

.alert-success {
  background: var(--accent-well);
  border: 1px solid var(--accent-border);
  color: var(--success);
}

.alert-warn {
  background: var(--warning-surface);
  border: 1px solid var(--warning-border);
  color: var(--warning-text);
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted-fg);
  font-size: 0.86rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 12px;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--fg);
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--brand);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: oklch(0 0 0 / 75%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 500px;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-surface);
  box-shadow: 0 20px 50px -20px oklch(0 0 0 / 85%);
  padding: 22px;
  max-height: 90vh;
  overflow-y: auto;
}

.share-details {
  width: min(550px, calc(100% - 32px));
  max-width: none;
  color: var(--fg);
}

.share-details::backdrop { background: rgb(12 25 20 / 62%); }
.share-details h2 { margin: 0; }
.share-details h3 { margin: 14px 0 4px; overflow-wrap: anywhere; }
.share-details-url { margin: 0 0 14px; color: var(--muted-fg); font-size: 0.82rem; }
.share-details-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0 0 14px; }
.share-details-grid > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
.share-details dt { color: var(--muted-fg); font-size: 0.8rem; }
.share-details dd { margin: 1px 0 0; font-size: 0.9rem; font-weight: 650; }
.share-details-actions { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 10px; }
.share-details-actions form { display: grid; gap: 4px; }
.share-details-actions select { width: auto; min-width: 88px; padding-inline: 8px; }

.toast {
  position: fixed;
  bottom: 20px;
  inset-inline-start: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  box-shadow: 0 12px 30px oklch(0 0 0 / 50%);
  color: var(--fg);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.88rem;
  z-index: 60;
}

.w-full { width: 100%; }
.w-auto { width: auto; }
.flex-1-min { flex: 1; min-width: 180px; }
.mb-0 { margin-bottom: 0; }
.mb-6 { margin-bottom: 6px; }
.mb-10 { margin-bottom: 10px; }
.mb-12 { margin-bottom: 12px; }
.mb-14 { margin-bottom: 14px; }
.mt-8 { margin-top: 8px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.text-center { text-align: center; }
.break-all { word-break: break-all; }
.text-xs { font-size: 0.78rem; }

.workspace {
  display: grid;
  grid-template-columns: minmax(350px, 0.93fr) minmax(0, 1.75fr);
  align-items: start;
  gap: 20px;
}

.workspace-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 30px;
  border-radius: var(--radius-surface);
  background:
    radial-gradient(circle at 7% 115%, transparent 0 82px, rgb(212 242 214 / 10%) 83px 84px, transparent 85px 109px, rgb(212 242 214 / 8%) 110px 111px, transparent 112px),
    linear-gradient(115deg, #21634f, #123f37 70%);
  color: #f6fbf5;
}

.workspace-header h1, .page-title {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  font-weight: 800;
  line-height: 1.45;
}

.workspace-header .disk-bar {
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid rgb(225 246 229 / 20%);
  border-radius: 12px;
  background: rgb(225 246 229 / 6%);
}

.disk-title {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
}

.workspace-header .disk-text { color: #d7ecdf; }
.workspace-header .progress-wrap { background: rgb(225 246 229 / 19%); }
.workspace-header .progress-bar { background: #a0d9ac; }

.workspace .card { min-width: 0; margin: 0; }
.workspace .card-title { margin-bottom: 16px; font-size: 1.2rem; }
.composer { background: linear-gradient(155deg, var(--composer-glow), var(--card) 42%); }
.composer .tabs { display: flex; }
.composer .tab-btn { flex: 1; justify-content: center; padding-inline: 7px; }
.composer form > .btn-primary { width: 100%; }

.dropzone {
  border-color: var(--drop-border);
  background: var(--accent-well);
  padding-block: 25px;
}

.dropzone:focus-visible, .table-wrap:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 3px;
}

.dropzone-icon { background: var(--accent-surface); }
#dropzoneText { font-weight: 650; overflow-wrap: anywhere; }
.composer .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.composer .advanced-options summary span:first-child { margin-inline-end: 6px; }

.library-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.library-search { grid-column: 1 / -1; }
.library-filters select { padding-inline: 10px; }
.library .table-wrap { border: 1px solid var(--border); border-radius: 12px; }
.library th { background: var(--surface-2); }
.library tr:last-child td { border-bottom: 0; }
.library .empty-cell { padding: 32px 16px; text-align: center; white-space: normal; }
.library .item-title { font-weight: 650; overflow-wrap: anywhere; min-width: 100px; }
.library .item-path { display: block; overflow-wrap: anywhere; font-size: 0.75rem; }

.library-maintenance { margin-top: 12px; font-size: 0.82rem; color: var(--muted-fg); }
.library-maintenance summary { cursor: pointer; width: fit-content; }
.library-maintenance .row { margin-top: 8px; }

.auth-shell {
  min-height: 100svh;
  background:
    radial-gradient(ellipse at 70% 15%, var(--auth-glow), transparent 57%),
    var(--bg);
}

.auth-card { margin: 0; padding: clamp(21px, 5vw, 34px); }
.auth-card .page-title { margin: 12px 0 16px; font-size: 1.65rem; }
.auth-card .tabs { display: flex; }
.auth-card .tabs .tab-btn { flex: 1; justify-content: center; padding-inline: 8px; }
.result-panel { background: var(--accent-well); border: 1px solid var(--accent-border); }
.result-panel .row > :first-child { min-width: 0; }
.result-panel .mono { display: inline-block; color: var(--primary); }

@media (max-width: 1040px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
}

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

@media (max-width: 640px) {
  .card {
    padding: 18px 16px;
    border-radius: 16px;
  }
  .topbar {
    padding: 14px 16px;
    border-radius: 16px;
  }
  .topbar-identity { width: 100%; justify-content: space-between; }
  .workspace { gap: 14px; }
  .workspace-header { flex-direction: column; align-items: stretch; padding: 18px; gap: 10px; }
  .workspace-header .disk-bar { max-width: none; }
  .library-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .library-filters select:last-child { grid-column: 1 / -1; }
  .library table { min-width: 510px; }
  .composer .tab-btn { gap: 5px; font-size: 0.78rem; }
}
