/* ── Inter font (self-hosted) ── */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #242736;
  --border:    #2e3248;
  --accent:    #6c63ff;
  --accent-h:  #5a52e0;
  --green:     #22c55e;
  --red:       #ef4444;
  --yellow:    #f59e0b;
  --text:      #e2e8f0;
  --muted:     #8892a4;
  --radius:    12px;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
}

html { font-size: 16px; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 0 20px 24px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.sidebar-logo .logo-icon { font-size: 1.5rem; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--muted);
  font-size: .93rem;
  border-radius: 0;
  transition: background .15s, color .15s;
}
.nav-item:hover, .nav-item.active {
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
}
.nav-item.active { border-left: 3px solid var(--accent); }
.nav-item .nav-icon { width: 20px; text-align: center; font-size: 1.1rem; }

.sidebar-bottom {
  margin-top: auto;
  padding: 16px 20px 0;
  border-top: 1px solid var(--border);
}
.user-info { font-size: .85rem; color: var(--muted); padding: 8px 0; }
.user-info strong { color: var(--text); display: block; }

.main-content {
  flex: 1;
  padding: 32px 40px;
  max-width: 960px;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 16px;
  font-size: .8rem;
}
.card h2 { font-size: 1.4rem; margin-bottom: 8px; }

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label { font-size: .8rem; color: var(--muted); }
.stat-paid   .stat-value { color: var(--green); }
.stat-free   .stat-value { color: var(--accent); }
.stat-total  .stat-value { color: var(--text); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: .93rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); text-decoration: none; color: var(--text); }
.btn-success { background: var(--green); color: #fff; }
.btn-danger  { background: var(--red);   color: #fff; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-sm { padding: 6px 14px; font-size: .83rem; }
.btn-block { display: flex; width: 100%; justify-content: center; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .87rem; color: var(--muted); margin-bottom: 6px; }
.form-control {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color .15s;
}
.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-error { color: var(--red); font-size: .83rem; margin-top: 4px; }
.form-hint  { color: var(--muted); font-size: .82rem; margin-top: 4px; }

/* file input */
.file-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
}
.file-drop:hover, .file-drop.dragover {
  border-color: var(--accent);
  background: rgba(108,99,255,.06);
}
.file-drop input[type=file] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}
.file-drop-icon { font-size: 2.5rem; margin-bottom: 8px; }
.file-drop-text { color: var(--muted); font-size: .9rem; }
.file-drop-text strong { color: var(--accent); }

/* ── Auth pages ── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  box-shadow: var(--shadow);
}
.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}
.auth-logo .icon { font-size: 3rem; margin-bottom: 8px; }
.auth-logo h1 { font-size: 1.4rem; font-weight: 700; }
.auth-logo p  { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.auth-divider {
  text-align: center;
  color: var(--muted);
  font-size: .83rem;
  margin: 20px 0;
  position: relative;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after  { right: 0; }
.auth-footer { text-align: center; margin-top: 20px; color: var(--muted); font-size: .87rem; }

/* code input */
.code-input {
  font-size: 2rem !important;
  font-weight: 700;
  letter-spacing: .3em;
  text-align: center;
  padding: 16px !important;
}

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: .9rem;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-success { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.3); color: #86efac; }
.alert-error   { background: rgba(239,68,68,.12);  border: 1px solid rgba(239,68,68,.3);  color: #fca5a5; }
.alert-info    { background: rgba(108,99,255,.12); border: 1px solid rgba(108,99,255,.3); color: #a5b4fc; }
.alert-warning { background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.3); color: #fcd34d; }

/* ── Packages ── */
.packages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.package-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  transition: border-color .2s;
  position: relative;
}
.package-card:hover { border-color: var(--accent); }
.package-card.featured { border-color: var(--accent); }
.package-badge {
  position: absolute;
  top: -10px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff;
  font-size: .7rem; font-weight: 700;
  padding: 2px 10px; border-radius: 20px;
  white-space: nowrap;
}
.package-limits { font-size: 2rem; font-weight: 700; color: var(--green); }
.package-name   { color: var(--muted); font-size: .85rem; margin-bottom: 12px; }
.package-price  { font-size: 1.3rem; font-weight: 600; margin-bottom: 16px; }

/* ── Deleted image placeholder (grid thumb) ── */
.thumb-deleted {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 5px;
  background: var(--surface);
  color: var(--muted);
  padding: 12px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.thumb-deleted::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    -45deg,
    transparent 0px, transparent 7px,
    rgba(255,255,255,.025) 7px, rgba(255,255,255,.025) 14px
  );
  pointer-events: none;
}
.thumb-deleted svg {
  width: 34px; height: 34px;
  opacity: .3;
  flex-shrink: 0;
  position: relative; z-index: 1;
}
.thumb-deleted-date {
  font-size: .68rem;
  font-family: 'Courier New', monospace;
  color: var(--muted);
  opacity: .75;
  letter-spacing: .02em;
  position: relative; z-index: 1;
  line-height: 1.3;
}
.thumb-deleted-label {
  font-size: .6rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  opacity: .45;
  position: relative; z-index: 1;
}
.thumb-deleted-limit {
  font-size: .62rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  position: relative; z-index: 1;
}
.thumb-deleted-limit--paid { color: var(--green); background: rgba(34,197,94,.12); }
.thumb-deleted-limit--free { color: var(--accent); background: rgba(108,99,255,.12); }

/* ── Deleted image placeholder (result full page) ── */
.result-deleted {
  text-align: center;
  padding: 56px 24px;
  display: flex; flex-direction: column;
  align-items: center; gap: 10px;
}
.result-deleted svg {
  width: 64px; height: 64px;
  color: var(--muted);
  opacity: .3;
  margin-bottom: 8px;
}
.result-deleted-title {
  font-size: 1.05rem; font-weight: 600;
  color: var(--text);
}
.result-deleted-date {
  font-family: 'Courier New', monospace;
  font-size: .85rem; color: var(--muted);
}
.result-deleted-hint {
  font-size: .82rem; color: var(--muted);
  opacity: .65; max-width: 320px; line-height: 1.5;
  margin-top: 4px;
}

/* ── History ── */
.session-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.session-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .2s;
}
.session-card:hover { border-color: var(--accent); }
.session-thumb {
  width: 100%; aspect-ratio: 1/1;
  background: var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 2rem;
  overflow: hidden;
}
.session-thumb img { width: 100%; height: 100%; object-fit: cover; }
.session-meta { padding: 12px; font-size: .82rem; color: var(--muted); }
.session-meta strong { color: var(--text); display: block; margin-bottom: 4px; }

/* ── Result image ── */
.result-wrap { text-align: center; }
.result-wrap img {
  max-width: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.result-wrap img.img-loading { opacity: 0; }
.result-wrap img.img-ready   { opacity: 1; transition: opacity .3s ease; }

.img-skeleton {
  width: 100%;
  max-width: 640px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite;
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Quality selector ── */
.quality-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}
.quality-option { display: none; }
.quality-label {
  display: block;
  text-align: center;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: .87rem;
  transition: border-color .15s, background .15s;
}
.quality-option:checked + .quality-label {
  border-color: var(--accent);
  background: rgba(108,99,255,.1);
  color: var(--accent);
}

/* ── Page header ── */
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 1.6rem; font-weight: 700; }
.page-header p   { color: var(--muted); margin-top: 4px; }

/* ── Мобильные элементы скрыты на десктопе ── */
.mob-bar           { display: none; }
.mob-overlay       { display: none; }
.sidebar-close-btn { display: none; }

/* ── Responsive ── */
@media (max-width: 768px) {

  /* Компенсация высоты фиксированной шапки */
  body { padding-top: 54px; }

  /* Фиксированная шапка */
  .mob-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 200;
    height: 54px;
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }
  .mob-bar__logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
  }
  .mob-bar__icon { font-size: 1.3rem; }

  /* Гамбургер */
  .mob-bar__btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 8px;
    background: none;
    border: none;
    cursor: pointer;
  }
  .mob-bar__btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
  }

  /* Затемнение */
  .mob-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 299;
    display: none;
  }
  .mob-overlay.mob-open { display: block; }

  /* Sidebar → полноэкранное меню */
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100vh;
    z-index: 300;
    flex-direction: column;
    flex-wrap: nowrap;
    padding: 20px 0;
    border-right: none;
    border-bottom: none;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .sidebar.mob-open { transform: translateX(0); }

  /* Кнопка × */
  .sidebar-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 12px; right: 14px;
    width: 34px; height: 34px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
    line-height: 1;
  }
  .sidebar-close-btn:hover { color: var(--text); }

  /* Пункты меню */
  .sidebar-logo {
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
    font-size: 1.2rem;
  }
  .nav-item { padding: 14px 20px; font-size: 1rem; }
  .nav-item.active { border-left: 3px solid var(--accent); border-bottom: none; }
  .sidebar-bottom { display: flex; flex-direction: column; }

  /* Основной контент */
  .layout { flex-direction: column; }
  .main-content { padding: 20px 16px; }
  .stats-grid    { grid-template-columns: repeat(2, 1fr); }
  .packages-grid { grid-template-columns: repeat(2, 1fr); }
  .quality-grid  { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats-grid    { grid-template-columns: 1fr; }
  .packages-grid { grid-template-columns: 1fr; }
}