:root {
  --background: #f5f7fc;
  --foreground: #111827;
  --card: hsl(0 0% 100%);
  --primary: #061a49;
  --primary-foreground: #ffffff;
  --secondary: hsl(210 20% 93%);
  --muted: hsl(210 20% 95%);
  --muted-foreground: #68738a;
  --accent: #1645b7;
  --accent-soft: #e8eefc;
  --destructive: hsl(0 70% 45%);
  --destructive-soft: hsl(0 93% 94%);
  --success: hsl(143 64% 24%);
  --success-soft: hsl(141 84% 93%);
  --border: #dce1e9;
  --input: hsl(214 20% 82%);
  --sidebar-accent: #e8eefc;
  --radius: 0.5rem;
  --shadow: 0 1px 2px hsl(205 45% 10% / 0.04), 0 8px 24px -10px hsl(205 45% 10% / 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--foreground);
  background: var(--background);
}

* { box-sizing: border-box; }

body { margin: 0; min-height: 100vh; font-size: 14px; }

[hidden] { display: none !important; }

button, input, select { font: inherit; color: inherit; }

h1, h2, h3, p { margin: 0; }

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

.icon { width: 16px; height: 16px; flex-shrink: 0; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}

.button:disabled { opacity: .6; cursor: default; }
.button.block { width: 100%; }
.button.primary { background: var(--primary); color: var(--primary-foreground); }
.button.primary:hover:not(:disabled) { background: hsl(205 82% 26%); }
.button.outline { border-color: var(--border); background: var(--card); }
.button.outline:hover { background: var(--muted); }
.button.ghost:hover { background: var(--muted); }
.button.danger { border-color: var(--destructive-soft); background: var(--destructive-soft); color: var(--destructive); }
.button.danger:hover { border-color: var(--destructive); }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
}

.icon-button:hover { background: var(--muted); }

input[type="password"], input[type="text"], input[type="search"], select {
  height: 36px;
  border: 1px solid var(--input);
  border-radius: var(--radius);
  background: var(--card);
  padding: 0 12px;
  outline: none;
}

input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px hsl(205 82% 20% / .12); }

.login {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background: radial-gradient(circle at 20% 0%, hsl(207 70% 92%), transparent 45%), radial-gradient(circle at 100% 100%, var(--accent-soft), transparent 40%), var(--background);
}

.login-card {
  display: grid;
  gap: 16px;
  width: 100%;
  max-width: 380px;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.login-logo { height: 48px; width: auto; justify-self: start; }
.login-card h1 { font-size: 22px; }

.field { display: grid; gap: 6px; font-weight: 500; }
.input-wrap { position: relative; }
.input-wrap input { width: 100%; padding-right: 44px; }
.input-wrap .icon-button { position: absolute; top: 3px; right: 3px; width: 30px; height: 30px; border: 0; }

.form-error {
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--destructive-soft);
  color: var(--destructive);
}

.shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) auto;
  grid-template-rows: 60px minmax(0, 1fr);
  grid-template-areas: "top top top" "side main preview";
  height: 100vh;
}

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 700; }
.brand img { height: 32px; }
.brand span { padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; }

.search { position: relative; display: flex; align-items: center; flex: 1; max-width: 420px; margin-left: auto; }
.search > span { position: absolute; left: 12px; color: var(--muted-foreground); display: flex; }
.search input { width: 100%; padding-left: 36px; }

.sidebar {
  grid-area: side;
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 16px 12px;
  border-right: 1px solid var(--border);
  background: var(--card);
}

.sidebar-title { padding: 0 10px 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-foreground); }

.root-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: hsl(210 20% 30%);
  text-decoration: none;
  font-weight: 500;
}

.root-link:hover { background: var(--muted); }
.root-link.active { background: var(--sidebar-accent); color: var(--primary); }
.root-link small { margin-left: auto; color: var(--muted-foreground); font-weight: 400; }

.main { grid-area: main; position: relative; display: flex; flex-direction: column; min-height: 0; padding: 20px 24px; overflow: auto; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.actions { display: flex; align-items: center; gap: 8px; }
.segmented { display: flex; }
.segmented .icon-button:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.segmented .icon-button:last-child { border-radius: 0 var(--radius) var(--radius) 0; border-left: 0; }
.segmented .icon-button.active { background: var(--secondary); }

.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 16px; font-weight: 600; }
.breadcrumb a { padding: 4px 6px; border-radius: 6px; color: var(--muted-foreground); text-decoration: none; }
.breadcrumb a:hover { background: var(--muted); color: var(--foreground); }
.breadcrumb a:last-child { color: var(--foreground); }
.breadcrumb .separator { color: var(--input); }

.stats { margin: 12px 0 16px; }

.content.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }

.card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  padding: 0;
  transition: border-color .15s, box-shadow .15s;
}

.card:hover { border-color: hsl(205 40% 70%); box-shadow: var(--shadow); }
.card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px hsl(205 82% 20% / .15); }

.thumb { display: grid; place-items: center; aspect-ratio: 4 / 3; background: var(--muted); color: var(--muted-foreground); overflow: hidden; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb .icon { width: 36px; height: 36px; }
.thumb.folder { color: hsl(207 60% 45%); background: hsl(207 70% 96%); }
.thumb.pdf { color: var(--destructive); background: var(--destructive-soft); }

.card-body { display: grid; gap: 2px; padding: 10px 12px; min-width: 0; }
.card-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.card-meta { font-size: 12px; color: var(--muted-foreground); }

.content.list { border: 1px solid var(--border); border-radius: 12px; background: var(--card); overflow: hidden; }

.row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 110px 150px;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 14px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.row:last-child { border-bottom: 0; }
.row:hover { background: var(--muted); }
.row.selected { background: var(--sidebar-accent); }
.row.head { cursor: default; background: var(--muted); font-size: 12px; font-weight: 600; color: var(--muted-foreground); }
.row .thumb { width: 40px; height: 32px; aspect-ratio: auto; border-radius: 6px; }
.row .thumb .icon { width: 18px; height: 18px; }
.row .card-name { font-weight: 500; }
.row .cell { font-size: 13px; color: var(--muted-foreground); }

.empty { display: grid; place-items: center; gap: 8px; padding: 64px 16px; border: 1px dashed var(--input); border-radius: 12px; text-align: center; color: var(--muted-foreground); }
.empty .icon { width: 32px; height: 32px; }

.dropzone {
  position: absolute;
  inset: 12px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  border: 2px dashed var(--primary);
  border-radius: 16px;
  background: hsl(207 70% 96% / .92);
  font-weight: 600;
  pointer-events: none;
}

.dropzone .icon { width: 36px; height: 36px; }

.preview {
  grid-area: preview;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 340px;
  padding: 20px;
  border-left: 1px solid var(--border);
  background: var(--card);
  overflow: auto;
}

.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.preview-head h2 { font-size: 15px; }
.preview-media { display: grid; place-items: center; min-height: 180px; border-radius: 12px; background: var(--muted); overflow: hidden; color: var(--muted-foreground); }
.preview-media img, .preview-media video { width: 100%; max-height: 320px; object-fit: contain; background: repeating-conic-gradient(var(--muted) 0 25%, var(--card) 0 50%) 0 0 / 16px 16px; }
.preview-media .icon { width: 48px; height: 48px; }
.preview-name { word-break: break-all; font-weight: 600; }

.details { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; margin: 0; font-size: 13px; }
.details dt { color: var(--muted-foreground); }
.details dd { margin: 0; word-break: break-all; }

.url-box { display: flex; gap: 6px; }
.url-box input { flex: 1; min-width: 0; font-size: 12px; background: var(--muted); }

.preview-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.preview-actions .danger { grid-column: 1 / -1; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: var(--secondary); font-size: 12px; font-weight: 500; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 10; }
.toast { min-width: 240px; max-width: 360px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.toast.success { border-color: var(--success-soft); background: var(--success-soft); color: var(--success); }
.toast.error { border-color: var(--destructive-soft); background: var(--destructive-soft); color: var(--destructive); }

.skeleton { border-radius: 12px; background: linear-gradient(90deg, var(--muted), var(--secondary), var(--muted)); background-size: 200% 100%; animation: shimmer 1.2s infinite; aspect-ratio: 4 / 4; }

@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: 60px auto minmax(0, 1fr); grid-template-areas: "top" "side" "main"; }
  .sidebar { display: flex; overflow-x: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar-title { display: none; }
  .root-link { white-space: nowrap; }
  .preview { position: fixed; inset: auto 0 0 0; width: auto; max-height: 75vh; border-top: 1px solid var(--border); border-left: 0; border-radius: 16px 16px 0 0; box-shadow: var(--shadow); z-index: 5; }
  .topbar .button span:last-child { display: none; }
  .topbar { gap: 10px; padding: 0 12px; }
  .brand span { display: none; }
  .row { grid-template-columns: 40px minmax(0, 1fr) 90px; }
  .row .cell:last-child { display: none; }
}
