/* ======================================
   Hackpad Viewer – minimal stylesheet
   ====================================== */

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC",
               "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: #1a1a1a;
  background: #f8f8f6;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1.25rem;
}
.container--wide { max-width: 980px; }

.site-header {
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
  padding: 0.75rem 0;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1a1a1a;
}
.header-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}
.user-name { color: #555; }

/* ── User menu dropdown ── */
.user-menu {
  position: relative;
}
.user-menu .user-name {
  cursor: default;
  user-select: none;
}
.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
  z-index: 100;
  padding: 0.4rem 0;
}
/* Transparent bridge fills the gap so hover doesn't break */
.user-dropdown::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 0;
  right: 0;
  height: 10px;
}
.user-menu:hover .user-dropdown { display: block; }
.user-dropdown a,
.user-dropdown-empty {
  display: block;
  padding: 0.45rem 1rem;
  font-size: 0.88rem;
  color: #1a1a1a;
  white-space: nowrap;
}
.user-dropdown a:hover { background: #f5f5f3; text-decoration: none; }
.user-dropdown-empty { color: #aaa; }
.user-dropdown-divider {
  border-top: 1px solid #e5e5e5;
  margin: 0.3rem 0;
}

main.container { padding-top: 2rem; padding-bottom: 3rem; }

.site-footer {
  border-top: 1px solid #e5e5e5;
  padding: 1rem 0;
  font-size: 0.85rem;
  color: #888;
  text-align: center;
}

/* ── Pad List (index) ── */
.pad-list { list-style: none; margin: 0; padding: 0; }
.pad-list-item {
  border-bottom: 1px solid #eee;
  padding: 0.75rem 0;
}
.pad-list-item:last-child { border-bottom: none; }
.pad-list-title { font-weight: 600; font-size: 1rem; }
.pad-list-meta  { font-size: 0.8rem; color: #888; margin-top: 0.15rem; }
.pad-list-preview {
  font-size: 0.82rem;
  color: #555;
  margin-top: 0.3rem;
  white-space: pre-wrap;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
}
.badge-private {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  color: #888;
  background: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 3px;
  padding: 0 0.35rem;
  vertical-align: middle;
  letter-spacing: 0.02em;
}

/* ── Pad View ── */
.pad-view { background: #fff; border-radius: 6px; padding: 2rem 2.5rem; box-shadow: 0 1px 4px rgba(0,0,0,.06); margin-left: 120px; }

.pad-header { margin-bottom: 1.5rem; border-bottom: 1px solid #eee; padding-bottom: 1rem; }
.pad-title  { font-size: 1.75rem; font-weight: 700; margin: 0 0 0.5rem; line-height: 1.3; }
.pad-meta   { font-size: 0.82rem; color: #888; display: flex; gap: 1.25rem; flex-wrap: wrap; }
.pad-empty  { color: #aaa; font-style: italic; }

/* ── Pad Content Typography ── */
.pad-content { word-break: break-word; }
.pad-content p          { margin: 0 0 0.5em; }
.pad-content p.blank-line { margin: 0; line-height: 1; height: 0.8em; }
.pad-content h2         { font-size: 1.35rem; font-weight: 700; margin: 1.25em 0 0.4em; border-bottom: 1px solid #eee; padding-bottom: 0.2em; }
.pad-content h3         { font-size: 1.1rem;  font-weight: 600; margin: 1em 0 0.3em; }
.pad-content ul, .pad-content ol { margin: 0 0 0.5em 1.5em; padding: 0; }
.pad-content li         { margin: 0.1em 0; }
.pad-content ul.task    li::marker { content: "☐  "; }
.pad-content ul.taskdone li::marker { content: "☑  "; color: #888; }
.pad-content ul.taskdone li { color: #888; text-decoration: line-through; }
.pad-content ul.code    { font-family: "SFMono-Regular", Consolas, monospace; font-size: 0.9em; background: #f4f4f2; border-radius: 4px; padding: 0.5em 1em; list-style: none; margin-left: 0; }
.pad-content a          { color: #2563eb; }
.pad-content img        { max-width: 100%; height: auto; display: block; margin: 0.5em 0; }

/* ── Sign-in ── */
.signin-box {
  max-width: 380px;
  margin: 4rem auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  padding: 2.5rem 2rem;
  text-align: center;
}
.signin-box h1  { font-size: 1.4rem; margin: 0 0 1.5rem; }
.signin-error   { color: #c0392b; font-size: 0.9rem; margin-bottom: 1rem; background: #fdf2f2; border-radius: 4px; padding: 0.6em 0.9em; }
.btn-google-login {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1.2rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  color: #333;
  font-size: 0.95rem;
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.btn-google-login:hover { box-shadow: 0 2px 6px rgba(0,0,0,.12); text-decoration: none; }
.signin-note { font-size: 0.8rem; color: #aaa; margin-top: 1.25rem; }

/* ── Error pages ── */
.error-box {
  text-align: center;
  padding: 5rem 1rem;
}
.error-box h1 { font-size: 4rem; font-weight: 700; color: #ddd; margin: 0; }
.error-box h2 { font-size: 1.25rem; font-weight: 600; margin: 0.5rem 0 1rem; }
.error-box p  { color: #777; }

/* ── Page layout with sidebar ── */
.page-layout {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}
.page-content {
  flex: 1;
  min-width: 0;
}
.sidebar {
  width: 200px;
  flex-shrink: 0;
}
.sidebar-section {
  margin-bottom: 1.5rem;
}
.sidebar-section .sidebar-list {
  max-height: 300px;
  overflow-y: auto;
}
.sidebar-heading {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #999;
  margin: 0 0 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid #eee;
}
.sidebar-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidebar-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0.2rem 0;
  font-size: 0.85rem;
  border-bottom: 1px solid #f5f5f5;
}
.sidebar-list a {
  color: #444;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-list a:hover { color: #1a73e8; text-decoration: underline; }
.sidebar-count {
  font-size: 0.75rem;
  color: #bbb;
  margin-left: 0.4rem;
  flex-shrink: 0;
}
/* Pad contributors sidebar */
.sidebar-contributors li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.contributor-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
/* Pad TOC sidebar */
.sidebar-toc {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sidebar-toc li { margin-bottom: 0.25rem; }
.sidebar-toc a {
  font-size: 0.82rem;
  color: #444;
  text-decoration: none;
  display: block;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-toc a:hover { color: #1a73e8; text-decoration: underline; }
.toc-level-1 { padding-left: 0; font-weight: 600; }
.toc-level-2 { padding-left: 0.8rem; }
.toc-level-3 { padding-left: 1.6rem; font-size: 0.78rem; color: #888; }
.back-link {
  margin-right: 0.4rem;
  color: #999;
  text-decoration: none;
  font-weight: 400;
}
.back-link:hover { color: #333; }

@media (max-width: 700px) {
  .page-layout { flex-direction: column; }
  .sidebar { width: 100%; }
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}
.page-btn {
  padding: 0.35rem 0.8rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  color: #444;
  text-decoration: none;
  font-size: 0.9rem;
}
.page-btn:hover { background: #f5f5f5; text-decoration: none; }
.page-info { font-size: 0.85rem; color: #999; }

/* ── Pad collection tags ── */
.pad-collections {
  margin-top: 0.4rem;
}
.pad-collection-tag {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  margin: 0.15rem 0.25rem 0.15rem 0;
  border: 1px solid #d0e4ff;
  border-radius: 20px;
  background: #f0f6ff;
  color: #1a73e8;
  font-size: 0.78rem;
  text-decoration: none;
}
.pad-collection-tag:hover { background: #ddeeff; text-decoration: none; }

/* ── Inline comments ── */
.pad-comment {
  margin: 0.25rem 0 0.25rem 1rem;
  padding: 0.35rem 0.6rem 0.35rem 0.8rem;
  border-left: 3px solid #f0c040;
  background: #fffdf0;
  font-size: 0.92rem;
  color: #444;
  border-radius: 0 4px 4px 0;
}
.comment-author {
  font-weight: 600;
  margin-right: 0.5rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ── Per-line author gutter ── */
.line-author {
  position: absolute;
  right: calc(100% + 2.5rem + 8px);
  width: 104px;
  text-align: right;
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.75;
  pointer-events: none;
}
@media (max-width: 700px) {
  .pad-view { margin-left: 0; }
  .line-author { display: none; }
}

/* ── Admin panel ── */
.admin-header { display:flex; align-items:baseline; gap:1.5rem; margin-bottom:1.5rem; }
.admin-header h1 { margin:0; font-size:1.5rem; }
.admin-back { font-size:0.85rem; color:#666; }
.admin-count { font-size:1rem; font-weight:400; color:#888; margin-left:0.5rem; }
.admin-cards { display:flex; gap:1.5rem; margin-bottom:2rem; }
.admin-card {
  display:block; text-decoration:none; color:inherit;
  background:#fff; border:1px solid #e5e5e5; border-radius:8px;
  padding:1.25rem 2rem; text-align:center; min-width:140px;
  box-shadow:0 1px 4px rgba(0,0,0,.05);
}
.admin-card:hover { box-shadow:0 2px 8px rgba(0,0,0,.1); text-decoration:none; }
.admin-card-number { font-size:2rem; font-weight:700; }
.admin-card-label  { font-size:0.85rem; color:#888; margin-top:0.25rem; }
.admin-table { width:100%; border-collapse:collapse; background:#fff;
               border-radius:6px; overflow:hidden; box-shadow:0 1px 4px rgba(0,0,0,.06); }
.admin-table th { background:#f5f5f3; text-align:left; padding:0.6rem 0.9rem;
                  font-size:0.82rem; color:#555; border-bottom:1px solid #e5e5e5; }
.admin-table td { padding:0.5rem 0.9rem; border-bottom:1px solid #f0f0f0; font-size:0.88rem; }
.admin-table tr:last-child td { border-bottom:none; }
.admin-table tr:hover td { background:#fafaf8; }
.admin-search { display:flex; gap:0.5rem; margin-bottom:1rem; }
.admin-search input { flex:1; padding:0.45rem 0.75rem; border:1px solid #ddd;
                       border-radius:4px; font-size:0.9rem; }
.admin-search button { padding:0.45rem 1rem; background:#2563eb; color:#fff;
                        border:none; border-radius:4px; cursor:pointer; font-size:0.9rem; }
.admin-search a { padding:0.45rem 0.75rem; color:#666; font-size:0.9rem; align-self:center; }
.user-dropdown-section {
  padding:0.35rem 1rem; font-size:0.75rem; font-weight:700;
  color:#aaa; text-transform:uppercase; letter-spacing:0.05em;
}

/* ── Welcome page (primary domain, not logged in) ── */
.welcome-box {
  max-width: 560px;
  margin: 3rem auto;
  text-align: center;
}
.welcome-box h1 { font-size: 1.75rem; margin-bottom: 1rem; }
.welcome-box p  { color: #555; line-height: 1.8; margin-bottom: 1rem; }
.btn-primary {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.65rem 1.75rem;
  background: #2563eb;
  color: #fff;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 500;
}
.btn-primary:hover { background: #1d4ed8; text-decoration: none; }

/* ── Revision history ── */
.pad-history-link { font-size:0.82rem; color:#2563eb; }
.history-table { width:100%; border-collapse:collapse; }
.history-table th { text-align:left; padding:0.5rem 0.75rem; font-size:0.82rem;
                     color:#888; border-bottom:2px solid #eee; }
.history-table td { padding:0.5rem 0.75rem; border-bottom:1px solid #f0f0f0; font-size:0.88rem; }
.history-table tr:hover td { background:#fafaf8; }
.history-time  { color:#555; white-space:nowrap; }
.history-author { font-weight:600; }
.history-rev   { color:#aaa; font-size:0.8rem; font-family:monospace; }

/* ── Revision history diff ── */
.history-diff-row td { padding: 0 0.75rem 0.5rem; }
details summary { cursor: pointer; font-size: 0.82rem; color: #2563eb; }
.diff-block { font-family: monospace; font-size: 0.82rem; line-height: 1.5;
              margin-top: 0.5rem; border-radius: 4px; overflow: auto; max-height: 400px; }
.diff-add  { background: #ecfdf5; color: #166534; white-space: pre-wrap; padding: 0 0.5rem; }
.diff-del  { background: #fef2f2; color: #991b1b; white-space: pre-wrap; padding: 0 0.5rem; }
.diff-ctx  { color: #6b7280; white-space: pre-wrap; padding: 0 0.5rem; }
.diff-skip { color: #9ca3af; padding: 0 0.5rem; font-style: italic; }
.welcome-operator { margin-top: 1.5rem; font-size: 0.85rem; color: #aaa; }
.welcome-operator a { color: #888; }

/* ── Header search ── */
.header-search { display:flex; gap:0.25rem; }
.header-search input {
  padding: 0.3rem 0.6rem; border: 1px solid #ddd; border-radius: 4px;
  font-size: 0.85rem; width: 160px;
}
.header-search button {
  padding: 0.3rem 0.5rem; border: 1px solid #ddd; border-radius: 4px;
  background: #f5f5f3; cursor: pointer; font-size: 0.85rem;
}

/* ── Search results page ── */
.search-header { margin-bottom: 1.5rem; }
.search-form { display:flex; gap:0.5rem; }
.search-input {
  flex: 1; padding: 0.55rem 0.9rem; border: 1px solid #ddd;
  border-radius: 6px; font-size: 1rem;
}
.search-form button {
  padding: 0.55rem 1.25rem; background: #2563eb; color: #fff;
  border: none; border-radius: 6px; cursor: pointer; font-size: 1rem;
}
.search-summary { color: #666; margin-bottom: 1rem; font-size: 0.9rem; }
.search-error   { color: #c0392b; }
.search-results { list-style: none; padding: 0; margin: 0; }
.search-result  { padding: 1rem 0; border-bottom: 1px solid #f0f0f0; }
.search-result:last-child { border-bottom: none; }
.search-result-title {
  font-size: 1.05rem; font-weight: 600; color: #2563eb; display: block;
  margin-bottom: 0.25rem;
}
.search-result-title mark { background: #fef9c3; color: inherit; border-radius: 2px; }
.search-result-snippet {
  font-size: 0.88rem; color: #555; line-height: 1.6; margin-bottom: 0.2rem;
}
.search-result-snippet mark { background: #fef9c3; color: inherit; border-radius: 2px; }
.search-result-meta { font-size: 0.78rem; color: #aaa; }
