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

[hidden] { display: none !important; }

:root {
  --accent: #ff6600;
  --accent-hover: #e65c00;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: #fafafa;
  color: #1c1c1e;
  line-height: 1.6;
  min-height: 100vh;
}

header {
  background: #1c1c1e;
  color: #fff;
  padding: 20px 0 18px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 20px;
}

header h1 {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.tagline {
  color: #aaa;
  font-size: 0.87rem;
  margin-top: 3px;
  font-weight: 400;
}

.notif-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #333;
  border: 1px solid #444;
  border-radius: 6px;
  color: #ddd;
  font-family: inherit;
  font-size: 0.8rem;
  padding: 7px 13px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  font-weight: 500;
  min-height: 44px;
}

.notif-btn:hover {
  border-color: #666;
  background: #444;
  color: #fff;
}

.notif-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.notif-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.notif-btn.active:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.tabs-wrap {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.tabs {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  gap: 4px;
}

.tab {
  background: none;
  border: none;
  padding: 13px 14px 11px;
  font-size: 0.875rem;
  color: #888;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
  font-family: inherit;
}

.tab:hover {
  color: #1c1c1e;
}

.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.tag-cloud-wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 8px 20px 10px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.tag-cloud-wrap:empty {
  display: none;
}

.tag-search {
  flex-shrink: 0;
  width: 100px;
  padding: 3px 8px;
  font-size: 0.72rem;
  font-family: inherit;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  outline: none;
  color: #555;
  background: #fafafa;
  transition: border-color 0.15s, width 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

.tag-search:focus {
  border-color: #aaa;
  width: 140px;
}

.tag-search::placeholder {
  color: #999;
}

.tag-cloud {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.tag-cloud:empty {
  display: none;
}

.tag-no-match {
  font-size: 0.72rem;
  color: #bbb;
}

.tag-pill {
  background: none;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  padding: 3px 9px;
  font-size: 0.72rem;
  color: #777;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: border-color 0.1s, color 0.1s, background 0.1s;
}

.tag-pill:hover {
  border-color: #aaa;
  color: #1c1c1e;
}

.tag-pill.active {
  background: #1c1c1e;
  border-color: #1c1c1e;
  color: #fff;
}

.tag-pill-count {
  font-size: 0.65rem;
  opacity: 0.55;
}

main {
  max-width: 820px;
  margin: 0 auto;
  padding: 20px 20px 60px;
}

.loading,
.error-msg {
  text-align: center;
  padding: 60px 20px;
  color: #555;
  font-size: 0.95rem;
  font-weight: 500;
}

.error-msg {
  color: #c0392b;
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #e0e0e0;
  border-top-color: #1c1c1e;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 10px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-skeleton {
  max-width: 820px;
  margin: 0 auto;
  padding: 16px 20px;
}

.skeleton-card {
  background: #fff;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 8px;
  border: 1px solid #e8e8e8;
}

.skeleton-title {
  height: 18px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  margin-bottom: 8px;
  width: 80%;
}

.skeleton-meta {
  height: 14px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  width: 40%;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.story {
  background: #fff;
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 14px;
  border: 1px solid #e8e8e8;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.story:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border-color: #d0d0d0;
}

.story-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.story-num {
  color: #ccc;
  font-size: 0.85rem;
  min-width: 26px;
  text-align: right;
  padding-top: 2px;
  flex-shrink: 0;
  font-weight: 600;
}

.story-body {
  flex: 1;
  min-width: 0;
}

.story-title {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 4px;
}

.story-title a {
  color: #1c1c1e;
  text-decoration: none;
}

.story-title a:hover {
  color: var(--accent);
}

.story-teaser {
  font-size: 0.9rem;
  color: #555;
  margin-top: 6px;
  line-height: 1.55;
}

.story-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
}

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 4px;
  color: #fff;
  flex-shrink: 0;
}

.badge-hn {
  background: #ff6600;
}

.badge-lobsters {
  background: #ac130d;
}

.badge-dr {
  background: #c8102e;
}

.badge-tv2 {
  background: #0060a3;
}

.meta-item {
  font-size: 0.85rem;
  color: #777;
}

.meta-dot {
  color: #d0d0d0;
  font-size: 0.78rem;
}

.discuss-link {
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.discuss-link:hover {
  text-decoration: underline;
  color: var(--accent-hover);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  font-size: 0.72rem;
  background: #f0f0f0;
  color: #555;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.digest-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #f0f0f0;
  padding-left: 32px;
}

.digest-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 5px 10px;
  font-size: 0.78rem;
  color: #666;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.1s, color 0.1s;
}

.digest-btn:hover:not(:disabled) {
  border-color: #aaa;
  color: #1c1c1e;
}

.digest-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.digest-text {
  margin-top: 8px;
  font-size: 0.875rem;
  color: #444;
  line-height: 1.65;
  max-width: 680px;
}

.digest-text p {
  font-style: italic;
  margin-bottom: 6px;
}

.digest-text ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.digest-text li {
  padding-left: 16px;
  position: relative;
}

.digest-text li::before {
  content: '·';
  position: absolute;
  left: 4px;
  color: #bbb;
}

.digest-text strong {
  font-weight: 600;
  color: #1c1c1e;
}

.digest-error {
  margin-top: 8px;
  font-size: 0.8rem;
  color: #c0392b;
}

footer {
  text-align: center;
  padding: 20px;
  font-size: 0.75rem;
  color: #bbb;
}

/* ── Morning brief ── */

@keyframes morning-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 214, 10, 0.7); border-color: #ffd60a; }
  60%  { box-shadow: 0 0 0 9px rgba(255, 214, 10, 0); border-color: #ffd60a; }
  100% { box-shadow: 0 0 0 0 rgba(255, 214, 10, 0); border-color: #ffd60a; }
}

.morning-btn.is-pulsing {
  animation: morning-pulse 1.8s ease-out infinite;
  color: #ffd60a;
}

.morning-modal-box {
  max-width: 620px;
  max-height: 80vh;
  overflow-y: auto;
}

.morning-content {
  font-size: 0.9rem;
  line-height: 1.75;
  color: #333;
  margin-top: 14px;
}

.morning-content p {
  margin-bottom: 10px;
  font-style: normal;
}

.morning-content ul {
  padding-left: 0;
  list-style: none;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.morning-content li {
  padding-left: 14px;
  position: relative;
}

.morning-content li::before {
  content: '·';
  position: absolute;
  left: 2px;
  color: #bbb;
}

.morning-content strong {
  font-weight: 700;
  color: #1c1c1e;
}

.morning-personalized {
  font-size: 0.74rem;
  color: #888;
  border-left: 3px solid #ffd60a;
  padding-left: 8px;
  margin-bottom: 14px;
  font-style: normal;
}

.morning-generated {
  font-size: 0.72rem;
  color: #ccc;
  margin-top: 18px;
  margin-bottom: 0;
  font-style: normal;
}

/* ── / Search bar ── */

.search-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1c1c1e;
  border-top: 1px solid #333;
  padding: 9px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 200;
}

.search-bar[hidden] {
  display: none;
}

.search-prefix {
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: 1rem;
  color: #aaa;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 0.9rem;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  min-width: 0;
  caret-color: #fff;
}

.search-input::placeholder {
  color: #555;
}

.search-count {
  font-size: 0.75rem;
  color: #666;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  flex-shrink: 0;
}

.search-hint {
  font-size: 0.7rem;
  color: #444;
  flex-shrink: 0;
}

mark {
  background: #ffd60a;
  color: #1c1c1e;
  border-radius: 2px;
  padding: 0 1px;
}

/* ── Header auth area ── */

.header-btns {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#user-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.user-email-label {
  font-size: 0.78rem;
  color: #aaa;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Save button ── */

.save-btn {
  flex-shrink: 0;
  background: transparent;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s;
  align-self: flex-start;
  margin-top: 2px;
}

.save-btn:hover {
  color: #888;
}

.save-btn.saved {
  color: #1c1c1e;
}

/* ── Auth modal ── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 28px 28px 24px;
  max-width: 380px;
  width: 100%;
  position: relative;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1rem;
  color: #999;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
}

.modal-close:hover {
  color: #1c1c1e;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 0.88rem;
  color: #666;
  margin-bottom: 18px;
}

.email-input {
  display: block;
  width: 100%;
  padding: 9px 12px;
  font-size: 0.92rem;
  font-family: inherit;
  border: 1px solid #ddd;
  border-radius: 7px;
  outline: none;
  margin-bottom: 10px;
  transition: border-color 0.15s;
}

.email-input:focus {
  border-color: #1c1c1e;
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 9px 12px;
  background: #1c1c1e;
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 0.92rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover:not(:disabled) {
  background: #333;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: default;
}

.auth-error {
  font-size: 0.82rem;
  color: #c0392b;
  margin-top: 8px;
  margin-bottom: 0;
}

.auth-error[hidden] {
  display: none;
}

.auth-sent-msg {
  font-size: 0.9rem;
  color: #333;
  line-height: 1.5;
}
