/* ===== CSS Custom Properties ===== */
:root {
  --bg:        #0d0d0d;
  --surface:   #161616;
  --surface2:  #1e1e1e;
  --border:    #2a2a2a;
  --border2:   #333;
  --accent:    #4ade80;
  --accent-dim:#22c55e;
  --text:      #e2e2e2;
  --text-muted:#888;
  --text-dim:  #555;
  --danger:    #ef4444;
  --warning:   #f59e0b;
  --info:      #38bdf8;
  --radius:    6px;
  --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", ui-monospace, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

code, pre { font-family: var(--font-mono); }

/* ===== Header / Nav ===== */
header {
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
}

nav {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 46px;
}

.nav-logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.nav-links {
  display: flex;
  gap: 1rem;
}

.nav-links a {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.nav-links a:hover { color: var(--text); }

/* ===== Main ===== */
main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 1rem;
  color: var(--text-dim);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

footer a { color: var(--text-dim); }
footer a:hover { color: var(--text-muted); text-decoration: none; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover { background: var(--border2); text-decoration: none; }

.btn-primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
}

.btn-primary:hover { background: var(--accent-dim); border-color: var(--accent-dim); }

.btn-danger {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover { background: rgba(239,68,68,0.1); }

.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

/* ===== Alerts ===== */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.35);
  color: #fca5a5;
}

.alert-success {
  background: rgba(74,222,128,0.1);
  border: 1px solid rgba(74,222,128,0.35);
  color: #86efac;
}

/* ===== Editor ===== */
.editor-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.editor-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.tab-btn {
  padding: 0.55rem 1.1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.88rem;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

#content-editor {
  width: 100%;
  min-height: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.65;
  padding: 1rem;
  resize: vertical;
  outline: none;
  tab-size: 4;
}

#content-editor:focus { border-color: var(--border2); }

.char-counter {
  text-align: right;
  font-size: 0.75rem;
  color: var(--text-dim);
  padding: 0.25rem 0.5rem;
}

#tab-preview {
  min-height: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 1.5rem;
}

.preview-loading { color: var(--text-muted); font-style: italic; }

#tab-how {
  max-height: 520px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 1.5rem;
  background: var(--surface);
}

/* ===== Form Controls ===== */
.form-controls {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.form-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.input-group {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 200px;
}

.input-prefix {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-right: none;
  padding: 0.5rem 0.6rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-radius: var(--radius) 0 0 var(--radius);
  white-space: nowrap;
  height: 38px;
  line-height: 1;
  display: flex;
  align-items: center;
}

.input-group input {
  flex: 1;
  height: 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0 0.75rem;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s;
}

.input-group .input-prefix + input {
  border-radius: 0 var(--radius) var(--radius) 0;
}

.input-group input:focus { border-color: var(--border2); }

.url-status {
  margin-left: 0.5rem;
  font-size: 0.78rem;
  white-space: nowrap;
}

.url-status.ok    { color: var(--accent); }
.url-status.taken { color: var(--danger); }
.url-status.invalid { color: var(--warning); }

.form-submit {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.hint {
  font-size: 0.8rem;
  color: var(--text-dim);
}

kbd {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 3px;
  padding: 0.1em 0.4em;
  font-size: 0.78rem;
  font-family: var(--font-mono);
}

/* ===== View page ===== */
.entry-meta-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.entry-url { font-family: var(--font-mono); }
.entry-actions { margin-left: auto; display: flex; gap: 0.5rem; }

.edit-code-display {
  background: var(--surface2);
  padding: 0.15em 0.5em;
  border-radius: 4px;
  user-select: all;
  font-size: 0.95em;
}

.content-warning {
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.4);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

.nsfw-blur { filter: blur(20px); transition: filter 0.3s; }
.nsfw-blur:hover { filter: blur(0); }

/* ===== Edit page ===== */
.edit-heading {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.danger-zone {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(239,68,68,0.3);
}

.danger-zone h3 {
  font-size: 0.85rem;
  color: var(--danger);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===== Static pages ===== */
.static-page {
  max-width: 720px;
}

.static-page h1 { margin-bottom: 1rem; }
.static-page h2 { margin: 1.5rem 0 0.5rem; font-size: 1.1rem; }
.static-page p  { margin-bottom: 0.75rem; color: var(--text); }
.static-page ul, .static-page ol { padding-left: 1.5rem; margin-bottom: 0.75rem; }
.static-page li { margin-bottom: 0.25rem; }

.static-page table {
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.static-page th, .static-page td {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border2);
  text-align: left;
}

.static-page th { background: var(--surface2); color: var(--text-muted); }

/* ===== Cheatsheet ===== */
.cheatsheet h2 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1rem;
  color: var(--text);
}

.cs-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

.cs-table td {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  vertical-align: middle;
}

.cs-table td:first-child {
  background: var(--surface2);
  font-family: var(--font-mono);
  white-space: pre;
  width: 50%;
}

.cs-table pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

/* ===== Center message (404) ===== */
.center-message {
  text-align: center;
  padding: 4rem 1rem;
}

.center-message h1 { font-size: 4rem; color: var(--text-dim); }
.center-message p  { color: var(--text-muted); margin: 0.5rem 0 1.5rem; }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .form-row { flex-direction: column; }
  .input-group { min-width: 100%; }
  .entry-actions { margin-left: 0; }
}
