:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --bg3: #273449;
  --accent: #2dd4bf;
  --accent-dim: #14b8a6;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --danger: #f87171;
  --radius: 14px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  padding-inline: 1.5rem;
  margin-inline: auto;
}

a { color: var(--accent); }

/* --- Шапка --- */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(15, 23, 42, .92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--bg3);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: .7rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: .12em;
}

.brand img { border-radius: 9px; }

.nav { display: flex; gap: .35rem; }

.nav a {
  text-decoration: none;
  color: var(--text);
  padding: .5rem .95rem;
  border-radius: 9px;
  transition: background .15s, color .15s;
}

.nav a:hover { background: var(--bg2); color: var(--accent); }

.burger {
  display: none;
  background: none;
  border: 1px solid var(--bg3);
  border-radius: 8px;
  width: 42px;
  height: 38px;
  cursor: pointer;
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.burger span,
.burger span::before,
.burger span::after {
  content: "";
  position: absolute;
  left: 9px;
  width: 22px;
  height: 2px;
  background: var(--text);
  transition: transform .2s;
}

.burger span { top: 18px; }
.burger span::before { left: 0; top: -7px; }
.burger span::after { left: 0; top: 7px; }

/* --- Контент --- */
main { flex: 1; padding-block: 2rem 3rem; }

h1 { font-size: 1.7rem; margin: 0 0 1.3rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.4rem;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: transform .15s, border-color .15s, box-shadow .15s;
}

.card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-dim);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .35);
}

.card-img {
  aspect-ratio: 4 / 3;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

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

.card-body { padding: 1rem 1.15rem 1.2rem; display: flex; flex-direction: column; gap: .45rem; }

.card-body h2 { margin: 0; font-size: 1.15rem; color: var(--accent); }

.card-body .desc { margin: 0; color: var(--muted); font-size: .92rem; line-height: 1.45; }

.card-body .url {
  font-size: .82rem;
  color: var(--muted);
  word-break: break-all;
  margin-top: auto;
  padding-top: .4rem;
}

.card:hover .url { color: var(--text); }

.empty { color: var(--muted); }

/* --- Подвал --- */
.footer {
  border-top: 1px solid var(--bg3);
  background: #0b1120;
  padding-block: 1rem;
  font-size: .9rem;
  color: var(--muted);
}

.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--accent); }

/* --- Вход --- */
.login-wrap { display: flex; align-items: center; justify-content: center; padding-block: 4rem; }

.login-box {
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: var(--radius);
  padding: 2rem;
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: center;
}

.login-box img { margin-inline: auto; border-radius: 12px; }
.login-box h1 { font-size: 1.3rem; margin: 0; }
.login-box label { text-align: left; }
.back-link { font-size: .9rem; text-decoration: none; }

/* --- Админка --- */
.admin .hint { color: var(--muted); margin-top: -.7rem; font-size: .92rem; }
.handle-demo { color: var(--accent); }

.panel {
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: var(--radius);
  padding: 1.3rem 1.4rem;
  margin-bottom: 1.6rem;
}

.panel h2 { margin: 0 0 1rem; font-size: 1.15rem; color: var(--accent); }

label {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  font-size: .88rem;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="file"] {
  background: var(--bg);
  border: 1px solid var(--bg3);
  border-radius: 9px;
  color: var(--text);
  padding: .6rem .75rem;
  font-size: .95rem;
  font-family: inherit;
  width: 100%;
}

input:focus { outline: 2px solid var(--accent-dim); outline-offset: -1px; }

.pass-field { position: relative; display: flex; align-items: center; }
.pass-field input { padding-right: 2.9rem; }

.eye {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 5px;
  display: flex;
  border-radius: 7px;
  transition: color .15s;
}

.eye:hover, .eye.on { color: var(--accent); }
.eye svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.remember {
  flex-direction: row;
  align-items: center;
  gap: .55rem;
  color: var(--text);
  font-size: .92rem;
  cursor: pointer;
}

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

input[type="file"] { padding: .45rem; font-size: .85rem; }
input[type="file"]::file-selector-button {
  background: var(--bg3);
  color: var(--text);
  border: none;
  border-radius: 7px;
  padding: .4rem .8rem;
  margin-right: .7rem;
  cursor: pointer;
}

/* Safari до поддержки ::file-selector-button */
input[type="file"]::-webkit-file-upload-button {
  background: var(--bg3);
  color: var(--text);
  border: none;
  border-radius: 7px;
  padding: .4rem .8rem;
  margin-right: .7rem;
  cursor: pointer;
}

.btn {
  background: var(--accent);
  color: #06281f;
  font-weight: 600;
  border: none;
  border-radius: 9px;
  padding: .65rem 1.3rem;
  font-size: .95rem;
  cursor: pointer;
  transition: background .15s;
}

.btn:hover { background: var(--accent-dim); }
.btn:disabled { opacity: .5; cursor: wait; }
.btn.small { padding: .4rem .7rem; font-size: .85rem; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn.danger:hover { background: rgba(248, 113, 113, .12); }

.alert {
  background: rgba(45, 212, 191, .12);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  border-radius: 9px;
  padding: .7rem 1rem;
  margin: 0 0 1rem;
  font-size: .92rem;
}

.alert.error { background: rgba(248, 113, 113, .1); border-color: var(--danger); color: var(--danger); }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .9rem;
  margin-bottom: 1rem;
}

.form-grid .wide { grid-column: 1 / -1; }

.add-form .btn { width: auto; }

.p-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .9rem; }

.p-item {
  display: grid;
  grid-template-columns: auto 92px 1fr auto;
  gap: 1rem;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--bg3);
  border-radius: var(--radius);
  padding: .9rem 1rem;
}

.p-item.dragging { opacity: .5; border-color: var(--accent); }

.handle { cursor: grab; color: var(--muted); font-size: 1.3rem; user-select: none; padding-inline: .2rem; }
.handle:active { cursor: grabbing; }

.thumb {
  width: 92px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 9px;
  border: 1px solid var(--bg3);
  background: var(--bg3);
}

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.fields label:nth-child(3), .fields label:nth-child(4) { grid-column: span 1; }

.actions { display: flex; flex-direction: column; gap: .45rem; }

.pass-form {
  display: flex;
  gap: .9rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.pass-form label { flex: 1; min-width: 200px; }

/* --- Мобильные --- */
@media (max-width: 720px) {
  .burger { display: block; }

  .nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg2);
    border-bottom: 1px solid var(--bg3);
    flex-direction: column;
    padding: .6rem 1rem 1rem;
    display: none;
  }

  body.nav-open .nav { display: flex; }

  .form-grid { grid-template-columns: 1fr; }

  .p-item {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "handle thumb"
      "fields fields"
      "actions actions";
    gap: .8rem;
  }

  .p-item .handle { grid-area: handle; }
  .p-item .thumb { grid-area: thumb; width: 72px; justify-self: end; }
  .p-item .fields { grid-area: fields; grid-template-columns: 1fr; }
  .p-item .actions { grid-area: actions; flex-direction: row; flex-wrap: wrap; }
  .p-item .actions .btn { flex: 1; }
}

@media (max-width: 420px) {
  .grid { grid-template-columns: 1fr; }
  h1 { font-size: 1.4rem; }
}
