:root {
  --bg: #140b07;
  --bg2: #1c100a;
  --card: #23140d;
  --line: #5a2a12;
  --text: #ffe8c8;
  --muted: #c9a07a;
  --flame: #ff6a1a;
  --ember: #ff9a2f;
  --cream: #ffe0a3;
  --belly: #fff1cf;
  --ink: #2a1208;
  --body-text: #f3d7b3;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background:
    radial-gradient(circle at 15% -10%, rgba(255,106,26,.28), transparent 32%),
    radial-gradient(circle at 90% 0%, rgba(255,154,47,.16), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "PingFang TC", "Noto Sans TC", sans-serif;
  min-height: 100vh;
}

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 2px;
}

/* —— Ticker —— */
.ticker-wrap {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(90deg, #2a1208, #4a1d0a 40%, #2a1208);
  border-bottom: 1px solid #7a3a14;
  overflow: hidden; height: 46px;
  display: flex; align-items: center;
}
.ticker {
  display: flex; width: max-content;
  animation: marquee 32s linear infinite;
  white-space: nowrap; font-weight: 800;
}
.ticker:hover { animation-play-state: paused; }
.ticker span {
  display: inline-flex; align-items: center;
  gap: 10px; padding: 0 22px; font-size: 15px;
}
.code {
  color: var(--ink); background: var(--cream);
  padding: 2px 10px; border-radius: 999px; font-weight: 800;
}
.dot { color: var(--ember); }
@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* —— Nav —— */
nav {
  max-width: 980px; margin: 0 auto;
  padding: 16px 20px 0;
  display: flex; align-items: center;
  justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 900; letter-spacing: .04em;
  text-decoration: none; color: var(--text);
}
.logo-flame {
  font-size: 22px;
  filter: drop-shadow(0 0 8px rgba(255,106,26,.8));
}
.nav-links { display: flex; gap: 8px; flex-wrap: wrap; }
.nav-links a {
  text-decoration: none;
  border: 1px solid var(--line);
  background: rgba(255,106,26,.08);
  color: var(--cream);
  padding: 8px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 700;
  transition: background .2s, color .2s, border-color .2s;
}
.nav-links a.active,
.nav-links a:hover {
  background: linear-gradient(180deg, var(--ember), var(--flame));
  color: var(--ink); border-color: transparent;
}

/* —— Header / page hero —— */
header, .page-header {
  max-width: 980px; margin: 0 auto;
  padding: 36px 20px 8px;
}
.badge {
  display: inline-block; font-size: 12px; letter-spacing: .14em;
  color: var(--cream); border: 1px solid var(--line);
  padding: 6px 10px; border-radius: 999px; margin-bottom: 16px;
  background: rgba(255,106,26,.1);
}
h1 {
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.2; margin-bottom: 12px;
}
.lead {
  color: var(--muted); font-size: 18px; line-height: 1.7;
}

/* —— Firm cards —— */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px; padding: 24px 20px 48px;
  max-width: 980px; margin: 0 auto;
}
.card {
  background: linear-gradient(180deg, #2b160d, #1a0e08);
  border: 1px solid var(--line);
  border-radius: 18px; padding: 22px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 0 0 1px rgba(255,154,47,.08), 0 10px 30px rgba(0,0,0,.25);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.card:hover {
  transform: translateY(-3px);
  border-color: #7a3a14;
  box-shadow: 0 0 0 1px rgba(255,154,47,.18), 0 14px 36px rgba(0,0,0,.35);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand img {
  width: 48px; height: 48px; border-radius: 12px;
  background: #140b07; object-fit: contain; padding: 6px;
  border: 1px solid var(--line);
}
.brand h2 { font-size: 20px; }
.meta { color: var(--muted); font-size: 14px; line-height: 1.6; }
.actions {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; border: 0; cursor: pointer;
  padding: 10px 14px; border-radius: 999px;
  font-weight: 800; font-size: 14px;
  font-family: inherit;
  transition: filter .15s, transform .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.98); }
.btn-gold {
  background: linear-gradient(180deg, #ffb347, #ff6a1a);
  color: var(--ink);
}
.btn-ghost {
  background: transparent; color: var(--cream);
  border: 1px solid var(--line);
}
.btn-ghost:hover {
  background: rgba(255,106,26,.12);
}

.note {
  max-width: 980px; margin: 0 auto 28px;
  color: var(--muted); font-size: 13px; line-height: 1.7;
  padding: 0 20px;
}
footer {
  text-align: center; color: var(--muted);
  font-size: 13px; padding-bottom: 40px;
}

.toast {
  position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #3a1a0c; color: var(--cream);
  border: 1px solid var(--ember);
  padding: 10px 16px; border-radius: 999px;
  opacity: 0; transition: .25s ease;
  z-index: 100; pointer-events: none;
}
.toast.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
}

/* —— Guides list —— */
.toolbar {
  max-width: 980px; margin: 0 auto;
  padding: 16px 20px 0;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
}
.toolbar input,
.toolbar select,
.form-field input,
.form-field select,
.form-field textarea {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
}
.toolbar input { flex: 1; min-width: 180px; }
.toolbar select { min-width: 120px; }
.guides-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px; padding: 24px 20px 48px;
  max-width: 980px; margin: 0 auto;
}
.guide-card {
  background: linear-gradient(180deg, #2b160d, #1a0e08);
  border: 1px solid var(--line);
  border-radius: 18px; padding: 22px;
  display: flex; flex-direction: column; gap: 12px;
  text-decoration: none; color: inherit;
  box-shadow: 0 0 0 1px rgba(255,154,47,.08), 0 10px 30px rgba(0,0,0,.25);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.guide-card:hover {
  transform: translateY(-3px);
  border-color: #7a3a14;
  box-shadow: 0 0 0 1px rgba(255,154,47,.18), 0 14px 36px rgba(0,0,0,.35);
}
.guide-card h2 {
  font-size: 18px; line-height: 1.4;
}
.guide-card .excerpt {
  color: var(--muted); font-size: 14px; line-height: 1.7;
  flex: 1;
}
.guide-card .guide-meta {
  color: var(--muted); font-size: 13px;
}
.empty-state {
  max-width: 980px; margin: 0 auto;
  padding: 40px 20px; text-align: center; color: var(--muted);
}

/* —— Article / post —— */
.progress-bar {
  position: fixed; top: 0; left: 0; height: 3px;
  background: linear-gradient(90deg, var(--ember), var(--flame));
  width: 0; z-index: 60; transition: width .1s linear;
}
article.post {
  max-width: 800px; margin: 0 auto;
  padding: 36px 20px 72px;
}
article.post a { color: var(--ember); }
article.post .badge { margin-bottom: 16px; }
article.post h1 {
  font-size: clamp(28px, 5vw, 40px);
  line-height: 1.25; margin-bottom: 12px;
}
article.post .meta {
  color: var(--muted); margin-bottom: 28px; font-size: 14px;
}
article.post h2 {
  font-size: 22px; margin: 28px 0 10px; color: var(--text);
}
article.post p,
article.post li {
  color: var(--body-text); line-height: 1.9;
}
article.post p { margin: 0 0 14px; }
article.post ul {
  padding-left: 20px; margin-bottom: 16px;
}
.callout {
  border: 1px solid var(--line); border-radius: 16px;
  padding: 16px 18px; margin: 20px 0;
  background: rgba(255,106,26,.08);
  color: var(--body-text); line-height: 1.8;
}
.code-chip {
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; border: 0; font-family: inherit;
  color: var(--ink); background: var(--cream);
  padding: 2px 10px; border-radius: 999px; font-weight: 800;
  font-size: 14px;
}
.code-chip:hover { filter: brightness(1.05); }
a.back, .back {
  display: inline-block; margin-top: 28px;
  color: #2a1208 !important;
  text-decoration: none; font-weight: 800;
  background: linear-gradient(180deg, #ffb347, #ff6a1a);
  padding: 10px 16px; border-radius: 999px;
  border: 0;
}
a.back:visited, a.back:hover, a.back:active, .back:hover {
  color: #2a1208 !important;
  filter: brightness(1.06);
}

/* —— Admin —— */
.admin-wrap {
  max-width: 1100px; margin: 0 auto;
  padding: 24px 20px 64px;
}
.gate {
  max-width: 400px; margin: 60px auto;
  padding: 28px;
  background: linear-gradient(180deg, #2b160d, #1a0e08);
  border: 1px solid var(--line); border-radius: 18px;
  display: flex; flex-direction: column; gap: 14px;
}
.gate h2 { font-size: 22px; }
.gate p { color: var(--muted); font-size: 14px; line-height: 1.6; }
.gate input {
  background: var(--card); border: 1px solid var(--line);
  color: var(--text); border-radius: 12px;
  padding: 12px 14px; font-size: 15px; font-family: inherit;
}
.admin-panel { display: none; }
.admin-panel.visible { display: block; }
.tabs {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px;
}
.tab-btn {
  border: 1px solid var(--line);
  background: rgba(255,106,26,.08);
  color: var(--cream); padding: 8px 14px;
  border-radius: 999px; font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: inherit;
}
.tab-btn.active {
  background: linear-gradient(180deg, var(--ember), var(--flame));
  color: var(--ink); border-color: transparent;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.editor-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 860px) {
  .editor-layout { grid-template-columns: 1fr; }
}
.form-card {
  background: linear-gradient(180deg, #2b160d, #1a0e08);
  border: 1px solid var(--line);
  border-radius: 18px; padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
}
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label {
  font-size: 13px; font-weight: 700; color: var(--cream);
}
.form-field textarea {
  min-height: 180px; resize: vertical; line-height: 1.6;
}
.form-actions {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px;
}
.preview-box {
  background: linear-gradient(180deg, #2b160d, #1a0e08);
  border: 1px solid var(--line);
  border-radius: 18px; padding: 20px;
  max-height: 70vh; overflow: auto;
}
.preview-box .post-preview h1 {
  font-size: 26px; margin-bottom: 8px;
}
.preview-box .post-preview h2 {
  font-size: 18px; margin: 18px 0 8px;
}
.preview-box .post-preview p,
.preview-box .post-preview li {
  color: var(--body-text); line-height: 1.8; font-size: 14px;
}
.preview-box .post-preview ul {
  padding-left: 18px; margin-bottom: 12px;
}
.output-box {
  margin-top: 16px;
  background: #0f0805;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--cream);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 240px;
  overflow: auto;
}
.hint {
  color: var(--muted); font-size: 13px; line-height: 1.6;
}
.logout-row {
  display: flex; justify-content: flex-end; margin-bottom: 12px;
}

@media (max-width: 560px) {
  .ticker span { font-size: 13px; padding: 0 14px; }
  h1 { font-size: clamp(24px, 7vw, 32px); }
  .lead { font-size: 16px; }
  .grid, .guides-grid { padding: 16px 14px 40px; gap: 12px; }
  .card, .guide-card { padding: 18px; }
  nav { padding: 12px 14px 0; }
  header, .page-header { padding: 24px 14px 8px; }
  .actions .btn { flex: 1; min-width: 120px; }
}


/* —— Comments —— */
#comments-mount {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 20px;
  box-sizing: border-box;
}
.comments {
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 8px 0 72px;
  box-sizing: border-box;
}
.comments-card {
  background: linear-gradient(180deg, #2b160d, #1a0e08);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 18px 16px;
  box-shadow: 0 0 0 1px rgba(255,154,47,.06), 0 10px 30px rgba(0,0,0,.22);
  margin: 0 auto;
}
.comments-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding-bottom: 12px; margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.comments-head h2 {
  font-size: 20px; margin: 0; display: flex; align-items: baseline; gap: 10px;
}
.comments-count { color: var(--muted); font-size: 14px; font-weight: 600; }
.comments-sort {
  background: var(--card); border: 1px solid var(--line);
  color: var(--cream); border-radius: 999px;
  padding: 8px 12px; font-size: 13px; font-family: inherit; font-weight: 700;
}
.comment-compose {
  border: 1px solid var(--line);
  background: rgba(20,11,7,.55);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 16px;
}
.comment-compose textarea {
  width: 100%; min-height: 88px; resize: vertical;
  background: transparent; border: 0; outline: none;
  color: var(--text); font-size: 15px; font-family: inherit; line-height: 1.6;
  box-sizing: border-box;
}
.comment-compose-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 8px; flex-wrap: wrap;
}
.comment-name {
  flex: 1; min-width: 140px;
  background: var(--card); border: 1px solid var(--line);
  color: var(--text); border-radius: 999px;
  padding: 8px 12px; font-size: 13px; font-family: inherit;
  box-sizing: border-box;
}
.comment-list { display: flex; flex-direction: column; gap: 12px; }
.comment-item {
  border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
  background: rgba(255,106,26,.05);
}
.comment-meta { color: var(--muted); font-size: 13px; margin-bottom: 6px; font-weight: 700; }
.comment-body { color: var(--body-text); line-height: 1.7; white-space: pre-wrap; }
.comment-status { color: var(--muted); font-size: 13px; margin-top: 8px; min-height: 1.2em; text-align: center; }
.comment-empty {
  color: var(--muted); font-size: 14px; text-align: center;
  padding: 22px 12px; border: 1px dashed var(--line); border-radius: 14px;
  margin: 0;
}

.comment-meta-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 6px;
}
.comment-delete {
  border: 1px solid var(--line);
  background: rgba(255,80,40,.12);
  color: #ffb3a0;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
}
.comment-delete:hover { background: rgba(255,80,40,.22); }

.publish-status {
  margin: 10px 0 0;
  min-height: 1.4em;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  white-space: pre-wrap;
}
.publish-status.is-pending { color: #ffd08a; }
.publish-status.is-ok { color: #7dffa6; }
.publish-status.is-error { color: #ff9b8a; }

.manage-posts-list { display: flex; flex-direction: column; gap: 10px; }
.manage-post-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px;
  background: rgba(0,0,0,.18);
}
.manage-post-main { min-width: 0; }
.manage-post-main strong { display: block; margin: 6px 0 4px; font-size: 16px; }
.manage-post-actions { display: flex; gap: 8px; flex-shrink: 0; }
@media (max-width: 720px) {
  .manage-post-item { flex-direction: column; align-items: stretch; }
  .manage-post-actions { justify-content: flex-end; }
}
