@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,400;1,9..144,300&display=swap');

:root {
  --bg:      #1e1e1e;
  --bg2:     #252526;
  --bg3:     #2d2d2d;
  --border:  #2a2a2a;
  --accent:  #ff6600;
  --text:    #e8e0d0;
  --text2:   #888;
  --text3:   #666;
  --link:    #c8b89a;
  --green:   #4caf6a;
  --mono:    'JetBrains Mono', monospace;
  --serif:   'Fraunces', serif;
  --r:       3px;
  --safe-top: env(safe-area-inset-top);
  --safe-bot: env(safe-area-inset-bottom);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow-x: hidden; }
body {
  font-family: var(--mono);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

/* HEADER */
#header {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 10px 14px calc(10px + var(--safe-bot));
  display: flex; align-items: center; gap: 10px;
}
#logo {
  font-family: var(--serif);
  font-weight: 300;
  font-size: 1.5rem;
  color: var(--accent);
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
#date-nav { display: flex; align-items: center; gap: 10px; flex: 1; justify-content: flex-end; }
#date-label {
  font-size: 0.82rem;
  color: var(--text2);
  letter-spacing: 0.04em;
  min-width: 108px;
  text-align: center;
}
.nav-btn {
  font-family: var(--mono);
  font-size: 1rem;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.1s;
}
.nav-btn:active { background: var(--bg2); }
.nav-btn:disabled { opacity: 0.25; cursor: default; }

/* PTR */
#ptr {
  height: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 0.62rem; color: var(--text2);
  letter-spacing: 0.1em; text-transform: uppercase;
  transition: height 0.15s;
}
#ptr.visible { height: 42px; }
.ptr-spin {
  width: 12px; height: 12px;
  border: 1.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
#ptr.loading .ptr-spin { display: block; }

/* FEED */
#feed { padding-bottom: calc(90px + var(--safe-bot)); }

.story {
  border-bottom: 1px solid var(--border);
  padding: 11px 14px;
  display: grid;
  grid-template-columns: 2ex 1fr;
  gap: 0 9px;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  animation: fadeUp 0.18s ease both;
}
.story:active { background: var(--bg2); }
.rank { 
  font-size: 0.75rem; 
  color: var(--text3); 
  padding-top: 2px; 
  text-align: center; 
}
.s-title {
  font-family: var(--serif);
  font-size: 1.08rem;
  font-weight: 300;
  line-height: 1.35;
  margin-bottom: 5px;
}
.story.read .s-title { color: var(--text3); }
.story.unread .s-title { color: var(--text); }
.domain {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text3);
  margin-left: 5px;
  vertical-align: middle;
  font-weight: 400;
}
.s-meta {
  font-size: 0.72rem;
  color: var(--text2);
  display: flex; flex-wrap: wrap; gap: 0 9px;
  line-height: 1.7;
}
.pts { color: var(--accent); font-weight: 500; }
.cmt-btn {
  background: none; border: none;
  font-family: var(--mono); font-size: 0.72rem;
  color: var(--link); cursor: pointer; padding: 0;
  -webkit-tap-highlight-color: transparent;
  font-variant-emoji: text;
  span {
    opacity: 0.6;
  }
}
.cmt-btn:active { color: var(--accent); }
.dot {
  display: inline-block;
  width: 5px; height: 5px;
  background: var(--accent);
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

/* STATUS */
#status {
  text-align: center;
  padding: 64px 20px;
  color: var(--text2);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  line-height: 2;
}
#status.err { color: #e05555; }
#status .ico { font-size: 1.6rem; display: block; margin-bottom: 8px; }

/* DRAWER */
#overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 200; opacity: 0; pointer-events: none;
  transition: opacity 0.22s;
}
#overlay.open { opacity: 1; pointer-events: all; }
#drawer {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 201;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex; flex-direction: column; overflow: hidden;
}
#drawer.open { transform: translateY(0); }
#d-head {
  padding: 10px 42px 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#d-title {
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 300;
  line-height: 1.3;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
}
#d-title[href]:hover { text-decoration: underline; text-decoration-color: var(--text3); }
#d-title[href] { cursor: pointer; }
#d-meta { font-size: 0.68rem; color: var(--text2); display: flex; gap: 8px; }
#d-close {
  position: absolute; top: 10px; right: 12px;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); font-family: var(--mono); font-size: 0.75rem;
  width: 30px; height: 30px; border-radius: var(--r);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
#d-link {
  display: block;
  margin: 8px 14px 0;
  padding: 7px 10px;
  font-size: 0.75rem;
  color: var(--link);
  text-decoration: none;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
#d-link:active { background: var(--bg3); }
#d-scroll {
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(20px + var(--safe-bot));
}

/* COMMENTS */
.comment {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.comment::before {
  content: '';
  position: absolute;
  left: calc(14px + var(--d) * 13px - 6px);
  top: 0; bottom: 0; width: 1px;
  background: var(--border);
}
.comment[data-d="0"]::before { display: none; }
.comment:active { background: var(--bg2); }
.c-head {
  display: flex; align-items: center; gap: 7px;
  margin-bottom: 3px;
  padding-left: calc(var(--d) * 13px);
  user-select: none;
}
.c-by { font-size: 0.72rem; font-weight: 500; color: var(--accent); }
.c-by.op { color: var(--green); }
.c-age { font-size: 0.68rem; color: var(--text3); }
.c-body {
  padding-left: calc(var(--d) * 13px);
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 300;
  line-height: 1.55;
  color: var(--text);
  word-break: break-word;
}
.c-body a { color: var(--link); }
.c-body pre, .c-body code {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--r); font-family: var(--mono);
  font-size: 0.7rem;
}
.c-body pre { padding: 7px; overflow-x: auto; margin: 5px 0; }
.c-body code { padding: 1px 4px; }
.c-body p { margin-bottom: 4px; }
.c-body p:last-child { margin: 0; }
.comment.col .c-body { display: none; }
.c-col-info {
  padding-left: calc(var(--d) * 13px);
  font-size: 0.68rem; color: var(--text3); margin-top: 1px;
  display: none;
}
.comment.col .c-col-info { display: block; }

#c-loading {
  text-align: center; padding: 40px 20px;
  color: var(--text2); font-size: 0.68rem;
  letter-spacing: 0.05em;
}

/* OFFLINE */
#offline {
  position: fixed;
  bottom: calc(14px + var(--safe-bot)); left: 50%;
  transform: translateX(-50%) translateY(70px);
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 20px; padding: 5px 14px;
  font-size: 0.6rem; color: var(--text2);
  letter-spacing: 0.05em; z-index: 300;
  transition: transform 0.28s; white-space: nowrap;
}
#offline.show { transform: translateX(-50%) translateY(0); }

/* ANIMATIONS */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: none; }
}
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
