:root {
  --bg: #0b0e14;
  --bg2: #11151f;
  --card: #161b28;
  --border: #232a3b;
  --text: #e6e9f0;
  --muted: #8b93a7;
  --accent: #6c8cff;
  --accent2: #8b5cf6;
  --danger: #ff5d6c;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: dark; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #1a2138 0%, var(--bg) 55%);
  color: var(--text);
  font-family: 'Segoe UI', 'Noto Sans Thai', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  line-height: 1.6;
}
.wrap { max-width: 880px; margin: 0 auto; padding: 48px 20px 80px; }

.hero { text-align: center; margin-bottom: 32px; }
.logo { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.5px; }
.logo span { color: var(--accent); }
.tagline { color: var(--muted); margin-top: 6px; font-size: 1.02rem; }

.dropzone {
  background: var(--card);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 44px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
  outline: none;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); background: #181f30; }
.dropzone.dragover { border-color: var(--accent); background: #1a2338; transform: scale(1.01); }
.dropzone svg { color: var(--accent); margin-bottom: 12px; }
.dz-main { font-size: 1.1rem; }
.dz-main .link { color: var(--accent); font-weight: 600; }
.dz-sub { color: var(--muted); font-size: .88rem; margin-top: 6px; }
.dz-hint { color: var(--muted); font-size: .8rem; margin-top: 14px; opacity: .8; }

.expiry-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 14px; padding: 0 4px;
}
.expiry-label { color: var(--muted); font-size: .85rem; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip.exp.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; border-color: transparent;
}

.progress-wrap { margin-top: 20px; }
.progress-bar { height: 8px; background: var(--bg2); border-radius: 99px; overflow: hidden; }
#progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 99px; transition: width .2s; }
#progress-text { color: var(--muted); font-size: .85rem; margin-top: 6px; text-align: center; }

.errors { margin-top: 16px; }
.errors .err {
  background: #2a1520; border: 1px solid #4a1f2e; color: #ffb3bc;
  padding: 10px 14px; border-radius: 10px; font-size: .88rem; margin-bottom: 8px;
}

.results { margin-top: 36px; }
.results h2, .mine-section h2 { font-size: 1.15rem; margin-bottom: 14px; }
.results-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.links-box {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 12px;
}
.links-row { display: flex; gap: 10px; align-items: baseline; padding: 4px 0; }
.links-name {
  color: var(--muted); font-size: .78rem; width: 140px; flex-shrink: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.links-url {
  flex: 1; min-width: 0; color: var(--accent); font-size: .8rem;
  font-family: ui-monospace, monospace; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.result-card {
  display: flex; gap: 16px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.thumb {
  width: 96px; height: 96px; object-fit: cover; border-radius: 10px;
  background: var(--bg2); flex-shrink: 0; cursor: zoom-in;
}
.result-info { flex: 1; min-width: 0; }
.fname { font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fmeta { color: var(--muted); font-size: .8rem; margin-bottom: 8px; }
.url-row { display: flex; gap: 8px; }
.url-box {
  flex: 1; min-width: 0; background: var(--bg2); color: var(--accent);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  font-size: .82rem; font-family: ui-monospace, monospace;
}
.btn {
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border: none;
  border-radius: 8px; padding: 8px 14px; font-size: .82rem; font-weight: 600; cursor: pointer;
  transition: opacity .15s; white-space: nowrap; text-decoration: none; display: inline-block;
}
.btn:hover { opacity: .88; }
.fmt-row { display: flex; gap: 6px; margin-top: 8px; align-items: center; }
.chip {
  background: var(--bg2); color: var(--muted); border: 1px solid var(--border);
  border-radius: 7px; padding: 4px 10px; font-size: .75rem; cursor: pointer; transition: all .15s;
}
.chip:hover { color: var(--text); border-color: var(--accent); }
.chip.del:hover { color: var(--danger); border-color: var(--danger); }

.mine-section { margin-top: 48px; }
.mine-note { margin: -8px 0 12px; font-size: .78rem; }
.gallery-head { display: flex; justify-content: space-between; align-items: center; }
.muted { color: var(--muted); font-weight: 400; font-size: .85rem; }
.center { text-align: center; }
.gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-top: 4px;
}
.gallery .empty { grid-column: 1 / -1; padding: 24px 0; }
.g-item.expiring { border-style: dashed; }
.g-item {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  transition: transform .15s, border-color .15s;
}
.g-item:hover { transform: translateY(-2px); border-color: var(--accent); }
.g-item img { width: 100%; height: 110px; object-fit: cover; display: block; cursor: zoom-in; background: var(--bg2); }
.g-item figcaption { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; gap: 4px; }
.g-actions { display: flex; gap: 4px; flex-shrink: 0; }
.g-actions .chip { padding: 2px 6px; }
.g-name { font-size: .68rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn-ghost {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 14px; font-size: .82rem; cursor: pointer; margin-top: 12px;
  font-family: inherit;
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }

.lightbox {
  position: fixed; inset: 0; background: rgba(5, 7, 12, .92); z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 30px;
}
.lightbox img { max-width: 92vw; max-height: 78vh; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
#lightbox-close {
  position: absolute; top: 18px; right: 22px; background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 50%; width: 40px; height: 40px; font-size: 1rem; cursor: pointer;
}

footer { text-align: center; margin-top: 60px; color: var(--muted); font-size: .8rem; }
footer a { color: var(--muted); }
[hidden] { display: none !important; }

@media (max-width: 560px) {
  .result-card { flex-direction: column; }
  .thumb { width: 100%; height: 160px; }
  .logo { font-size: 1.7rem; }
}
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--card); border: 1px solid var(--accent); color: var(--text);
  padding: 10px 18px; border-radius: 10px; font-size: .85rem; z-index: 200;
  animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
