:root {
  --ink: #171a18;
  --ink-soft: #5f665f;
  --paper: #f4f1ea;
  --paper-deep: #e7e3d9;
  --card: #fbfaf6;
  --line: #d8d4ca;
  --accent: #d5ff3f;
  --accent-ink: #263000;
  --danger: #a6302f;
  --sidebar: #151816;
  --sidebar-soft: #aab1aa;
  --shadow: 0 18px 45px rgb(27 34 29 / 10%);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 70%, #000);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  transform: translateY(-150%);
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 28px 20px 20px;
  background:
    radial-gradient(circle at 20% 0%, rgb(213 255 63 / 10%), transparent 33%),
    var(--sidebar);
  color: white;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 30px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 17px;
  font-weight: 900;
  letter-spacing: -0.05em;
  transform: rotate(-3deg);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 18px;
  letter-spacing: -0.02em;
}

.brand small {
  margin-top: 2px;
  color: var(--sidebar-soft);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.side-nav {
  display: grid;
  gap: 7px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--sidebar-soft);
  text-align: left;
  font-weight: 650;
}

.nav-item:hover,
.nav-item.is-active {
  background: rgb(255 255 255 / 8%);
  color: white;
}

.nav-item.is-active {
  box-shadow: inset 3px 0 var(--accent);
}

.nav-icon {
  width: 21px;
  color: var(--accent);
  font-size: 18px;
  text-align: center;
}

.sidebar-spacer {
  flex: 1;
}

.storage-card {
  display: grid;
  gap: 4px;
  padding: 15px;
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 14px;
  background: rgb(255 255 255 / 5%);
}

.storage-card__top {
  display: flex;
  justify-content: space-between;
  color: var(--sidebar-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.storage-card strong {
  margin-top: 7px;
  font-size: 14px;
}

.storage-card small {
  color: var(--sidebar-soft);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #7c837d;
  box-shadow: 0 0 0 4px rgb(255 255 255 / 5%);
}

.status-dot.is-online {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgb(213 255 63 / 12%);
}

.text-button {
  justify-self: start;
  margin: 10px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
}

.main-panel {
  min-width: 0;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px clamp(20px, 4vw, 54px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  background: rgb(244 241 234 / 88%);
  backdrop-filter: blur(16px);
}

.search-box {
  width: min(520px, 48vw);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink-soft);
}

.search-box input {
  min-width: 0;
  flex: 1;
  padding: 12px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.search-box kbd {
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 10px;
}

.top-actions {
  display: flex;
  gap: 9px;
  margin-left: auto;
}

.button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 750;
}

.button {
  padding: 10px 15px;
}

.button--primary {
  background: var(--ink);
  color: white;
  box-shadow: 0 5px 15px rgb(23 26 24 / 14%);
}

.button--primary:hover {
  background: #000;
}

.button--quiet {
  border-color: var(--line);
  background: var(--card);
  color: var(--ink);
}

.button--quiet:hover {
  border-color: #a8ada7;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  background: transparent;
  color: var(--ink-soft);
  font-size: 19px;
}

.icon-button:hover,
.icon-button.is-active {
  background: var(--ink);
  color: white;
}

.mobile-menu {
  display: none;
}

.content {
  padding: 22px clamp(20px, 4vw, 54px) 60px;
}

.breadcrumbs {
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  color: var(--ink-soft);
  font-size: 13px;
  white-space: nowrap;
}

.breadcrumbs button {
  padding: 3px 5px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: inherit;
}

.breadcrumbs button:hover {
  background: var(--paper-deep);
  color: var(--ink);
}

.breadcrumb-separator {
  color: #a8ada7;
}

.hero-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 0 28px;
}

.eyebrow {
  margin: 0 0 7px;
  color: #606a0d;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(36px, 5vw, 62px);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.subtitle {
  max-width: 560px;
  margin-bottom: 0;
  color: var(--ink-soft);
}

.view-controls {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

.view-controls .icon-button {
  width: 34px;
  height: 32px;
  border-radius: 7px;
  font-size: 17px;
}

.selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 22px;
  padding: 12px 14px;
  border: 1px solid #becb8a;
  border-radius: 12px;
  background: #eff5d5;
}

.selection-bar[hidden] {
  display: none;
}

.selection-bar > div {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.selection-bar button {
  padding: 5px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.selection-bar button:hover {
  background: rgb(255 255 255 / 60%);
}

.selection-bar .danger-link {
  color: var(--danger);
}

.recent-strip {
  margin-bottom: 30px;
}

.recent-strip[hidden] {
  display: none;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 13px;
}

.section-heading h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.section-heading span {
  color: var(--ink-soft);
  font-size: 12px;
}

.recent-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.recent-item {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  color: var(--ink);
  text-align: left;
}

.recent-item:hover {
  border-color: #a7ad9f;
  transform: translateY(-1px);
}

.recent-thumb {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--paper-deep);
  object-fit: cover;
}

.recent-item span {
  min-width: 0;
}

.recent-item strong,
.recent-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-item strong {
  font-size: 12px;
}

.recent-item small {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 10px;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
}

.media-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--card);
  box-shadow: 0 1px 0 rgb(255 255 255 / 70%) inset;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.media-card:hover {
  transform: translateY(-2px);
  border-color: #a7ad9f;
  box-shadow: var(--shadow);
}

.media-card.is-selected {
  border-color: #869300;
  box-shadow: 0 0 0 3px rgb(213 255 63 / 45%);
}

.media-card__select {
  position: absolute;
  z-index: 4;
  top: 10px;
  left: 10px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid rgb(23 26 24 / 24%);
  border-radius: 7px;
  background: rgb(255 255 255 / 90%);
  color: transparent;
  font-size: 14px;
  font-weight: 900;
  opacity: 0;
}

.media-card:hover .media-card__select,
.media-card.is-selected .media-card__select,
.media-card__select:focus-visible {
  opacity: 1;
}

.media-card.is-selected .media-card__select {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--accent);
}

.media-card__preview {
  position: relative;
  height: 145px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgb(255 255 255 / 35%), transparent),
    var(--paper-deep);
}

.media-card__preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-glyph {
  width: 62px;
  height: 76px;
  display: grid;
  place-items: end center;
  padding-bottom: 12px;
  border: 1px solid #c5c0b5;
  border-radius: 7px;
  background: #f7f5ef;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  box-shadow: 5px 7px 0 rgb(23 26 24 / 6%);
}

.folder-preview {
  width: calc(100% - 26px);
  height: calc(100% - 28px);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  grid-template-rows: 1fr 1fr;
  gap: 4px;
  overflow: hidden;
  border: 5px solid #dad6cb;
  border-top-width: 12px;
  border-radius: 8px;
  background: #d2cec3;
  box-shadow: 0 8px 18px rgb(23 26 24 / 10%);
}

.folder-preview::before {
  content: "";
  position: absolute;
  top: 20px;
  left: 30px;
  width: 58px;
  height: 13px;
  border-radius: 5px 5px 0 0;
  background: #dad6cb;
}

.folder-preview img {
  min-width: 0;
  min-height: 0;
  background: #beb9ad;
}

.folder-preview img:first-child {
  grid-row: 1 / 3;
}

.folder-preview.is-empty {
  grid-template-columns: 1fr;
}

.folder-preview.is-empty::after {
  content: "EMPTY";
  place-self: center;
  color: #8c877c;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.15em;
}

.media-card__body {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px;
}

.media-card__meta {
  min-width: 0;
  flex: 1;
}

.media-card__meta strong,
.media-card__meta small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-card__meta strong {
  font-size: 13px;
}

.media-card__meta small {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 10px;
}

.card-menu {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 18px;
}

.card-menu:hover {
  background: var(--paper-deep);
  color: var(--ink);
}

.media-grid.is-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
}

.media-grid.is-list .media-card {
  min-height: 64px;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  border-radius: 10px;
}

.media-grid.is-list .media-card__preview {
  height: 64px;
  border-right: 1px solid var(--line);
  border-bottom: 0;
}

.media-grid.is-list .file-glyph {
  width: 30px;
  height: 38px;
  padding-bottom: 5px;
  font-size: 7px;
  box-shadow: none;
}

.media-grid.is-list .folder-preview {
  width: 47px;
  height: 35px;
  border-width: 3px;
  border-top-width: 7px;
  gap: 1px;
}

.media-grid.is-list .folder-preview::before {
  top: 12px;
  left: 18px;
  width: 24px;
  height: 7px;
}

.loading-state,
.empty-state {
  min-height: 270px;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  color: var(--ink-soft);
}

.loading-state[hidden],
.empty-state[hidden] {
  display: none;
}

.spinner {
  width: 28px;
  height: 28px;
  margin-bottom: 10px;
  border: 3px solid var(--paper-deep);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-icon {
  width: 62px;
  height: 50px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  border: 2px solid #bbb6aa;
  border-radius: 8px;
  color: #8d897f;
  font-size: 22px;
}

.empty-state h2 {
  margin-bottom: 6px;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 25px;
  font-weight: 500;
}

.empty-state p {
  margin-bottom: 18px;
}

.drop-overlay {
  position: fixed;
  z-index: 70;
  inset: 16px;
  display: grid;
  place-items: center;
  border: 3px dashed var(--accent);
  border-radius: 22px;
  background: rgb(21 24 22 / 90%);
  color: white;
  backdrop-filter: blur(8px);
}

.drop-overlay[hidden] {
  display: none;
}

.drop-overlay > div {
  text-align: center;
}

.drop-overlay strong,
.drop-overlay span {
  display: block;
}

.drop-overlay strong {
  margin-bottom: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(32px, 6vw, 66px);
  font-weight: 500;
}

.drop-overlay span {
  color: var(--accent);
}

.dialog {
  width: min(470px, calc(100vw - 30px));
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 30px 80px rgb(0 0 0 / 35%);
}

.dialog::backdrop {
  background: rgb(13 16 14 / 72%);
  backdrop-filter: blur(5px);
}

.dialog form {
  position: relative;
  padding: 30px;
}

.dialog h2 {
  margin-bottom: 9px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
  font-weight: 500;
}

.dialog p {
  color: var(--ink-soft);
  line-height: 1.55;
}

.dialog label {
  display: grid;
  gap: 7px;
  margin-top: 22px;
  font-size: 12px;
  font-weight: 800;
}

.dialog input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
}

.dialog-close {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: var(--paper-deep);
  color: var(--ink);
  font-size: 20px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}

.form-error {
  min-height: 18px;
  margin: 7px 0 0;
  color: var(--danger) !important;
  font-size: 12px;
}

.toast-region {
  position: fixed;
  z-index: 90;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: min(390px, calc(100vw - 40px));
  padding: 12px 15px;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 10px;
  background: #151816;
  color: white;
  box-shadow: 0 15px 40px rgb(0 0 0 / 25%);
  font-size: 13px;
  animation: toast-in 180ms ease-out;
}

.toast.is-error {
  background: #722523;
}

@keyframes toast-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    z-index: 60;
    inset: 0 auto 0 0;
    width: min(280px, 86vw);
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: 18px 0 60px rgb(0 0 0 / 28%);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .mobile-menu {
    display: inline-grid;
    flex: 0 0 auto;
  }

  .recent-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .topbar {
    gap: 8px;
    min-height: 66px;
    padding-inline: 12px;
  }

  .search-box {
    width: auto;
    flex: 1;
  }

  .search-box kbd,
  .top-actions .button--quiet {
    display: none;
  }

  .top-actions {
    margin-left: 0;
  }

  .top-actions .button {
    padding: 10px 12px;
  }

  .content {
    padding-inline: 15px;
  }

  .hero-row {
    align-items: flex-start;
  }

  .subtitle {
    font-size: 13px;
  }

  .recent-list {
    grid-template-columns: 1fr;
  }

  .media-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .media-card__preview {
    height: 118px;
  }

  .selection-bar {
    align-items: flex-start;
    flex-direction: column;
  }
}

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

  .media-card__preview {
    height: 155px;
  }
}

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