/* ─── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

/* ─── Tokens ─────────────────────────────────────────────── */
:root {
  --bg:           #faf8f4;
  --bg-card:      #ffffff;
  --ink:          #1c1b19;
  --ink-2:        #5a5754;
  --ink-3:        #a09d99;
  --accent:       #b5743a;
  --accent-hover: #9c6030;
  --rule:         #e6e2db;
  --danger:       #c94040;

  --f-display: 'Playfair Display', Georgia, serif;
  --f-body:    'Lora', Georgia, serif;
  --f-ui:      'DM Sans', system-ui, sans-serif;
}

html { font-size: 18px; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ─── Nav ────────────────────────────────────────────────── */
#main-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2.5rem;
  height: 60px;
}

.nav-logo {
  font-family: var(--f-display);
  font-size: 1.55rem;
  font-weight: 700;
  font-style: italic;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.nav-logo:hover { color: var(--ink-2); }

.nav-rule {
  height: 1px;
  background: var(--rule);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-user-name {
  font-family: var(--f-ui);
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--ink-2);
}

.btn-nav-write {
  font-family: var(--f-ui);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink);
  background: transparent;
  border: 1.5px solid var(--rule);
  border-radius: 100px;
  padding: 0.35rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  letter-spacing: 0.01em;
}
.btn-nav-write:hover { border-color: var(--ink-3); }

.btn-nav-signin {
  font-family: var(--f-ui);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--bg);
  background: var(--ink);
  border: none;
  border-radius: 100px;
  padding: 0.4rem 1.15rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-nav-signin:hover { background: var(--ink-2); }

.btn-nav-signout {
  font-family: var(--f-ui);
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--ink-3);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s;
}
.btn-nav-signout:hover { color: var(--ink); }

/* ─── Home ───────────────────────────────────────────────── */
#home-screen {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 2rem 5rem;
}

.home-hero {
  padding: 3.5rem 0 2.5rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 0;
}

.home-tagline {
  font-family: var(--f-display);
  font-size: 2.2rem;
  font-weight: 400;
  font-style: italic;
  color: var(--ink-2);
  line-height: 1.3;
}

/* ─── Article Card ───────────────────────────────────────── */
.articles-feed { }

.article-card {
  display: block;
  padding: 2rem 0;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: opacity 0.12s;
  text-decoration: none;
}
.article-card:hover { opacity: 0.65; }

.card-title {
  font-family: var(--f-display);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
  margin-bottom: 0.35rem;
}

.card-subtitle {
  font-family: var(--f-body);
  font-size: 0.95rem;
  font-style: italic;
  color: var(--ink-2);
  line-height: 1.55;
  margin-bottom: 0.9rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  font-family: var(--f-ui);
  font-size: 0.76rem;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.card-meta-dot { opacity: 0.5; }

/* ─── Article Page ───────────────────────────────────────── */
.article-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 3rem 2rem 6rem;
}

.article-back {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--f-ui);
  font-size: 0.8rem;
  color: var(--ink-3);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-bottom: 2.25rem;
  transition: color 0.15s;
}
.article-back:hover { color: var(--ink); }

.article-title {
  font-family: var(--f-display);
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 0.75rem;
}

.article-subtitle {
  font-family: var(--f-body);
  font-size: 1.2rem;
  font-style: italic;
  color: var(--ink-2);
  line-height: 1.5;
  margin-bottom: 2rem;
}

.article-byline {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1.25rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2.75rem;
}

.author-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--f-display);
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  user-select: none;
}

.byline-info { flex: 1; min-width: 0; }

.byline-name {
  font-family: var(--f-ui);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.3;
}

.byline-meta {
  font-family: var(--f-ui);
  font-size: 0.76rem;
  color: var(--ink-3);
  margin-top: 0.15rem;
}

.byline-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

.btn-edit {
  font-family: var(--f-ui);
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--ink-2);
  background: none;
  border: 1px solid var(--rule);
  border-radius: 100px;
  padding: 0.3rem 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-edit:hover { border-color: var(--ink-2); color: var(--ink); }

.btn-delete {
  font-family: var(--f-ui);
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--danger);
  background: none;
  border: 1px solid var(--rule);
  border-radius: 100px;
  padding: 0.3rem 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.btn-delete:hover { border-color: var(--danger); }

.article-body {
  font-family: var(--f-body);
  font-size: 1.05rem;
  line-height: 1.9;
  color: var(--ink);
}
.article-body p { margin-bottom: 1.5rem; }
.article-body p:last-child { margin-bottom: 0; }

/* ─── Editor ─────────────────────────────────────────────── */
#editor-screen {
  background: var(--bg-card);
  min-height: calc(100vh - 61px);
  border-top: none;
}

.editor-wrap {
  max-width: 740px;
  margin: 0 auto;
  padding: 0 2rem 4rem;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2.5rem;
}

.btn-ghost-sm {
  font-family: var(--f-ui);
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--ink-3);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  transition: color 0.15s;
}
.btn-ghost-sm:hover { color: var(--ink); }

.btn-publish {
  font-family: var(--f-ui);
  font-size: 0.82rem;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 100px;
  padding: 0.45rem 1.3rem;
  cursor: pointer;
  transition: background 0.15s;
  letter-spacing: 0.01em;
}
.btn-publish:hover { background: var(--accent-hover); }

.editor-title {
  display: block;
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--f-display);
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  margin-bottom: 0.6rem;
}
.editor-title::placeholder { color: var(--rule); }

.editor-subtitle {
  display: block;
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--f-body);
  font-size: 1.15rem;
  font-style: italic;
  color: var(--ink-2);
  margin-bottom: 0;
}
.editor-subtitle::placeholder { color: var(--ink-3); font-style: italic; }

.editor-divider {
  height: 1px;
  background: var(--rule);
  margin: 1.5rem 0;
}

.editor-body {
  display: block;
  width: 100%;
  min-height: 55vh;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--f-body);
  font-size: 1.05rem;
  line-height: 1.9;
  color: var(--ink);
  resize: none;
}
.editor-body::placeholder { color: var(--ink-3); }

/* ─── Login ──────────────────────────────────────────────── */
#login-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex !important;
  align-items: center;
  justify-content: center;
}
#login-screen[hidden] { display: none !important; }

.login-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 27, 25, 0.55);
  backdrop-filter: blur(5px);
}

.login-card {
  position: relative;
  background: var(--bg-card);
  border-radius: 14px;
  padding: 3rem 2.5rem 2.5rem;
  width: min(400px, calc(100vw - 2rem));
  text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.06);
}

.login-logo {
  font-family: var(--f-display);
  font-size: 2.1rem;
  font-weight: 700;
  font-style: italic;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin-bottom: 0.4rem;
}

.login-sub {
  font-family: var(--f-ui);
  font-size: 0.85rem;
  font-weight: 300;
  color: var(--ink-3);
  margin-bottom: 2rem;
}

#gsi-button {
  display: flex;
  justify-content: center;
}

.login-error {
  font-family: var(--f-ui);
  font-size: 0.8rem;
  color: var(--danger);
  margin-top: 1rem;
}

/* ─── Empty ──────────────────────────────────────────────── */
.empty-state {
  font-family: var(--f-body);
  font-style: italic;
  color: var(--ink-3);
  text-align: center;
  padding: 4rem 0;
  font-size: 0.95rem;
}

/* ─── Author bar (below article body) ───────────────────── */
.author-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 3rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--rule);
}

.author-bar-label {
  font-family: var(--f-ui);
  font-size: 0.8rem;
  color: var(--ink-3);
  flex: 1;
}

.btn-author-edit {
  font-family: var(--f-ui);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-2);
  background: none;
  border: 1.5px solid var(--rule);
  border-radius: 100px;
  padding: 0.45rem 1.1rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-author-edit:hover { border-color: var(--ink-2); color: var(--ink); }

.btn-author-delete {
  font-family: var(--f-ui);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--danger);
  background: none;
  border: 1.5px solid var(--rule);
  border-radius: 100px;
  padding: 0.45rem 1.1rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.btn-author-delete:hover { border-color: var(--danger); }

/* ─── Card author actions (home feed) ────────────────────── */
.card-author-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.btn-card-edit {
  font-family: var(--f-ui);
  font-size: 0.73rem;
  font-weight: 500;
  color: var(--ink-3);
  background: none;
  border: 1px solid var(--rule);
  border-radius: 100px;
  padding: 0.25rem 0.7rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-card-edit:hover { color: var(--ink); border-color: var(--ink-3); }

.btn-card-delete {
  font-family: var(--f-ui);
  font-size: 0.73rem;
  font-weight: 500;
  color: var(--danger);
  background: none;
  border: 1px solid var(--rule);
  border-radius: 100px;
  padding: 0.25rem 0.7rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.btn-card-delete:hover { border-color: var(--danger); }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 600px) {
  #main-nav { padding: 0 1.25rem; }
  #home-screen { padding: 0 1.25rem 4rem; }
  .home-tagline { font-size: 1.7rem; }
  .article-container { padding: 2rem 1.25rem 4rem; }
  .editor-wrap { padding: 0 1.25rem 4rem; }
  .article-title { font-size: 1.9rem; }
  .editor-title { font-size: 1.8rem; }
  .article-byline { flex-wrap: wrap; gap: 0.65rem; }
  .byline-actions { width: 100%; justify-content: flex-start; }
}
