:root {
  --bg: #f3f6f8;
  --card: #ffffff;
  --text: #15232d;
  --muted: #5d6b76;
  --line: #dde4ea;
  --brand: #0b6e78;
  --brand-dark: #085660;
  --danger: #b4232c;
  --ok-bg: #e4f5ec;
  --ok-text: #136b3a;
  --err-bg: #fdecec;
  --err-text: #9b1c24;
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}
a { color: var(--brand); }
h1 { font-size: 1.35rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 28px 0 12px; display: flex; align-items: center; gap: 8px; }
.count { font-size: 0.8rem; background: var(--line); border-radius: 999px; padding: 1px 9px; color: var(--muted); }
.muted { color: var(--muted); }
small { font-weight: normal; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--brand); text-decoration: none; font-size: 1.05rem; }
.wrap { max-width: 860px; margin: 0 auto; padding: 20px 16px 60px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.card.login { max-width: 400px; margin: 48px auto 0; }
.card.center { text-align: center; max-width: 460px; margin: 48px auto 0; }

label { display: block; font-weight: 600; margin: 14px 0 0; }
label input[type="text"], label input[type="password"] {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff;
}
input:focus-visible, button:focus-visible, .file-btn:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--text); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; line-height: 1.2; white-space: nowrap;
}
.btn:hover { border-color: #b9c4cd; background: #fafcfd; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: #fff5f5; border-color: #e3b4b7; }
.btn.small { padding: 7px 12px; font-size: 0.9rem; }
.btn[disabled] { opacity: 0.6; cursor: wait; }
form.login .btn, .login form .btn { width: 100%; margin-top: 18px; }
.upload .btn.primary { margin-top: 18px; }

.flash { padding: 12px 14px; border-radius: 8px; margin: 0 0 16px; font-weight: 500; }
.flash.ok { background: var(--ok-bg); color: var(--ok-text); }
.flash.error { background: var(--err-bg); color: var(--err-text); }

.drop {
  display: block; border: 2px dashed #b9c8d0; border-radius: var(--radius);
  padding: 26px 16px; text-align: center; cursor: pointer; margin-top: 16px; font-weight: 500;
  color: var(--muted); background: #fafcfd; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--brand); background: #eef7f8; color: var(--brand-dark); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-name { display: block; margin-top: 6px; color: var(--text); font-weight: 600; word-break: break-all; }
.drop-name:empty { display: none; }

.empty { color: var(--muted); text-align: center; padding: 30px; border: 1px dashed var(--line); border-radius: var(--radius); }

.file {
  display: grid; grid-template-columns: 160px 1fr; gap: 18px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; scroll-margin-top: 16px;
}
.file:target { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11,110,120,.15); }
.qr { display: block; width: 160px; height: 160px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.qr img { display: block; width: 100%; height: 100%; }
.info { min-width: 0; }
.rename { display: flex; gap: 8px; align-items: center; }
.rename .title {
  flex: 1; min-width: 0; font: inherit; font-weight: 700; font-size: 1.05rem;
  padding: 4px 6px; margin: 0 0 0 -6px; border: 1px solid transparent; border-radius: 6px; background: transparent;
}
.rename .title:hover { border-color: var(--line); }
.rename .title:focus { border-color: var(--brand); background: #fff; outline: none; }
.meta { margin: 4px 0; color: var(--muted); font-size: 0.9rem; word-break: break-word; }
.link { display: flex; gap: 8px; margin: 10px 0; }
.link input {
  flex: 1; min-width: 0; font: inherit; font-size: 0.9rem; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: #f8fafb; color: var(--text);
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.inline-form { display: inline; margin: 0; }
.file-btn { margin: 0; font-weight: 600; }

@media (max-width: 560px) {
  .file { grid-template-columns: 1fr; }
  .qr { margin: 0 auto; }
  .actions .btn, .actions .inline-form { flex: 1 1 45%; }
  .actions .inline-form .btn { width: 100%; }
}
