:root {
  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --bg-inset: #f6f8fa;
  --fg: #1f2328;
  --fg-muted: #59636e;
  --border: #d1d9e0;
  --border-muted: #d1d9e0b3;
  --accent: #0969da;
  --accent-subtle: #ddf4ff;
  --success: #1f883d;
  --success-hover: #1c8139;
  --danger: #d1242f;
  --danger-subtle: #ffebe9;
  --warn-bg: #fff8c5;
  --warn-border: #d4a72c66;
  --header-bg: #1f2328;
  --header-fg: #ffffff;
  --btn-bg: #f6f8fa;
  --btn-hover: #eff2f5;
  --line-num: #59636e;
  --shadow: 0 1px 0 rgba(31,35,40,.04);
  --overlay-shadow: 0 8px 24px rgba(66,74,83,.12), 0 1px 3px rgba(31,35,40,.12);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --bg-subtle: #151b23;
    --bg-inset: #010409;
    --fg: #f0f6fc;
    --fg-muted: #9198a1;
    --border: #3d444d;
    --border-muted: #3d444db3;
    --accent: #4493f8;
    --accent-subtle: #388bfd1a;
    --success: #238636;
    --success-hover: #29903b;
    --danger: #f85149;
    --danger-subtle: #f851491a;
    --warn-bg: #bb800926;
    --warn-border: #bb800966;
    --header-bg: #010409;
    --btn-bg: #212830;
    --btn-hover: #262c36;
    --line-num: #9198a1;
    --overlay-shadow: 0 8px 24px rgba(1,4,9,.8);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { width: 100%; max-width: 1012px; margin: 0 auto; padding: 0 16px; }
main.container { flex: 1; padding-top: 24px; padding-bottom: 40px; }

/* ---------- header ---------- */
.topbar { background: var(--header-bg); color: var(--header-fg); }
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--header-fg); font-size: 16px; }
.brand:hover { text-decoration: none; opacity: .85; }
.brand svg { color: #f2cc60; }
.topnav { display: flex; gap: 16px; flex: 1; }
.topnav a { color: var(--header-fg); font-weight: 600; }
.topnav a:hover { color: #ffffffb3; text-decoration: none; }
.btn-new {
  color: var(--header-fg); display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 6px; border: 1px solid #ffffff33;
}
.btn-new:hover { background: #ffffff1a; text-decoration: none; }

.notice {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 16px; font-size: 13px;
  background: var(--warn-bg); border-bottom: 1px solid var(--warn-border); color: var(--fg);
  text-align: center;
}

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 6px;
  font: 500 14px/1 var(--sans); white-space: nowrap; cursor: pointer;
  background: var(--btn-bg); color: var(--fg);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.btn:hover { background: var(--btn-hover); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-primary { background: var(--success); color: #fff; border-color: #1f232826; }
.btn-primary:hover { background: var(--success-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-icon { width: 32px; padding: 0; justify-content: center; }
.btn-group { display: inline-flex; }
.btn-group .btn:first-child { border-radius: 6px 0 0 6px; }
.btn-group .btn:last-child { border-radius: 0 6px 6px 0; margin-left: -1px; padding: 0 8px; }
.btn svg { flex: none; }

.input {
  width: 100%; height: 32px; padding: 5px 12px; border-radius: 6px;
  font: 14px/20px var(--sans); color: var(--fg);
  background: var(--bg); border: 1px solid var(--border);
}
.input:focus, .editor:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

/* ---------- dropdown ---------- */
.dropdown { position: relative; }
.menu {
  position: absolute; right: 0; bottom: calc(100% + 4px); z-index: 10; width: 300px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--overlay-shadow); padding: 8px; display: none;
}
.menu.open { display: block; }
.menu button {
  display: flex; gap: 8px; width: 100%; text-align: left; padding: 8px; border-radius: 6px;
  border: 0; background: none; color: var(--fg); cursor: pointer; font: inherit;
}
.menu button:hover { background: var(--btn-hover); }
.menu .check { width: 16px; flex: none; visibility: hidden; }
.menu button[aria-checked="true"] .check { visibility: visible; }
.menu small { display: block; color: var(--fg-muted); font-size: 12px; }

/* ---------- create / edit ---------- */
.page-title { font-size: 20px; font-weight: 600; margin: 0 0 4px; }
.page-sub { color: var(--fg-muted); margin: 0 0 16px; }
.form-desc { margin-bottom: 16px; }
.file-box { border: 1px solid var(--border); border-radius: 6px; margin-bottom: 16px; background: var(--bg); }
.file-box-head {
  display: flex; align-items: center; gap: 8px; padding: 8px;
  background: var(--bg-subtle); border-bottom: 1px solid var(--border); border-radius: 6px 6px 0 0;
}
.file-box-head .input { max-width: 340px; }
.file-box-head .spacer { flex: 1; }
.file-box-head select.input { width: auto; padding-right: 28px; }
.editor-wrap { display: flex; font: 12px/20px var(--mono); }
.editor-gutter {
  padding: 10px 8px 10px 16px; text-align: right; color: var(--line-num);
  user-select: none; min-width: 48px; white-space: pre; overflow: hidden;
  border-right: 1px solid var(--border-muted);
}
.editor {
  flex: 1; display: block; width: 100%; min-height: 300px; padding: 10px 12px; margin: 0;
  border: 0; border-radius: 0 0 6px 0; resize: vertical;
  font: inherit; color: var(--fg); background: var(--bg); tab-size: 4;
  white-space: pre; overflow: auto;
}
.form-actions { display: flex; align-items: center; gap: 8px; justify-content: space-between; flex-wrap: wrap; }
.form-actions .right { display: flex; gap: 8px; margin-left: auto; }
.hint { color: var(--fg-muted); font-size: 12px; }
kbd {
  font: 11px var(--mono); padding: 2px 5px; border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: 6px; background: var(--bg-subtle);
}

/* ---------- gist view ---------- */
.gist-head {
  display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap;
  padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--border);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 16px;
  background: var(--accent-subtle); color: var(--accent);
}
.gist-title { flex: 1; min-width: 0; }
.gist-title h1 { font-size: 20px; font-weight: 400; margin: 0; word-break: break-all; }
.gist-title h1 b { font-weight: 600; }
.gist-meta { color: var(--fg-muted); font-size: 12px; margin-top: 2px; }
.gist-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.label {
  display: inline-block; padding: 0 7px; border: 1px solid var(--border); border-radius: 2em;
  font-size: 12px; font-weight: 500; line-height: 18px; color: var(--fg-muted); vertical-align: middle; margin-left: 6px;
}
.gist-desc { margin: 0 0 16px; }

.timer {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; margin-bottom: 16px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg-subtle);
}
.timer-clock { font: 600 20px/1 var(--mono); font-variant-numeric: tabular-nums; }
.timer-bar { flex: 1; height: 8px; border-radius: 4px; background: var(--border-muted); overflow: hidden; }
.timer-fill { height: 100%; background: var(--success); transition: width 1s linear, background .3s; }
.timer.low .timer-fill { background: #d4a72c; }
.timer.critical .timer-fill { background: var(--danger); }
.timer.critical .timer-clock { color: var(--danger); }

.share-row { display: flex; gap: 8px; margin-bottom: 16px; }
.share-row .input { font-family: var(--mono); font-size: 12px; background: var(--bg-subtle); }

.file { border: 1px solid var(--border); border-radius: 6px; margin-bottom: 16px; overflow: hidden; }
.file-head {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 16px;
  background: var(--bg-subtle); border-bottom: 1px solid var(--border);
}
.file-name { font: 600 12px var(--mono); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name a { color: var(--fg); }
.file-size { color: var(--fg-muted); font-size: 12px; }
.code { overflow: auto; background: var(--bg); }
.code table { border-collapse: collapse; font: 12px/20px var(--mono); width: 100%; }
.code td { padding: 0; vertical-align: top; }
.code td.ln {
  width: 1%; min-width: 50px; padding: 0 10px 0 16px; text-align: right;
  color: var(--line-num); user-select: none; cursor: pointer;
}
.code td.ln:hover { color: var(--fg); }
.code td.lc { padding: 0 16px 0 10px; white-space: pre; }
.code tr:first-child td { padding-top: 8px; }
.code tr:last-child td { padding-bottom: 8px; }
.code tr.hl td { background: #f2cc6033; }
.code .hljs { background: transparent; padding: 0; }
.markdown { padding: 24px 32px; overflow-wrap: anywhere; }
.markdown > :first-child { margin-top: 0; }
.markdown pre { background: var(--bg-subtle); padding: 16px; border-radius: 6px; overflow: auto; font: 12px/1.45 var(--mono); }
.markdown code { font-family: var(--mono); font-size: 85%; background: var(--bg-subtle); padding: .2em .4em; border-radius: 6px; }
.markdown pre code { background: none; padding: 0; font-size: 100%; }
.markdown img { max-width: 100%; }
.markdown table { border-collapse: collapse; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 6px 13px; }
.markdown h1, .markdown h2 { border-bottom: 1px solid var(--border-muted); padding-bottom: .3em; }

/* ---------- list ---------- */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button {
  border: 0; background: none; color: var(--fg); font: inherit; cursor: pointer;
  padding: 8px 12px; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button[aria-selected="true"] { border-bottom-color: #fd8c73; font-weight: 600; }
.tabs .count {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 2em;
  background: var(--border-muted); font-size: 12px; font-weight: 500; line-height: 18px; text-align: center;
}
.gist-item { padding: 16px 0; border-bottom: 1px solid var(--border-muted); }
.gist-item:last-child { border-bottom: 0; }
.gist-item-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.gist-item-head a { font-weight: 600; }
.gist-item .gist-desc-sm { color: var(--fg-muted); font-size: 12px; margin-bottom: 8px; }
.gist-item pre {
  margin: 0; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
  font: 12px/20px var(--mono); max-height: 180px; overflow: hidden; background: var(--bg);
}
.gist-item pre code.hljs { padding: 0; background: transparent; }
.ttl { color: var(--fg-muted); font-size: 12px; margin-left: auto; font-variant-numeric: tabular-nums; }

.blank {
  text-align: center; padding: 48px 24px; border: 1px solid var(--border); border-radius: 6px;
  color: var(--fg-muted);
}
.blank h2 { color: var(--fg); font-size: 20px; margin: 8px 0; }
.blank .big { font-size: 40px; }

.alert { padding: 12px 16px; border: 1px solid var(--danger); background: var(--danger-subtle); border-radius: 6px; margin-bottom: 16px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100;
  background: var(--fg); color: var(--bg); padding: 8px 16px; border-radius: 6px;
  box-shadow: var(--overlay-shadow); font-weight: 500; max-width: calc(100% - 32px);
}

.footer { color: var(--fg-muted); font-size: 12px; padding-top: 24px; padding-bottom: 24px; border-top: 1px solid var(--border-muted); text-align: center; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (max-width: 640px) {
  .topnav a { font-size: 13px; }
  .file-box-head { flex-wrap: wrap; }
  .file-box-head .input { max-width: none; flex: 1 1 100%; }
  .editor-gutter { display: none; }
  .gist-actions { width: 100%; }
  .markdown { padding: 16px; }
  .menu { width: min(300px, calc(100vw - 32px)); }
}

[hidden] { display: none !important; }
.ico { display: inline-flex; }
.avatar-sm { width: 20px; height: 20px; font-size: 11px; }
.preview-link, .preview-link:hover { display: block; color: inherit; text-decoration: none; }
.preview-link:hover pre { border-color: var(--accent); }
