:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --warn: #f59e0b;
  --border: #334155;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Hiragino Sans', 'Yu Gothic UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.header h1 { font-size: 1.25rem; margin: 0; }
.header .user-info { color: var(--muted); font-size: .9rem; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

h2 { margin-top: 0; font-size: 1.15rem; }

.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  margin-bottom: 6px;
  font-size: .9rem;
  color: var(--muted);
}
.form-row input,
.form-row select {
  width: 100%;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: .95rem;
  font-family: inherit;
}
.form-row input:focus,
.form-row select:focus {
  outline: none;
  border-color: var(--accent);
}
.form-row .hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.label-hint { font-size: .75rem; color: var(--muted); font-weight: normal; margin-left: 6px; }

/* ---- recipient emails ---- */
#recipient-list { display: flex; flex-direction: column; gap: 6px; }
.recipient-row { display: flex; align-items: center; gap: 6px; }
.recipient-row .recipient-input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: .95rem;
  font-family: inherit;
}
.recipient-row .recipient-input:focus { outline: none; border-color: var(--accent); }
.recipient-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0 6px;
  flex-shrink: 0;
  line-height: 1;
}
.recipient-remove:hover { color: var(--danger); }
.add-recipient-btn {
  margin-top: 6px;
  background: none;
  border: 1px dashed var(--border);
  color: var(--accent);
  cursor: pointer;
  font-size: .85rem;
  padding: 6px 10px;
  border-radius: 6px;
  font-family: inherit;
}
.add-recipient-btn:hover { border-color: var(--accent); }

.btn {
  display: inline-block;
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 6px 12px; font-size: .85rem; }

.drop-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all .15s ease;
  background: var(--panel-2);
}
.drop-area.dragging {
  border-color: var(--accent);
  background: rgba(59,130,246,0.08);
}
.drop-area.has-files { padding: 16px 20px; }
.drop-area.has-files .icon { font-size: 1.2rem; margin-bottom: 2px; }
.drop-area.has-files p { font-size: .8rem; margin: 2px 0; }
.drop-area .icon { font-size: 2rem; margin-bottom: 8px; }
.drop-area p { margin: 4px 0; color: var(--muted); }
.drop-area .picked { color: var(--success); font-weight: 600; }

.progress {
  margin-top: 12px;
  height: 8px;
  background: var(--panel-2);
  border-radius: 4px;
  overflow: hidden;
}
.progress > div {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width .15s ease;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
table th, table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
table th { color: var(--muted); font-weight: 500; }
table td.expired { color: var(--muted); }

.copy-url {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: .8rem;
  background: var(--panel-2);
  padding: 4px 8px;
  border-radius: 4px;
  word-break: break-all;
  display: inline-block;
}

.upload-action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.upload-action-row #alert { flex: 1; min-width: 0; }
.upload-action-row #alert:empty { display: none; }

.alert {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 0;
  font-size: .9rem;
}
.alert.error { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.4); color: #fecaca; }
.alert.success { background: rgba(16,185,129,.12); border: 1px solid rgba(16,185,129,.4); color: #a7f3d0; }
.alert.info { background: rgba(59,130,246,.12); border: 1px solid rgba(59,130,246,.4); color: #bfdbfe; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tabs button {
  flex: 1;
  padding: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}
.tabs button.active { color: var(--text); border-color: var(--accent); background: var(--panel); }

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}
.modal h3 { margin-top: 0; }
.modal .mail-box {
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 14px;
  border-radius: 6px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: .85rem;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 12px 0;
}
.modal .modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

#staged-list {
  width: 100%;
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
#staged-list:empty { display: none; }
.staged-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
  text-align: left;
}
.staged-count { font-size: .85rem; color: var(--text); font-weight: 600; }
.staged-actions-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: .82rem;
  padding: 0;
  text-decoration: underline;
  font-family: inherit;
}
.staged-actions-btn:hover { opacity: .75; }

.staged-items { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.staged-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.staged-name { font-size: .88rem; word-break: break-all; flex: 1; min-width: 0; }
.staged-size { color: var(--muted); font-size: .8rem; white-space: nowrap; flex-shrink: 0; }
.staged-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0 4px;
  margin-left: 8px;
  flex-shrink: 0;
  line-height: 1;
}
.staged-remove:hover { color: var(--danger); }

/* ---- Download select screen ---- */
.select-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.dl-remaining {
  margin-left: auto;
  font-size: .82rem;
  color: var(--warn);
  white-space: nowrap;
}
.dl-list {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  max-height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dl-file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  font-size: .86rem;
  border-radius: 6px;
  cursor: pointer;
}
.dl-file:hover { background: var(--panel-2); }
.dl-file-name { flex: 1; min-width: 0; word-break: break-all; }
.dl-file-size { color: var(--muted); font-size: .78rem; white-space: nowrap; flex-shrink: 0; }
.dl-file-check { cursor: pointer; flex-shrink: 0; }

.progress-status {
  font-size: .82rem;
  color: var(--muted);
  margin-top: 4px;
  min-height: 1.2em;
}

@media (max-width: 640px) {
  .container { padding: 16px 12px; }
  table { font-size: .8rem; }
  table th, table td { padding: 6px 4px; }
  .copy-url { font-size: .7rem; }
}
