* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f4f2;
  color: #202020;
}

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px;
}

.hidden {
  display: none !important;
}

.entry-card {
  max-width: 390px;
  margin: 120px auto;
  padding: 30px;
  background: white;
  border-radius: 22px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
}

.entry-card h1 {
  margin-top: 0;
  margin-bottom: 8px;
}

.entry-card p {
  color: #666;
}

form {
  display: flex;
  gap: 10px;
}

input {
  min-width: 0;
  flex: 1;
  padding: 13px 14px;
  border: 1px solid #ccc;
  border-radius: 12px;
  font: inherit;
}

button {
  padding: 13px 16px;
  border: 0;
  border-radius: 12px;
  background: #202020;
  color: white;
  font: inherit;
  cursor: pointer;
}

button:hover {
  opacity: 0.86;
}

.secondary-button {
  margin-top: 14px;
  width: 100%;
  background: #eeeeee;
  color: #222;
}

.error {
  min-height: 1.4em;
  color: #c0392b !important;
}

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

.topbar h1 {
  margin-bottom: 4px;
}

#currentPath {
  margin: 0;
  color: #666;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 34px;
}

.breadcrumbs button {
  background: white;
  color: #222;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.08);
}

h2 {
  margin-top: 32px;
  margin-bottom: 14px;
}

.folders {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  min-height: 28px;
}

.folder {
  padding: 15px 18px;
  background: white;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.08);
  user-select: none;
}

.folder:hover {
  transform: translateY(-1px);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 18px;
  min-height: 28px;
}

.card {
  overflow: hidden;
  background: white;
  border-radius: 18px;
  cursor: pointer;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1);
}

.card:hover {
  transform: translateY(-1px);
}

.card img {
  width: 100%;
  height: 155px;
  object-fit: cover;
  display: block;
  background: #ddd;
}

.card div {
  padding: 11px;
  font-size: 14px;
  word-break: break-word;
}

.empty {
  color: #777;
}

.preview-toolbar {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  gap: 10px;
  z-index: 10;
}

.preview-toolbar button {
  height: 48px;
}

.close-preview {
  width: 48px;
  padding: 0;
  font-size: 28px;
}

.preview-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 54px;
  height: 72px;
  padding: 0;
  font-size: 48px;
  line-height: 1;
  z-index: 10;
  background: rgba(255, 255, 255, 0.16);
}

.preview-nav:hover {
  background: rgba(255, 255, 255, 0.28);
}

.preview-nav-left {
  left: 24px;
}

.preview-nav-right {
  right: 24px;
}

.preview-caption {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(90vw, 720px);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  font-size: 14px;
  text-align: center;
  word-break: break-word;
}

.preview-nav:disabled {
  opacity: 0.25;
  cursor: default;
}

@media (max-width: 680px) {
  .preview-toolbar {
    top: 14px;
    right: 14px;
  }

  .preview-nav {
    width: 44px;
    height: 62px;
    font-size: 38px;
  }

  .preview-nav-left {
    left: 10px;
  }

  .preview-nav-right {
    right: 10px;
  }

  .preview-caption {
    bottom: 14px;
    font-size: 13px;
  }
}

.modal {
  position: fixed;
  inset: 0;
  padding: 24px;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  width: min(420px, 100%);
  padding: 26px;
  background: white;
  border-radius: 22px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.2);
}

.modal-card h2 {
  margin-top: 0;
}

.preview-modal {
  position: fixed;
  inset: 0;
  padding: 32px;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-modal img {
  max-width: 95vw;
  max-height: 90vh;
  border-radius: 12px;
}

@media (max-width: 680px) {
  main {
    padding: 20px;
  }

  .entry-card {
    margin: 80px auto;
  }

  form {
    flex-direction: column;
  }

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

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions button {
    flex: 1;
  }
}
