:root {
  --bg: #ffffff;
  --fg: #1f2328;
  --muted: #656d76;
  --border: #d0d7de;
  --surface: #f6f8fa;
  --accent: #0969da;
  --accent-fg: #ffffff;
  --danger: #cf222e;
  --ok-bg: #dafbe1;
  --error-bg: #ffebe9;
  --radius: 6px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --fg: #e6edf3;
    --muted: #8d96a0;
    --border: #30363d;
    --surface: #161b22;
    --accent: #2f81f7;
    --danger: #f85149;
    --ok-bg: #12261e;
    --error-bg: #2d1214;
  }
}

* { box-sizing: border-box; }

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

a { color: var(--accent); }

header.site {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

header.site .brand { font-weight: 600; color: var(--fg); text-decoration: none; }
header.site nav, .toolbar, .share-row, .actions, .search { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
header.site nav form, .toolbar form, .share-row form { margin: 0; }

main { max-width: 72rem; margin: 0 auto; padding: 1rem; }

h1 { font-size: 1.4rem; margin: 0 0 0.25rem; overflow-wrap: anywhere; }

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

button, .button {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  cursor: pointer;
  line-height: 1.4;
}

button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; }

input[type="text"], input[type="search"], input[type="password"], select, textarea {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

textarea { font-family: var(--mono); font-size: 0.9rem; resize: vertical; tab-size: 4; }
code { font-family: var(--mono); font-size: 0.9em; }

.flash { padding: 0.6rem 0.9rem; border-radius: var(--radius); background: var(--ok-bg); }
.flash.error { background: var(--error-bg); }

.hint, .meta, .empty { color: var(--muted); }
.hint { font-size: 0.85rem; font-weight: normal; }
.meta { font-size: 0.9rem; margin: 0; }

.badge {
  display: inline-block;
  padding: 0 0.45rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  font-size: 0.8rem;
}
.badge.shared { color: var(--accent); border-color: var(--accent); }

.login { max-width: 22rem; margin: 4rem auto; display: grid; gap: 0.75rem; }

.search { margin-bottom: 1rem; flex-wrap: nowrap; }
.search input { flex: 1; }

.pastes { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); }
.pastes li + li { border-top: 1px solid var(--border); }
.pastes a { display: block; padding: 0.6rem 0.9rem; color: inherit; text-decoration: none; }
.pastes a:hover { background: var(--surface); }
.pastes .title { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pastes .meta { display: block; }

.pager { display: flex; justify-content: space-between; margin-top: 1rem; }

.paste-form { display: grid; gap: 1rem; }
.paste-form textarea { min-height: 40vh; }

.attach { display: grid; gap: 0.5rem; margin: 0; padding: 0.75rem; border: 1px dashed var(--border); border-radius: var(--radius); }
.attach legend { padding: 0 0.25rem; font-weight: 500; }
.attach .hint, .attach .flash { margin: 0; }
.paste-form.dropping .attach { border-color: var(--accent); background: var(--surface); }
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.file-list:empty { display: none; }
.file-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.file-list img { width: 3rem; height: 3rem; object-fit: cover; border: 1px solid var(--border); border-radius: 4px; }
.file-list .name { overflow-wrap: anywhere; }
.file-list .remove { font-size: 0.9rem; }
.fields { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 0.75rem; }
.fields label { display: grid; gap: 0.25rem; font-weight: 500; }

.paste > header { margin-bottom: 0.75rem; }
.toolbar { margin-bottom: 0.75rem; }
.share { margin-bottom: 0.75rem; }
.share label { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 0.25rem; }
.share-row input { flex: 1; min-width: 12rem; font-family: var(--mono); font-size: 0.85rem; }

.code { border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
.code .highlight { margin: 0; }
.code pre { margin: 0; padding: 0.75rem; font-family: var(--mono); font-size: 0.85rem; line-height: 1.45; }
.code table.highlighttable { border-collapse: collapse; width: 100%; }
.code td { padding: 0; vertical-align: top; }
.code td.linenos { width: 1%; border-right: 1px solid var(--border); background: var(--surface); user-select: none; }
.code td.linenos pre { text-align: right; color: var(--muted); }
.code td.linenos a { color: inherit; text-decoration: none; }
.code td.code { width: 99%; }

.attachments { display: grid; gap: 0.75rem; margin-top: 0.75rem; }
.attachment { margin: 0; }
.attachment img {
  display: block;
  max-width: 100%;
  max-height: 80vh;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.attachment figcaption, .attachment.file { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem; margin-top: 0.25rem; }
.attachment.file { margin: 0; padding: 0.6rem 0.9rem; border: 1px solid var(--border); border-radius: var(--radius); }
.attachment .name { overflow-wrap: anywhere; }

.error-page { text-align: center; margin-top: 3rem; }

.visually-hidden, .offscreen {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.offscreen { left: -9999px; }

@media (max-width: 40rem) {
  .fields { grid-template-columns: 1fr; }
  main { padding: 0.75rem; }
}
