*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f0f0;
  color: #333;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #222;
  text-decoration: none;
  letter-spacing: -0.01em;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.username {
  font-size: 0.78rem;
  color: #777;
}
.btn-login {
  font-size: 0.7rem;
  padding: 3px 9px;
  border: 1px solid #ccc;
  border-radius: 4px;
  text-decoration: none;
  color: #666;
  background: #fafafa;
  transition: background 0.15s;
}
.btn-login:hover { background: #f0f0f0; border-color: #aaa; }

/* Layout */
main { flex: 1; padding: 2rem 1.5rem; }
.container { max-width: 860px; margin: 0 auto; }
.center-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 170px);
}

/* Cards */
.card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1.75rem;
}
.card-sm { max-width: 380px; width: 100%; }
.card-title { font-size: 1.2rem; font-weight: 600; margin-bottom: 0.4rem; }
.card-subtitle { color: #888; font-size: 0.88rem; margin-bottom: 1.25rem; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: #555;
  margin-bottom: 0.3rem;
}
.form-group small { display: block; font-size: 0.74rem; color: #999; margin-top: 0.25rem; }

input[type="text"],
input[type="password"],
input[type="file"],
select {
  width: 100%;
  padding: 0.52rem 0.72rem;
  border: 1px solid #d0d0d0;
  border-radius: 5px;
  font-size: 0.88rem;
  background: #fafafa;
  color: #333;
  outline: none;
  transition: border-color 0.15s;
}
input[type="text"]:focus,
input[type="password"]:focus,
select:focus { border-color: #888; background: #fff; }
input[type="file"] { padding: 0.38rem; cursor: pointer; }

/* Buttons */
.btn-primary {
  display: inline-block;
  padding: 0.58rem 1.4rem;
  background: #444;
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.btn-primary:hover { background: #222; }
.btn-primary.full-width { width: 100%; text-align: center; }

.btn-sm {
  display: inline-block;
  padding: 0.28rem 0.45rem;
  background: #f0f0f0;
  color: #444;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.btn-sm:hover { background: #e4e4e4; }
.btn-danger { background: #fff0f0; color: #b00; border-color: #f0c0c0; }
.btn-danger:hover { background: #ffe4e4; }
.btn-download { background: #444; color: #fff; border-color: #444; }
.btn-download:hover { background: #222; color: #fff; border-color: #222; }

/* Alerts */
.alert {
  padding: 0.6rem 0.9rem;
  border-radius: 5px;
  font-size: 0.86rem;
  margin-bottom: 1rem;
}
.alert-error { background: #fff2f2; color: #b00; border: 1px solid #f5c0c0; }
.alert-success { background: #f2fff4; color: #080; border: 1px solid #aadcb0; }

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.page-header h2 { font-size: 1.05rem; font-weight: 600; }

/* Share list */
.shares-list { display: flex; flex-direction: column; gap: 0.5rem; }
.share-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.share-manage {
  flex-basis: 100%;
  border-top: 1px solid #f0f0f0;
  padding-top: 0.6rem;
  margin-top: 0.1rem;
}
.manage-files-list { margin-bottom: 0.6rem; }
.manage-file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0;
  font-size: 0.8rem;
  color: #555;
  border-bottom: 1px solid #f5f5f5;
}
.manage-file-row:last-child { border-bottom: none; }
.manage-add-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
.manage-add-form input[type="file"] { width: auto; flex: 1; font-size: 0.8rem; padding: 0.25rem; }
.share-code { display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.25rem; }
.share-code code {
  font-family: monospace;
  background: #f2f2f2;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}
.share-files { font-size: 0.8rem; color: #666; margin-bottom: 0.2rem; }
.file-size { color: #999; }
.share-meta { font-size: 0.73rem; color: #aaa; }
.share-actions { display: flex; gap: 0.35rem; flex-shrink: 0; align-items: center; }

/* Download page file list */
.files-list { display: flex; flex-direction: column; gap: 0.45rem; }
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.9rem;
  background: #fafafa;
  border: 1px solid #ebebeb;
  border-radius: 5px;
}
.file-info { display: flex; align-items: center; gap: 0.55rem; overflow: hidden; }
.file-icon { font-size: 1rem; flex-shrink: 0; }
.file-name { font-size: 0.88rem; font-weight: 500; word-break: break-all; }
.file-size-dl { font-size: 0.76rem; color: #999; flex-shrink: 0; }

/* Code input (index page) */
.code-form { display: flex; gap: 0.5rem; margin-top: 1.25rem; }
.code-input {
  flex: 1;
  font-size: 1.05rem !important;
  text-align: center;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: monospace !important;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 1px 6px;
  background: #ececec;
  border-radius: 3px;
  font-size: 0.7rem;
  color: #666;
}
.badge-lock { background: #fff8e0; color: #996600; }

/* Table */
.table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.table th {
  text-align: left;
  padding: 0.48rem 0.75rem;
  border-bottom: 2px solid #e4e4e4;
  color: #777;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.table td { padding: 0.58rem 0.75rem; border-bottom: 1px solid #f0f0f0; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafafa; }

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* Misc */
.empty-state { text-align: center; color: #aaa; font-size: 0.88rem; padding: 2rem 0; }
.text-muted { color: #bbb; }
.mt-lg { margin-top: 2rem; }

/* Footer */
footer { background: #fff; border-top: 1px solid #e8e8e8; padding: 0.7rem 1.5rem; }
.footer-inner {
  max-width: 960px;
  margin: 0 auto;
  font-size: 0.74rem;
  color: #bbb;
  text-align: center;
}

/* Checkbox label */
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #444;
  cursor: pointer;
  line-height: 1.4;
}
.checkbox-label input[type="checkbox"] {
  width: auto;
  margin-top: 2px;
  flex-shrink: 0;
}

/* Photo grid (no-download gallery) */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.45rem;
}
.photo-thumb {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 6px;
  cursor: pointer;
  background: #f0f0f0;
  border: 1px solid #e0e0e0;
  transition: opacity 0.15s;
}
.photo-thumb:hover { opacity: 0.85; }
.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.93);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.lightbox.active { display: flex; }
.lightbox #lb-img {
  max-width: 90vw;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 4px;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: auto;
}
.lb-close {
  position: absolute;
  top: 0.9rem;
  right: 1rem;
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
}
.lb-close:hover { color: #fff; background: rgba(255,255,255,0.1); }
.lb-prev, .lb-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.08);
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 2.8rem;
  cursor: pointer;
  padding: 0.4rem 0.8rem;
  border-radius: 5px;
  line-height: 1;
  transition: background 0.15s;
}
.lb-prev { left: 0.9rem; }
.lb-next { right: 0.9rem; }
.lb-prev:hover, .lb-next:hover { background: rgba(255,255,255,0.18); }
#lb-caption {
  color: rgba(255,255,255,0.55);
  font-size: 0.8rem;
  margin-top: 0.8rem;
  max-width: 90vw;
  text-align: center;
  user-select: none;
}

/* Badge variants */
.badge-nodl { background: #e8f0ff; color: #335; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 8px;
  padding: 1.6rem 1.5rem 1.5rem;
  width: 100%;
  max-width: 400px;
  position: relative;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}
.modal-close {
  position: absolute;
  top: 0.7rem;
  right: 0.8rem;
  background: none;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  color: #999;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
}
.modal-close:hover { background: #f0f0f0; color: #333; }
.modal-title {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 1.1rem;
  padding-right: 1.5rem;
  word-break: break-all;
}

/* Inline input row (e.g. expires days) */
.inline-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.input-days {
  width: 90px !important;
  text-align: center;
}
.input-suffix {
  font-size: 0.85rem;
  color: #666;
  white-space: nowrap;
}

/* Expired badge */
.badge-expired { background: #fff0f0; color: #b00; }

/* Scrollable table wrapper */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Responsive ──────────────────────────────────────────────── */

/* Tablet (≤ 768px) */
@media (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr; }
  .container { max-width: 100%; }
}

/* Mobile (≤ 600px) */
@media (max-width: 600px) {
  /* Layout */
  main { padding: 1rem 0.75rem; }
  .container { padding: 0; }

  /* Header */
  .header-inner { padding: 0 0.75rem; gap: 0.4rem; }
  .site-name { font-size: 0.85rem; }
  .username { display: none; }

  /* Cards */
  .card { padding: 1.1rem 0.9rem; }
  .card-sm { max-width: 100%; }

  /* Page header */
  .page-header { flex-wrap: wrap; gap: 0.4rem; }
  .page-header h2 { font-size: 0.95rem; }

  /* Forms */
  .code-form { flex-direction: column; }
  .inline-input-row { flex-wrap: wrap; }

  /* Share cards */
  .share-card { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
  .share-actions { flex-wrap: nowrap; gap: 0.2rem; width: 100%; }
  .share-code { flex-wrap: wrap; }

  /* File items on download page */
  .file-item { flex-wrap: wrap; gap: 0.4rem; }
  .file-item > div:last-child { flex-wrap: wrap; }

  /* Photo grid */
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.35rem; }

  /* Lightbox */
  .lightbox #lb-img { max-width: 98vw; max-height: 70vh; }
  .lb-prev { left: 0.2rem; font-size: 2rem; padding: 0.3rem 0.55rem; }
  .lb-next { right: 0.2rem; font-size: 2rem; padding: 0.3rem 0.55rem; }
  #lb-caption { font-size: 0.72rem; padding: 0 0.5rem; }

  /* Table */
  .table-wrap { margin: 0 -0.1rem; }
  .table th, .table td { padding: 0.42rem 0.55rem; font-size: 0.8rem; }

  /* Admin grid */
  .grid-2 { grid-template-columns: 1fr; }

  /* Modal */
  .modal-overlay { padding: 0.75rem; align-items: flex-end; }
  .modal-box { border-radius: 8px 8px 6px 6px; padding: 1.25rem 1rem 1.1rem; }

  /* Misc */
  .mt-lg { margin-top: 1.25rem; }
  .center-container { min-height: calc(100vh - 130px); padding: 1rem 0; align-items: flex-start; }
}
