/* Readings - clean, minimal reading experience */

:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #666;
  --border: #e5e5e5;
  --accent: #1a1a1a;
  --accent-hover: #333;
  --radius: 8px;
  --max-width: 720px;
  --max-width-wide: 960px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* -- Auth -- */

.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.auth-title {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 32px;
}

.auth-msg {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 24px;
  font-size: 14px;
  color: #0369a1;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-input {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s;
}

.auth-input:focus {
  border-color: var(--accent);
}

.auth-btn {
  padding: 12px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.auth-btn:hover { background: var(--accent-hover); }

/* -- Topbar -- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav-home {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.3px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-user {
  font-size: 14px;
  color: var(--text-secondary);
}

.nav-logout {
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
}

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

.nav-category {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* -- Dashboard -- */

.dashboard {
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding: 48px 24px;
}

.dashboard-header {
  margin-bottom: 48px;
}

.dashboard-header h1 {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.dashboard-subtitle {
  color: var(--text-secondary);
  font-size: 16px;
}

.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-secondary);
  font-size: 16px;
}

.content-section {
  margin-bottom: 48px;
}

.section-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

.section-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.content-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.content-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.card-category {
  display: inline-block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.card-title {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.4;
}

/* -- Reading content -- */

.reading-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 48px 24px 96px;
}

.reading-content h1 {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.reading-content h2 {
  font-size: 24px;
  font-weight: 600;
  margin-top: 48px;
  margin-bottom: 16px;
  letter-spacing: -0.3px;
}

.reading-content h3 {
  font-size: 18px;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 12px;
}

.reading-content h4 {
  font-size: 15px;
  font-weight: 600;
  margin-top: 24px;
  margin-bottom: 8px;
}

.reading-content p {
  margin-bottom: 16px;
  font-size: 16px;
  line-height: 1.7;
}

.reading-content ul, .reading-content ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

.reading-content li {
  margin-bottom: 6px;
  line-height: 1.6;
}

.reading-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 14px;
}

.reading-content th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
}

.reading-content td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

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

.reading-content blockquote {
  border-left: 3px solid var(--border);
  padding-left: 20px;
  margin: 24px 0;
  color: var(--text-secondary);
  font-style: italic;
}

.reading-content code {
  background: #f5f5f4;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
}

.reading-content pre {
  background: #f5f5f4;
  border-radius: var(--radius);
  padding: 20px;
  overflow-x: auto;
  margin: 24px 0;
}

.reading-content pre code {
  background: none;
  padding: 0;
}

.reading-content strong {
  font-weight: 600;
}

.reading-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 48px 0;
}

/* -- Error page -- */

.error-page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 96px 24px;
  text-align: center;
}

.error-page h1 {
  font-size: 48px;
  margin-bottom: 16px;
}

.error-page p {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.back-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.back-link:hover { text-decoration: underline; }

/* -- Admin -- */

.admin-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 24px;
}

.admin-header {
  margin-bottom: 40px;
}

.admin-header h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.admin-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
}

.admin-section {
  margin-bottom: 48px;
}

.admin-section h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  letter-spacing: -0.3px;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.admin-table tr.not-visited td {
  color: var(--text-secondary);
}

.admin-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.admin-link:hover {
  text-decoration: underline;
}

.cell-email {
  color: var(--text-secondary);
  font-size: 13px;
}

.cell-num {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.cell-date {
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
}

.cell-cat {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.auth-event-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.auth-login_success { background: #dcfce7; color: #166534; }
.auth-magic_link_sent { background: #dbeafe; color: #1e40af; }
.auth-magic_link_failed { background: #fee2e2; color: #991b1b; }
.auth-magic_link_invalid { background: #fef3c7; color: #92400e; }
.auth-unknown_email { background: #fef3c7; color: #92400e; }
.auth-rate_limited { background: #fee2e2; color: #991b1b; }

tr.auth-warning td { background: #fffbeb; }
tr.auth-success td { background: #f0fdf4; }

.cell-detail {
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-empty {
  color: var(--text-secondary);
  font-size: 15px;
  padding: 24px 0;
}

/* -- Responsive -- */

@media (max-width: 600px) {
  .dashboard { padding: 32px 16px; }
  .dashboard-header h1 { font-size: 24px; }
  .reading-content { padding: 32px 16px 64px; }
  .reading-content h1 { font-size: 24px; }
  .reading-content h2 { font-size: 20px; }
  .content-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 32px 24px; }
  .admin-page { padding: 32px 16px; }
  .admin-table { font-size: 13px; }
  .admin-table th, .admin-table td { padding: 8px 8px; }
}
