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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: #f7f9fa;
  color: #0f1419;
  line-height: 1.5;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  background: white;
  border-left: 1px solid #eff3f4;
  border-right: 1px solid #eff3f4;
}

/* ── Header ─────────────────────────── */

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid #eff3f4;
  padding: 12px 16px 12px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 44px;
  margin-bottom: 0;
}

h1 {
  font-size: 20px;
  font-weight: 700;
}

h1 span { color: #536471; font-weight: 400; }

.tags-toggle-btn {
  padding: 8px 18px;
  border-radius: 9999px;
  border: 1px solid #cfd9de;
  background: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.tags-toggle-btn:hover { background: #f7f7f7; }

.tags-toggle-btn.open {
  background: #0f1419;
  color: white;
  border-color: #0f1419;
}

#search {
  width: 100%;
  padding: 10px 16px;
  border-radius: 9999px;
  border: 1px solid #eff3f4;
  background: #eff3f4;
  font-size: 14px;
  outline: none;
  margin-top: 4px;
  transition: border-color 0.2s, background 0.2s;
}

#search:focus {
  background: white;
  border-color: #1d9bf0;
}

/* ── Tags Panel ──────────────────────── */

.tags-panel {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-8px);
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              margin-top 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin-top: 0;
}

.tags-panel.open {
  max-height: 350px;
  opacity: 1;
  transform: translateY(0);
  margin-top: 10px;
}

#tags-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0;
}

.tag-btn {
  padding: 10px 20px;
  border-radius: 9999px;
  border: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s;
}

/* Tag colors - unselected (light) */
.tag-btn[data-tag-id="all"]    { background: #f0f0f0; color: #555; border-color: #ddd; }
.tag-btn[data-tag-id="tool"]   { background: #eee; color: #888; border-color: #ddd; }
.tag-btn[data-tag-id="buy"]    { background: #fde8e8; color: #d97272; border-color: #f5c4c4; }
.tag-btn[data-tag-id="place"]  { background: #e6f7ec; color: #5aab7a; border-color: #b8e6cb; }
.tag-btn[data-tag-id="money"]  { background: #fdf6e3; color: #c4a035; border-color: #eddca0; }
.tag-btn[data-tag-id="study"]  { background: #f2f2f2; color: #999; border-color: #e0e0e0; }
.tag-btn[data-tag-id="health"] { background: #fff0e0; color: #d48c3e; border-color: #f5d6a8; }
.tag-btn[data-tag-id="ai"]     { background: #dff0f7; color: #3a8fb7; border-color: #b0d8ea; }
.tag-btn[data-tag-id="entame"] { background: #fce8f0; color: #c96b8b; border-color: #f0c0d0; }
.tag-btn[data-tag-id="tips"]   { background: #e6f7ec; color: #5aab7a; border-color: #b8e6cb; }
.tag-btn[data-tag-id="misc"]   { background: #f0f0f0; color: #999; border-color: #ddd; }

/* Tag colors - selected (darker) */
.tag-btn.active[data-tag-id="all"]    { background: #555; color: #fff; border-color: #555; }
.tag-btn.active[data-tag-id="tool"]   { background: #888; color: #fff; border-color: #888; }
.tag-btn.active[data-tag-id="buy"]    { background: #e05555; color: #fff; border-color: #e05555; }
.tag-btn.active[data-tag-id="place"]  { background: #3d9e64; color: #fff; border-color: #3d9e64; }
.tag-btn.active[data-tag-id="money"]  { background: #c49a20; color: #fff; border-color: #c49a20; }
.tag-btn.active[data-tag-id="study"]  { background: #aaa; color: #fff; border-color: #aaa; }
.tag-btn.active[data-tag-id="health"] { background: #d48c3e; color: #fff; border-color: #d48c3e; }
.tag-btn.active[data-tag-id="ai"]     { background: #2a7a9e; color: #fff; border-color: #2a7a9e; }
.tag-btn.active[data-tag-id="entame"] { background: #c05580; color: #fff; border-color: #c05580; }
.tag-btn.active[data-tag-id="tips"]   { background: #3d9e64; color: #fff; border-color: #3d9e64; }
.tag-btn.active[data-tag-id="misc"]   { background: #999; color: #fff; border-color: #999; }

/* ── Tag Pills ──────────────────────── */

.tag-pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.tag-tool   { background: #e8f5fd; color: #1d9bf0; }
.tag-buy    { background: #fce4ec; color: #e0136d; }
.tag-place  { background: #e0f7ed; color: #00945a; }
.tag-money  { background: #fff8e1; color: #b38f00; }
.tag-study  { background: #ede7f6; color: #6a3fbf; }
.tag-health { background: #fff3e0; color: #d45d00; }
.tag-ai     { background: #e0f7f4; color: #008f72; }
.tag-entame { background: #fbe9e7; color: #d63a00; }
.tag-tips   { background: #f3e5f5; color: #7b1fa2; }
.tag-misc   { background: #eceff1; color: #78909c; }

/* ── List View ──────────────────────── */

.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid #eff3f4;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background 0.1s;
}

.list-item:hover { background: #f7f9fa; }

.list-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.list-tags {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.list-body {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.list-handle {
  color: #536471;
  font-size: 13px;
  flex-shrink: 0;
  width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-text {
  flex: 1;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.list-date {
  color: #536471;
  font-size: 12px;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── Card View ──────────────────────── */

.card {
  padding: 12px 16px;
  border-bottom: 1px solid #eff3f4;
  transition: background 0.1s;
}

.card:hover { background: #f7f9fa; }

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.card-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.card-author-block { flex: 1; min-width: 0; }

.card-author-line {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.card-name {
  font-weight: 700;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-handle {
  color: #536471;
  font-size: 15px;
}

.card-dot { color: #536471; }

.card-date {
  color: #536471;
  font-size: 15px;
  text-decoration: none;
}

.card-date:hover { text-decoration: underline; }

.card-body { margin-top: 4px; }

.tweet-text {
  font-size: 15px;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}

.tweet-text a {
  color: #1d9bf0;
  text-decoration: none;
}

.tweet-text a:hover { text-decoration: underline; }

/* ── Quoted Tweet ───────────────────── */

.quoted-card {
  display: block;
  border: 1px solid #cfd9de;
  border-radius: 16px;
  padding: 12px;
  margin: 10px 0 0;
  cursor: pointer;
  transition: background 0.1s;
  overflow: hidden;
}

.quoted-card:hover { background: #f7f9fa; }

.quoted-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.quoted-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
}

.quoted-name {
  font-weight: 700;
  font-size: 13px;
}

.quoted-handle {
  color: #536471;
  font-size: 13px;
}

.quoted-text {
  font-size: 14px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.quoted-card .media-grid {
  margin-top: 8px;
  border-radius: 12px;
}

.quoted-card .media-grid img {
  max-height: 200px;
}

/* ── Media Grid ─────────────────────── */

.media-grid {
  display: grid;
  gap: 2px;
  border-radius: 16px;
  overflow: hidden;
  margin-top: 10px;
}

.media-grid.count-1 { grid-template-columns: 1fr; }
.media-grid.count-2 { grid-template-columns: 1fr 1fr; }
.media-grid.count-3 { grid-template-columns: 1fr 1fr; }
.media-grid.count-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }

.media-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  max-height: 300px;
}

/* ── Metrics ────────────────────────── */

.metrics {
  display: flex;
  gap: 20px;
  margin-top: 10px;
  color: #536471;
  font-size: 13px;
}

.metric {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Card Tags ──────────────────────── */

.card-tags {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* ── Empty State ────────────────────── */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #536471;
  font-size: 15px;
}

/* ── Responsive ─────────────────────── */

/* ── Undo Toast ─────────────────────── */

.undo-toast {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #0f1419;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  font-size: 14px;
  z-index: 200;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.undo-toast.show {
  transform: translateY(0);
}

.undo-btn {
  background: none;
  border: none;
  color: #1d9bf0;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 8px;
  margin-left: 12px;
  white-space: nowrap;
}

.undo-btn:hover {
  text-decoration: underline;
}


@media (max-width: 600px) {
  .container {
    border: none;
  }

  header { padding: 10px 12px; }

  .card { padding: 10px 12px; }

  #tags-bar { gap: 6px; }

  .tag-btn { padding: 8px 14px; font-size: 13px; }

  h1 { font-size: 18px; }

  .card-name { font-size: 14px; }
  .card-handle, .card-date, .card-dot { font-size: 13px; }
  .tweet-text { font-size: 14px; }

  .media-grid img { max-height: 220px; }
}