:root {
  --mono: "Space Mono", monospace;
  --serif: "Lora", serif;
  --sans: "Inter", sans-serif;
  --t: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --container-width: 820px;
}
[data-theme="dark"] {
  --bg: #030a0a;
  --text-main: #ffffff;
  --text-dim: #5c8582;
  --accent: #00fff5;
  --border: #0f2b29;
  --hover-box: rgba(0, 255, 245, 0.05);
}
[data-theme="light"] {
  --bg: #f5f2ed;
  --text-main: #1a1a1a;
  --text-dim: #666666;
  --accent: #008a7e;
  --border: #e0ddd7;
  --hover-box: rgba(0, 138, 126, 0.06);
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  background-color: var(--bg);
  color: var(--text-main);
  font-family: var(--serif);
  line-height: 1.6;
  transition: background var(--t);
  -webkit-font-smoothing: antialiased;
}
body.is-reading-mode {
  overflow: hidden !important;
}
.container {
  width: 90%;
  max-width: var(--container-width);
  margin: 0 auto;
}
.hidden {
  display: none !important;
}

header {
  padding: 1.2rem 0;
  padding-top: calc(1.2rem + env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2000;
}
.nav-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}
.brand-link {
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1.4rem;
  color: var(--text-main);
  transition: color var(--t);
  position: relative;
  cursor: pointer;
}
.brand-link::before {
  content: "←";
  position: absolute;
  left: -25px;
  color: var(--accent);
  opacity: 0;
  transition: all var(--t);
  font-family: var(--mono);
  font-weight: 700;
}
.brand-link:hover {
  color: var(--accent) !important;
}
.brand-link:hover::before {
  opacity: 1;
  left: -20px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.auth-btn {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--accent);
  border: 1px solid var(--accent);
  background: none;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  border-radius: 3px;
}
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
}
.toggle-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--text-dim);
  text-transform: uppercase;
}
.switch-base {
  width: 30px;
  height: 15px;
  background: var(--border);
  border-radius: 15px;
  position: relative;
}
.switch-base::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 11px;
  height: 11px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform var(--t);
}
[data-theme="dark"] .switch-base {
  background: var(--accent);
}
[data-theme="dark"] .switch-base::after {
  transform: translateX(15px);
  background: var(--bg);
}

.tagline {
  font-family: var(--serif);
  font-style: italic;
  color: var(--text-dim);
  font-size: 1rem;
  margin: 1.5rem 0 2rem;
}
/* --- Content Section --- */
.feed-item {
  display: grid;
  grid-template-columns: 140px 1fr;
  padding: 1.5rem 1.2rem; /* Increased padding for better click target */
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--t);
  margin: 0 -1rem;
  border-radius: 8px;
  align-items: center;
  background: transparent;
}

/* Hover state: cyan background tint and text color swap */
.feed-item:hover {
  background: var(--hover-box); /* This is the cyan tint */
  padding-left: 1.8rem; /* Smooth slide-in effect */
}

/* Force the title to turn cyan on hover */
.feed-item:hover .post-title {
  color: var(--accent);
}

.post-date {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-dim);
}

.post-title {
  font-family: var(--serif);
  font-size: 1.25rem;
  color: var(--text-main);
  transition: color var(--t);
}

#post-view {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg);
  z-index: 1000;
  overflow-y: auto;
  padding-top: calc(4rem + env(safe-area-inset-top));
}
#p-content {
  position: relative;
  width: 100%;
  height: calc(100vh - (4rem + env(safe-area-inset-top)));
}
iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

#loader {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  z-index: 10;
}
@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* overlay layout is on .modal-overlay — no rules needed here */
.modal-content {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2.5rem;
  border-radius: 12px;
  width: 360px;
  position: relative;
  font-family: var(--sans);
}
.modal-content h3 {
  margin-bottom: 1.8rem;
}
.google-login-btn {
  width: 100%;
  padding: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  background: #f8f9fa;
  color: #3c3c3c;
  border: 1px solid #dadce0;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 1.5rem;
  transition: background 0.15s, border-color 0.15s;
}
.google-login-btn:hover {
  background: #f0f0f0;
}
[data-theme="dark"] .google-login-btn {
  background: #2a2a2a;
  color: #e8e8e8;
  border-color: #444;
}
[data-theme="dark"] .google-login-btn:hover {
  background: #333;
}
.google-login-btn img {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.divider {
  display: flex;
  align-items: center;
  margin: 1rem 0;
  color: var(--text-dim);
  font-size: 0.7rem;
  text-transform: uppercase;
}
.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.divider span {
  padding: 0 10px;
}
.modal-content input {
  width: 100%;
  padding: 0.9rem;
  margin-bottom: 0.8rem;
  background: var(--hover-box);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 6px;
  outline: none;
}
.primary-btn {
  width: 100%;
  padding: 0.9rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
}
.modal-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
}
.modal-footer span {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  font-weight: 600;
}
.close-x {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
}

.comments-section {
  padding: 4rem 0;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
  font-family: var(--sans);
}
.avatar-box {
  width: 44px;
  height: 44px;
  background: var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  overflow: hidden;
  flex-shrink: 0;
}
.avatar-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
textarea {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 0.8rem;
  border-radius: 4px;
  outline: none;
  resize: none;
  min-height: 80px;
  font-family: var(--serif);
}
.btn-post {
  margin-top: 0.5rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 0.5rem 1.2rem;
  cursor: pointer;
  border-radius: 3px;
  float: right;
  font-weight: 600;
}

/* ── Modal overlay (shared by auth + account modals) ── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

/* ── Account modal extras ── */
.account-email {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  margin: 0.5rem 0 1.5rem;
  word-break: break-all;
}
.section-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 1.5rem 0 0.8rem;
  letter-spacing: 0.08em;
}
.oauth-note {
  font-size: 0.85rem;
  color: var(--text-dim);
  text-align: center;
  margin: 1rem 0;
  font-style: italic;
}
/* ── OTP screen ── */
.otp-hint {
  font-size: 0.9rem;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 1.5rem;
  line-height: 1.7;
}
.otp-hint strong {
  display: block;
  margin-top: 0.3rem;
  color: var(--accent);
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 600;
  word-break: break-all;
}
.otp-input {
  width: 100%;
  font-size: 2rem;
  font-family: var(--mono);
  text-align: center;
  letter-spacing: 0.5rem;
  padding: 0.6rem 0;
  border: 2px solid var(--accent);
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  margin-bottom: 1rem;
  box-sizing: border-box;
}
.otp-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 255, 245, 0.12);
}

.logout-btn {
  width: 100%;
  margin-top: 1.5rem;
  padding: 0.9rem;
  background: transparent;
  color: #e05a5a;
  border: 1px solid #e05a5a;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
  transition:
    background var(--t),
    color var(--t);
}
.logout-btn:hover {
  background: rgba(224, 90, 90, 0.1);
}

/* ── Comment layout ── */
.comment-box-top {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 3rem;
}
.input-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.login-msg {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}
.login-msg span {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}
.comment-item {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
}
.comment-reply {
  margin-top: 1rem;
  margin-bottom: 0;
}
.c-content {
  flex: 1;
  min-width: 0;
}
.c-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}
.c-user {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
}
.c-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: var(--mono);
}
.edited-tag {
  font-size: 0.65rem;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
  font-family: var(--mono);
  text-transform: uppercase;
}
.c-body {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
}
.c-actions {
  display: flex;
  gap: 0.8rem;
  margin-top: 0.5rem;
}
.c-action-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.75rem;
  font-family: var(--sans);
  font-weight: 500;
  cursor: pointer;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  transition: color var(--t), border-color var(--t);
}
.c-action-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Inline reply / edit forms ── */
.inline-form {
  margin-top: 0.8rem;
}
.inline-form textarea {
  min-height: 70px;
  font-size: 0.9rem;
}
.inline-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.5rem;
}
.btn-post-sm {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  border-radius: 3px;
  font-weight: 600;
  font-size: 0.82rem;
  font-family: var(--sans);
}
.btn-cancel {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  border-radius: 3px;
  font-size: 0.82rem;
  font-family: var(--sans);
  transition:
    border-color var(--t),
    color var(--t);
}
.btn-cancel:hover {
  border-color: var(--text-dim);
  color: var(--text-main);
}

/* ── Replies container ── */
.replies-list {
  margin-top: 1rem;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
}
