:root {
  --bg: #f6f5f3;
  --card: #ffffff;
  --text: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --accent: #ea580c;
  --accent-soft: #fff1e8;
  --danger: #dc2626;
  --radius: 12px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141210;
    --card: #1e1b19;
    --text: #f5f5f4;
    --muted: #a8a29e;
    --line: #2f2b28;
    --accent-soft: #3a2014;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; color: inherit; }

button {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; }
button.danger:hover { color: var(--danger); border-color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }

input[type=password], input[type=search], input[readonly], select {
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 10px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.muted { color: var(--muted); }
.error { color: var(--danger); margin: 0; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 880px;
  margin: 0 auto;
  padding: 18px 20px 8px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 18px; }
.header-right { display: flex; align-items: center; gap: 12px; font-size: 13px; }
header form { margin: 0; }

main { max-width: 880px; margin: 0 auto; padding: 8px 20px 60px; display: grid; gap: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 150px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  text-align: center;
  padding: 20px;
  transition: border-color .15s, background .15s;
}
.dropzone strong { font-size: 17px; }
.dropzone:hover, body.dragging .dropzone { border-color: var(--accent); background: var(--accent-soft); }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.section-head h2 { font-size: 15px; margin: 0; }
.section-head input { width: min(240px, 50%); padding: 6px 10px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.list li:first-child { border-top: 0; }
.list .name { flex: 1; min-width: 0; }
.list .name a, .list .name span.title {
  display: block;
  color: inherit;
  text-decoration: none;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list .name a:hover { color: var(--accent); }
.list .meta { font-size: 13px; color: var(--muted); }
.list .actions { display: flex; gap: 6px; flex-shrink: 0; }
.list .actions button { padding: 4px 10px; font-size: 13px; }
.empty { text-align: center; padding: 16px 0 6px; margin: 0; }

.uploads { display: grid; gap: 8px; }
.uploads:empty { display: none; }
.upload {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  align-items: center;
}
.upload .title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload .meta { font-size: 13px; color: var(--muted); }
.upload .bar { grid-column: 1 / -1; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.upload .bar > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.upload.done .bar > div { background: #16a34a; }
.upload.failed .bar > div { background: var(--danger); }
.upload .actions { display: flex; gap: 6px; }
.upload .actions button { padding: 3px 10px; font-size: 13px; }

dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  padding: 0;
  width: min(460px, calc(100vw - 32px));
}
dialog::backdrop { background: rgb(0 0 0 / .35); }
.dialog-body { padding: 18px 20px; display: grid; gap: 12px; margin: 0; }
.dialog-body h3, .dialog-body p { margin: 0; }
.dialog-body label { display: flex; align-items: center; gap: 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.share-result { display: flex; gap: 8px; }
.share-result input { flex: 1; min-width: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: 0 6px 24px rgb(0 0 0 / .2);
}

body.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(340px, 100%); display: grid; gap: 12px; justify-items: center; padding: 28px 24px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card input, .login-card button { width: 100%; padding: 10px 12px; }

@media (max-width: 560px) {
  .list li { flex-wrap: wrap; }
  .list .actions { width: 100%; justify-content: flex-end; }
  #free { display: none; }
}
