/* ---------- theme ---------- */
:root {
  --accent: #4f8cff;
  --accent-hover: #3a7bff;
  --success: #34d399;
  --danger: #f87171;
  --warn: #f59e0b;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Monaco, "Cascadia Code", "Roboto Mono", monospace;
  --code-bg: #0d1117;
  --code-fg: #c9d1d9;
  --code-border: #21262d;
}

[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --border: #2a2f3a;
  --text: #e6e8ee;
  --muted: #8b93a7;
}

[data-theme="light"] {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --border: #dfe3ec;
  --text: #1a1d24;
  --muted: #6a7285;
}

/* ---------- reset ---------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
}

body {
  display: flex;
  flex-direction: column;
  -webkit-text-size-adjust: 100%;
}

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

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  letter-spacing: -0.3px;
}
.logo:hover { text-decoration: none; }
.logo-mark {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
}

.topbar-actions { display: flex; gap: 8px; }

.icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  font-family: inherit;
}
.icon-btn:hover { border-color: #3a4150; }
[data-theme="dark"]  .icon-sun  { display: none; }
[data-theme="light"] .icon-moon { display: none; }

/* ---------- container ---------- */
.container {
  flex: 1;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

/* ---------- tabs ---------- */
.tabs {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 3px;
  margin-bottom: 20px;
  width: fit-content;
}

.tab {
  padding: 8px 20px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--accent); color: #fff; }

/* ---------- panels / cards ---------- */
.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

/* ---------- form ---------- */
.field-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 6px;
  font-weight: 500;
}

textarea, select, input[type="text"], input[type="password"] {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
textarea {
  min-height: 240px;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
  padding: 14px;
}
textarea:focus, select:focus, input:focus { border-color: var(--accent); }

.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.checkbox-row input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.row-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
  text-decoration: none;
}
.btn:hover { border-color: #3a4150; text-decoration: none; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ---------- dropzone ---------- */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: var(--surface-2);
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-2));
}
.dropzone-icon {
  width: 44px; height: 44px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 22px;
}
.dropzone-title { font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.dropzone-sub { font-size: 13px; color: var(--muted); }

/* ---------- storage indicator ---------- */
.storage-info {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}
.storage-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
}
.storage-label span:last-child {
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
}
.storage-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.storage-bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 3px;
  transition: width .3s ease, background-color .3s ease;
}
.storage-bar-fill.warn { background: var(--warn); }
.storage-bar-fill.danger { background: var(--danger); }

/* ---------- file list ---------- */
.file-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}
.file-item .fname {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-item .fsize { color: var(--muted); font-size: 13px; }
.file-item .remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 0 4px;
  font-family: inherit;
}
.file-item .remove:hover { color: var(--danger); }

/* ---------- progress ---------- */
.progress {
  margin-top: 16px;
  height: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .15s;
}

/* ---------- result ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  background: color-mix(in srgb, var(--success) 18%, transparent);
  color: var(--success);
}
.badge.off {
  background: color-mix(in srgb, var(--muted) 18%, transparent);
  color: var(--muted);
}

.result-link {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}
.result-link input {
  font-family: var(--mono);
  font-size: 13.5px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.meta-item .k {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
}
.meta-item .v { font-size: 14px; }

.meta-line {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 13px;
  margin-bottom: 14px;
}
.muted { color: var(--muted); }

/* ---------- code view ---------- */
.code-view {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.6;
  overflow-x: auto;
  margin: 0;
  white-space: pre;
  color: var(--code-fg);
  max-height: 70vh;
}
.code-view code {
  background: transparent;
  padding: 0;
  font-family: inherit;
  color: inherit;
}

/* ---------- file hero ---------- */
.file-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 12px;
}
.file-hero-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}
.file-hero-name { font-size: 16px; font-weight: 600; margin-bottom: 4px; word-break: break-all; }

/* ---------- modal card (password / 404) ---------- */
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  max-width: 420px;
  margin: 8vh auto 0;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
}
.modal-title { margin: 0 0 10px; font-size: 20px; }
.modal-card form { margin-top: 16px; }
.modal-card .error-text { margin-top: 10px; }

/* ---------- QR modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  animation: fadeIn .15s ease;
}

.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
  animation: popIn .18s ease;
  z-index: 1;
}
.qr-modal-content { text-align: center; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  text-align: left;
}
.modal-heading { margin: 0; font-size: 16px; font-weight: 600; }

.qr-wrap {
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  display: inline-block;
  margin: 4px 0 12px;
}
.qr-wrap img {
  display: block;
  width: 260px;
  height: 260px;
  image-rendering: pixelated;
}

.qr-url {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
  margin-bottom: 4px;
  line-height: 1.5;
}

.modal-content .actions { justify-content: center; }
.modal-content .actions .btn { min-width: 120px; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

/* ---------- errors / notices ---------- */
.error-text {
  margin-top: 14px;
  color: var(--danger);
  font-size: 13px;
}
.notice {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--text);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 14px;
}

/* ---------- footer ---------- */
.footer {
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-size: 12.5px;
  border-top: 1px solid var(--border);
}

/* ---------- highlight.js overrides ---------- */
.hljs {
  background: transparent !important;
  padding: 0 !important;
}

/* ---------- mobile ---------- */
@media (max-width: 560px) {
  .container { padding: 20px 14px 40px; }
  .topbar { padding: 12px 14px; }
  .card { padding: 18px; }
  textarea { min-height: 180px; }
  .actions { justify-content: stretch; }
  .actions .btn, .row-buttons .btn { flex: 1; }
  .result-link { flex-direction: column; }
  .result-link .btn { width: 100%; }
  .file-item .fsize { display: none; }
  .modal-card { margin-top: 4vh; padding: 24px 20px; }
  .tab { padding: 8px 16px; }
  .qr-wrap img { width: 200px; height: 200px; }
  .storage-label { font-size: 12px; }
}
