:root {
  color-scheme: dark;
  --bg: #080807;
  --surface: rgba(22, 23, 21, 0.64);
  --surface-strong: rgba(32, 34, 31, 0.82);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f4f1e8;
  --muted: #aaa79d;
  --soft: #76736c;
  --teal: #42d7c1;
  --amber: #e3b75d;
  --rose: #ef7f9b;
  --green: #90d26d;
  --danger: #ff6c6c;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.46);
}

* {
  box-sizing: border-box;
  touch-action: pan-y;
}

html {
  min-height: 100%;
  background:
    linear-gradient(130deg, rgba(66, 215, 193, 0.13), transparent 26%),
    linear-gradient(310deg, rgba(227, 183, 93, 0.11), transparent 28%),
    linear-gradient(180deg, #090907 0%, #10100e 46%, #070706 100%);
  overscroll-behavior-x: none;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  overscroll-behavior-x: none;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 4vw, 58px);
  line-height: 1;
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hidden {
  display: none !important;
}

.icon-button,
.primary-button,
.copy-button,
.folder-toggle-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.icon-button:hover,
.primary-button:hover,
.copy-button:hover,
.folder-toggle-button:hover {
  border-color: rgba(66, 215, 193, 0.55);
  background: rgba(66, 215, 193, 0.14);
}

.icon-button:active,
.primary-button:active,
.copy-button:active,
.folder-toggle-button:active {
  transform: translateY(1px);
}

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  font-size: 22px;
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.icon-button.active {
  border-color: rgba(227, 183, 93, 0.58);
  background: rgba(227, 183, 93, 0.14);
}

.toolbar,
.stats article,
.lightbox,
.empty,
.archive-card {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  padding: 14px;
  border-radius: 8px;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  outline: none;
  padding: 0 12px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.28);
}

.field textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.45;
  padding: 12px;
}

.field input:focus,
.field textarea:focus {
  border-color: rgba(66, 215, 193, 0.76);
  box-shadow: 0 0 0 3px rgba(66, 215, 193, 0.12);
}

.primary-button {
  width: 100%;
  min-height: 52px;
  border-radius: 8px;
  padding: 0 20px;
  font-weight: 800;
  background: linear-gradient(135deg, rgba(66, 215, 193, 0.24), rgba(227, 183, 93, 0.18));
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 0 0 18px;
}

.stats article {
  min-height: 92px;
  border-radius: 8px;
  padding: 18px;
}

.stats span,
.box-meta,
.link-time,
.empty p {
  color: var(--muted);
}

.stats span {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
}

.stats strong {
  font-size: 34px;
  line-height: 1;
}

.lightboxes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 16px;
}

.archive-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.archive-card {
  display: grid;
  min-height: 210px;
  gap: 14px;
  align-content: start;
  border-radius: 8px;
  padding: 18px;
  color: var(--text);
  text-align: left;
}

.archive-card:hover {
  border-color: rgba(66, 215, 193, 0.55);
  background: rgba(66, 215, 193, 0.11);
}

.archive-card-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.archive-card-title strong {
  font-size: 20px;
}

.archive-card-title span,
.archive-card-time {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.archive-preview {
  display: grid;
  gap: 8px;
}

.archive-preview p {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox {
  display: flex;
  min-width: 0;
  min-height: 330px;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
}

.lightbox.is-collapsed {
  min-height: 0;
}

.lightbox.is-collapsed .links {
  display: none;
}

.box-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.box-title {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.box-title h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.box-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--green);
}

.status-dot.full {
  background: var(--amber);
}

.copy-button {
  min-width: 92px;
  min-height: 36px;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 8px;
}

.folder-toggle-button {
  display: grid;
  width: 40px;
  min-width: 40px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  padding: 0;
}

.folder-toggle-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.65;
}

.folder-toggle-button .folder-chevron {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 160ms ease;
}

.folder-toggle-button.is-collapsed .folder-chevron {
  transform: rotate(-90deg);
}

.archive-action {
  min-width: 68px;
  color: var(--amber);
}

.progress {
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
}

.progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--amber));
}

.links {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.link-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  outline: none;
}

.link-row:last-child {
  border-bottom: 0;
}

.copyable-content {
  cursor: copy;
  outline: none;
  transition: background 160ms ease;
}

.copyable-content:hover,
.copyable-content:focus-visible {
  background: rgba(66, 215, 193, 0.09);
}

.copyable-content:focus-visible {
  box-shadow: inset 0 0 0 2px rgba(66, 215, 193, 0.36);
}

.link-controls {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 7px;
}

.link-index {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  color: var(--amber);
  background: rgba(0, 0, 0, 0.22);
  font-size: 12px;
  font-weight: 800;
}

.delete-item-button {
  display: grid;
  width: 30px;
  min-width: 30px;
  height: 28px;
  place-items: center;
  border: 1px solid rgba(255, 108, 108, 0.26);
  border-radius: 8px;
  color: #ffb4b4;
  background: rgba(255, 108, 108, 0.1);
  padding: 0;
}

.delete-item-button:hover,
.delete-item-button:focus-visible {
  border-color: rgba(255, 108, 108, 0.58);
  background: rgba(255, 108, 108, 0.18);
  outline: none;
}

.delete-item-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.link-content {
  display: grid;
  min-width: 0;
  gap: 4px;
  border-radius: 8px;
  padding: 2px 4px;
}

.item-text {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  display: -webkit-box;
  max-height: 4.4em;
  line-height: 1.45;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.link-time {
  font-size: 12px;
}

.empty {
  grid-column: 1 / -1;
  min-height: 240px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  text-align: center;
}

.empty h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.empty p {
  margin: 0;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(380px, calc(100% - 40px));
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-color: rgba(255, 108, 108, 0.48);
  color: #ffdede;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 22px, 1180px);
    padding-top: 22px;
  }

  .topbar {
    align-items: start;
  }

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

  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .stats article {
    min-height: 76px;
    padding: 12px 10px;
  }

  .stats span {
    margin-bottom: 7px;
    font-size: 12px;
  }

  .stats strong {
    font-size: 24px;
  }

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

  .box-header {
    align-items: stretch;
    flex-direction: column;
  }

  .card-actions {
    justify-content: flex-start;
  }
}
