:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #64748b;
  --primary: #0f766e;
  --danger: #b91c1c;

.sidebar-backdrop {
  display: none;
  --line: #dbe2ea;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top right, #d7f0ee, transparent 40%), var(--bg);
  line-height: 1.45;
}

h1,
h2,
p {
  margin: 0;
}

button,
input {
  font: inherit;
}

button {
  border: none;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  padding: 11px 16px;
  cursor: pointer;
}

:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #64748b;
  --primary: #0f766e;
  --danger: #b91c1c;
  --line: #dbe2ea;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top right, #d7f0ee, transparent 40%), var(--bg);
  line-height: 1.45;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input {
  font: inherit;
}

button {
  border: none;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  padding: 11px 16px;
  cursor: pointer;
}

button.ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

button.danger {
  background: var(--danger);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  position: sticky;
  top: 0;
  backdrop-filter: blur(8px);
  z-index: 5;
}

.mobile-only {
  display: none;
}

.layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
  align-items: start;
  min-width: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  min-width: 0;
}

.sidebar-backdrop {
  display: none;
}

.explorer-sidebar,
.explorer-main {
  display: grid;
  gap: 18px;
}

.sidebar-section,
.content-block {
  display: grid;
  gap: 12px;
}

.sidebar-header,
.content-block-header,
.explorer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.explorer-header > div {
  min-width: 0;
}

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbfc;
}

.breadcrumb-item {
  background: transparent;
  color: var(--primary);
  border: none;
  padding: 0;
  font-weight: 700;
  min-height: 28px;
}

.breadcrumb-separator {
  color: var(--muted);
}

.tree-root {
  display: grid;
  gap: 14px;
}

.tree-section {
  display: grid;
  gap: 10px;
}

.tree-root-button {
  width: 100%;
  text-align: left;
  background: #f3f8f8;
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 700;
  min-height: 44px;
}

.tree-root-button.active,
.tree-node.active {
  background: #d7f0ee;
  border-color: #b8ddd8;
}

.tree-node-wrap {
  display: grid;
  gap: 8px;
  margin-left: 8px;
}

.tree-node-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
}

.tree-toggle {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  padding: 0;
}

.tree-node {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  padding: 8px 10px;
  border-radius: 10px;
  min-height: 44px;
}

.tree-children {
  display: grid;
  gap: 6px;
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px dashed var(--line);
}

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.folder-card {
  display: grid;
  gap: 6px;
  text-align: left;
  background: linear-gradient(180deg, #ffffff, #f9fbfc);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
  min-height: 112px;
}

.folder-icon {
  font-size: 1.6rem;
}

.folder-card-title {
  font-weight: 700;
}

.folder-card-subtitle {
  color: var(--muted);
  font-size: 0.84rem;
  word-break: break-all;
}

.upload-panel form {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.hint {
  color: var(--muted);
  margin-top: 10px;
  font-size: 0.92rem;
}

.status {
  margin-top: 10px;
  min-height: 1.2em;
}

.gallery-split {
  display: grid;
  gap: 16px;
}

.group-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.98));
}

.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e5f3f1;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 700;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.thumb {
  width: 100%;
  height: 150px;
  background: #e8eef5;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.thumb img,
.thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.doc-thumb {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  background: #d9f0ee;
  color: #0f766e;
  border: 1px solid #b7dbd7;
}

.meta {
  padding: 10px;
  display: grid;
  gap: 8px;
}

.file-name {
  font-size: 0.9rem;
  line-height: 1.3;
  word-break: break-all;
}

.file-path {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.25;
  word-break: break-all;
}

.row {
  display: flex;
  gap: 8px;
}

.row button {
  flex: 1;
  padding: 8px 10px;
  font-size: 0.86rem;
}

.viewer {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, 0.9);
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) 70px;
  align-items: center;
  z-index: 30;
}

.viewer-content {
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 100vh;
  padding: 20px;
}

.viewer-content img,
.viewer-content video {
  max-width: min(92vw, 1200px);
  max-height: 86vh;
  border-radius: 12px;
}

.doc-preview {
  width: min(92vw, 1200px);
  max-height: 86vh;
  margin: 0;
  padding: 16px;
  border-radius: 12px;
  background: #0f172a;
  color: #e2e8f0;
  overflow: auto;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.viewer-nav,
.viewer-close {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.viewer-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
}

.viewer-nav {
  width: 54px;
  height: 54px;
  border-radius: 999px;
  justify-self: center;
}

.hidden {
  display: none !important;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  display: grid;
  gap: 14px;
  box-shadow: 0 20px 60px rgba(2, 6, 23, 0.08);
}

.login-form {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 600;
  font-size: 0.94rem;
}

input[type="text"],
input[type="password"],
input[type="file"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fff;
}

.error {
  color: var(--danger);
  min-height: 1.2em;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 14px;
    gap: 14px;
  }

  .topbar {
    padding: 12px 14px;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .mobile-only {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .explorer-sidebar {
    position: fixed;
    top: 64px;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 40;
    grid-template-rows: auto auto;
    overflow-y: auto;
    transform: translateY(calc(-100% - 24px));
    opacity: 0;
    pointer-events: none;
    transition: transform 220ms ease, opacity 220ms ease;
    box-shadow: 0 24px 80px rgba(2, 6, 23, 0.22);
  }

  .explorer-sidebar.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 64px 0 0 0;
    z-index: 30;
    background: rgba(15, 23, 42, 0.38);
    backdrop-filter: blur(2px);
  }

  .explorer-main {
    width: 100%;
  }

  .sidebar-header,
  .content-block-header,
  .explorer-header {
    align-items: flex-start;
    gap: 10px;
  }

  .explorer-header {
    align-items: center;
  }

  .breadcrumb {
    overflow-x: auto;
    padding: 8px 10px;
  }

  .folder-grid,
  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .thumb {
    height: 128px;
  }

  .viewer {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
  }

  .viewer-content {
    padding: 12px;
  }

  .viewer-content img,
  .viewer-content video {
    max-width: 94vw;
    max-height: 78vh;
    border-radius: 10px;
  }

  .viewer-nav {
    width: 40px;
    height: 40px;
  }

  .login-page {
    padding: 14px;
  }

  .login-card {
    padding: 18px;
    gap: 12px;
  }
}

@media (max-width: 560px) {
  .layout {
    padding: 10px;
    gap: 10px;
  }

  .panel {
    padding: 12px;
    border-radius: 12px;
  }

  .explorer-sidebar {
    top: 58px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    border-radius: 16px;
  }

  .sidebar-backdrop {
    inset: 58px 0 0 0;
  }

  .folder-grid,
  .gallery {
    grid-template-columns: 1fr;
  }

  .sidebar-section,
  .content-block {
    gap: 10px;
  }

  .tree-node-wrap {
    margin-left: 4px;
  }

  .tree-children {
    margin-left: 6px;
    padding-left: 8px;
  }

  .row {
    flex-direction: column;
  }

  .row button {
    width: 100%;
  }

  .thumb {
    height: 180px;
  }

  .viewer {
    grid-template-columns: 36px minmax(0, 1fr) 36px;
  }

  .viewer-close {
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
  }

  .viewer-nav {
    width: 34px;
    height: 34px;
  }

  .login-card {
    border-radius: 14px;
  }
}
