/* Namu BBS — web frontend stylesheet */

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #22263a;
  --border:    #2e3347;
  --accent:    #7c9ef8;
  --accent-dim:#4a6ab5;
  --danger:    #e05c5c;
  --success:   #5cb85c;
  --warning:   #e0a040;
  --text:      #c9d1e0;
  --text-dim:  #6b7590;
  --text-bright:#eef1f8;
  --font:      "JetBrains Mono", "Fira Code", "Cascadia Code", ui-monospace,
               "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  --radius:    4px;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 15px; }

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

/* ── Navigation ────────────────────────────────────────────────────────── */

nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 3rem;
  flex-shrink: 0;
}

nav .brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.05em;
}

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

nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}

nav a:hover, nav a.active {
  color: var(--text-bright);
  background: var(--surface2);
}

.logout-form { margin: 0; }

nav .nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-left: auto;
}

nav .nav-user span { color: var(--accent); }

/* ── Main content ──────────────────────────────────────────────────────── */

main {
  flex: 1;
  padding: 1.5rem;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}

h1, h2, h3 {
  color: var(--text-bright);
  font-weight: 600;
  margin-top: 0;
}

h1 { font-size: 1.4rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

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

/* ── Flash messages ────────────────────────────────────────────────────── */

.flash {
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  border: 1px solid;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.flash.error   { background: #2a1010; border-color: var(--danger);  color: #f0a0a0; }
.flash.success { background: #0f2010; border-color: var(--success); color: #90d090; }
.flash.warning { background: #201800; border-color: var(--warning); color: #d0a060; }

/* ── Forms ─────────────────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 1rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 0.45rem 0.7rem;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent-dim);
}

textarea {
  resize: vertical;
  min-height: 5rem;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */

.btn {
  display: inline-block;
  padding: 0.45rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: var(--font);
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

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

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}
.btn-ghost:hover { border-color: var(--text-dim); color: var(--text); }

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm    { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.btn-block { display: block; width: 100%; margin-top: 0.5rem; }

/* ── Tables ────────────────────────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 500;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
}

td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: var(--surface2); }

/* ── Cards / panels ────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

/* ── Login page ────────────────────────────────────────────────────────── */

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2.5rem;
  width: 100%;
  max-width: 380px;
}

.login-box h1 {
  font-size: 1.3rem;
  text-align: center;
  border: none;
  margin-bottom: 1.5rem;
  color: var(--accent);
}

/* ── Badges ────────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 500;
}
.badge-admin   { background: #1a1040; color: #a080f0; border: 1px solid #4030a0; }
.badge-user    { background: var(--surface2); color: var(--text-dim); border: 1px solid var(--border); }
.badge-active  { background: #0f2010; color: #70c070; border: 1px solid #305030; }
.badge-locked  { background: #2a1010; color: #e07070; border: 1px solid #803030; }

/* ── HTMX loading indicator ────────────────────────────────────────────── */

.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

/* ── Utility ────────────────────────────────────────────────────────────── */

.text-dim    { color: var(--text-dim); }
.text-danger { color: var(--danger); }
.text-right  { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.align-center { align-items: center; }
.form-inline { display: inline; }
.breadcrumb { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 0.5rem; }
.page-titlebar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.alias-note  { color: var(--text-dim); font-size: 0.85rem; margin-top: -0.5rem; }
.post-count  { color: var(--text-dim); font-size: 0.8rem; margin-top: 1rem; }
.fingerprint { font-size: 0.8rem; }
.reply-context {
  font-size: 0.85rem;
  margin-bottom: 1rem;
  color: var(--text-dim);
}
.card-narrow { max-width: 420px; }
.card-medium { max-width: 600px; }
.card-form   { max-width: 700px; }

/* ── Settings sub-nav ───────────────────────────────────────────────────────── */

.settings-nav {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.settings-nav a {
  padding: 0.5rem 1rem;
  color: var(--text-dim);
  font-size: 0.9rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 0;
}

.settings-nav a:hover { color: var(--text); text-decoration: none; background: none; }
.settings-nav a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Post list ──────────────────────────────────────────────────────────────── */

.post-num { color: var(--text-dim); font-size: 0.8rem; width: 3rem; }
.post-title a { color: var(--text); }
.post-title a:hover { color: var(--accent); text-decoration: none; }
.post-author { color: var(--text-dim); font-size: 0.85rem; width: 8rem; }
.post-date { color: var(--text-dim); font-size: 0.8rem; width: 11rem; white-space: nowrap; }

.pagination {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.pagination a { color: var(--accent); }

/* ── Post view ──────────────────────────────────────────────────────────────── */

.post-header {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.post-meta {
  display: flex;
  gap: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 0.3rem;
}

.post-content {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
  line-height: 1.7;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.post-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.replies-section { margin-top: 2rem; }
.replies-section h2 { font-size: 1rem; color: var(--text-dim); }

.reply {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

.reply-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}

.reply-content {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
  line-height: 1.6;
}

.reply-form { margin-top: 1.5rem; }
.reply-form h2 { font-size: 1rem; }

/* ── Admin ──────────────────────────────────────────────────────────────────── */

.admin-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}

.admin-search {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

.admin-search input[type="text"] {
  max-width: 280px;
}

/* ── Board tree (dashboard) ────────────────────────────────────────────── */

.board-tree { margin: 0; padding: 0; }

.board-dir {
  margin-bottom: 1.5rem;
}

.board-dir-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.board-dir-icon { opacity: 0.6; }

.board-leaf-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.board-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

.board-item:hover {
  border-color: var(--accent-dim);
  background: var(--surface2);
  color: var(--text-bright);
}

.board-item-icon { color: var(--accent-dim); flex-shrink: 0; }
.board-item-name { font-size: 0.9rem; }

.board-nested { padding-left: 1.25rem; margin-top: 0.75rem; }

.board-empty {
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 2rem 0;
  text-align: center;
}

/* ── Keyboard key ───────────────────────────────────────────────────────────── */

kbd {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  font-family: var(--font);
  font-size: 0.75em;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-dim);
  vertical-align: baseline;
}

/* ── Read New ───────────────────────────────────────────────────────────────── */

.rn-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.rn-board-path {
  color: var(--accent);
  font-weight: 600;
}

.rn-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.rn-num {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
}

.rn-title {
  margin-bottom: 0.4rem;
  font-size: 1.15rem;
  border: none;
  padding: 0;
}

.rn-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.rn-preview {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
  max-height: 16rem;
  overflow: hidden;
}

.rn-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  align-items: center;
}

.rn-hint {
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

.rn-done {
  text-align: center;
  padding: 3rem 0;
}

.rn-done-icon {
  font-size: 1.5rem;
  color: var(--success);
  margin-bottom: 0.5rem;
  font-weight: 700;
}
