:root {
  --bg: #0d1117;
  --bg-elev: #151b23;
  --bg-elev-2: #1c232c;
  --border: #262e39;
  --text: #e6edf3;
  --text-muted: #8b98a8;
  --accent: #4c8dff;
  --accent-ink: #ffffff;
  --ok: #3fb950;
  --danger: #f85149;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.centered {
  display: grid;
  place-items: center;
  padding: 24px;
}

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

.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.h1 { font-size: 20px; margin: 0 0 2px; font-weight: 600; }
.h2 { font-size: 16px; margin: 8px 0 4px; font-weight: 600; }

/* ---------------------------------------------------------------- layout */

.shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.main {
  padding: 24px 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; height: auto; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
}

/* ---------------------------------------------------------------- brand */

.brand { display: flex; align-items: center; gap: 8px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
}

.brand-name { font-weight: 600; letter-spacing: -0.01em; }

/* ---------------------------------------------------------------- cards */

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

.auth-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 10px; }
.auth-card form { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }

/* ---------------------------------------------------------------- forms */

label { font-size: 12px; color: var(--text-muted); }

input[type="text"], input[type="email"], input[type="password"], input[type="search"] {
  width: 100%;
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}

input:focus-visible, button:focus-visible, a:focus-visible, .dropzone:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev-2);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.btn:hover { border-color: #38414d; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; margin-top: 4px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: #5a2725; color: var(--danger); }
.btn-danger:hover { background: #2a1614; }

/* ---------------------------------------------------------------- upload */

.upload-form { display: flex; flex-direction: column; gap: 8px; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 18px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  text-align: center;
}

.dropzone:hover, .dropzone.is-drag { border-color: var(--accent); background: #101a2b; }
.dropzone-icon { font-size: 18px; color: var(--accent); }
.dropzone-text { font-size: 13px; font-weight: 500; word-break: break-all; }
.dropzone-hint { font-size: 11px; color: var(--text-muted); }

/* ---------------------------------------------------------------- file list */

.sidebar-list-head { display: flex; align-items: center; justify-content: space-between; }

.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.count {
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  font-size: 10px;
}

.doc-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; margin: -4px; padding: 4px; }

.doc-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
}

.doc-item:hover { background: var(--bg-elev-2); }
.doc-item.is-active { background: var(--bg-elev-2); border-color: var(--border); }
.doc-item-title { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-item-meta { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-muted); }

.dot { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto; }
.dot-on { background: var(--ok); }
.dot-off { background: #5b6672; }

.empty { font-size: 12px; color: var(--text-muted); padding: 8px 2px; }

/* ---------------------------------------------------------------- detail */

.placeholder { max-width: 460px; margin-top: 8vh; }

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.detail-actions { display: flex; gap: 6px; }

.share-card { display: flex; flex-direction: column; gap: 12px; }
.share-row { display: flex; align-items: center; gap: 12px; }
.share-state { margin: 0; font-weight: 600; }
.share-help, .share-state + p { margin: 0; }

.switch { flex: 0 0 auto; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.switch-track {
  display: block;
  width: 40px;
  height: 22px;
  padding: 2px;
  border-radius: 999px;
  background: #39414d;
  transition: background 0.15s ease;
}

.switch-knob {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}

.switch input:checked + .switch-track { background: var(--ok); }
.switch input:checked + .switch-track .switch-knob { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.link-row { display: flex; gap: 6px; align-items: center; }
.link-row.is-disabled { opacity: 0.45; pointer-events: none; }
.link-input { flex: 1; min-width: 0; }

/* ---------------------------------------------------------------- preview */

.preview { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 320px; }
.preview-head { display: flex; align-items: center; justify-content: space-between; }

.preview-frame {
  flex: 1;
  width: 100%;
  min-height: 320px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

/* ---------------------------------------------------------------- feedback */

.alert { margin: 0; padding: 9px 12px; border-radius: 8px; font-size: 13px; }
.alert-ok { background: #10251a; border: 1px solid #1f4d2e; color: #7ee493; }
.alert-error { background: #2a1614; border: 1px solid #5a2725; color: #ff9a92; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translate(-50%, 12px);
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
