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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #fff;
  color: #1a1a2e;
  line-height: 1.5;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: 5rem;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

header h1 {
  font-size: 1.25rem;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  color: inherit;
}

/* Settings */

.panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.panel[hidden] {
  display: none;
}

fieldset {
  border: 1px solid #e0e0e0;
  border-radius: 0.5rem;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

legend {
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0 0.25rem;
}

label {
  font-size: 0.875rem;
  font-weight: 600;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 0.5rem;
  font-family: inherit;
  min-height: 44px;
}

.btn {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  min-height: 44px;
  font-weight: 600;
}

.btn.primary {
  background: #3b82f6;
  color: #fff;
}

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

.btn.secondary {
  background: #e0e0e0;
  color: #1a1a2e;
  width: 100%;
}

/* Platform Filters */

.platform-filters {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.platform-filter {
  background: none;
  border: none;
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
  border-radius: 0.25rem;
  cursor: pointer;
  color: #888;
  font-weight: 500;
}

.platform-filter.active {
  background: #f0f0f0;
  color: #1a1a2e;
}

/* Bottom Tab Bar */

#bottom-tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: #fff;
  border-top: 1px solid #e0e0e0;
  padding: 0.5rem 0;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  z-index: 100;
}

.bottom-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  background: none;
  border: none;
  cursor: pointer;
  color: #888;
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 0.25rem 0;
  min-height: 44px;
  justify-content: center;
}

.bottom-tab.active {
  color: #3b82f6;
}

.bottom-tab svg {
  display: block;
}

.tab-icon-wrap {
  position: relative;
  display: inline-flex;
}

.badge {
  position: absolute;
  top: -4px;
  right: -8px;
  background: #ef4444;
  color: #fff;
  font-size: 0.625rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
  padding: 0 4px;
}

.badge[hidden] {
  display: none;
}

/* Status */

.status {
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
}

.status.success {
  background: #d4edda;
  color: #155724;
}

.status.error {
  background: #f8d7da;
  color: #721c24;
}

.status.loading {
  background: #fff3cd;
  color: #856404;
}

/* Feed */

#feed-empty {
  font-size: 0.875rem;
  color: #888;
  text-align: center;
  padding: 2rem 0;
}

#load-more-wrap {
  padding: 1rem 0;
}

#load-more-wrap[hidden] {
  display: none;
}

/* Post Card */

.post {
  padding: 0.75rem 0;
  border-bottom: 1px solid #e0e0e0;
}

.post:last-child {
  border-bottom: none;
}

.post-reblog {
  font-size: 0.75rem;
  color: #888;
  margin-bottom: 0.25rem;
  padding-left: 48px;
}

.reply-context {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  background: #f5f5f5;
  border-radius: 8px;
  border-left: 3px solid #ccc;
  font-size: 0.8rem;
  color: #666;
  text-decoration: none;
  overflow: hidden;
}

.reply-context:hover {
  background: #eee;
}

.reply-context-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 1px;
}

.reply-context-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.reply-context-label {
  font-weight: 600;
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-context-text {
  color: #888;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-header {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.post-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
}

.post-meta {
  flex: 1;
  min-width: 0;
}

.post-author {
  font-size: 0.875rem;
  font-weight: 600;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-author a {
  color: inherit;
  text-decoration: none;
}

.post-handle {
  font-size: 0.75rem;
  color: #888;
}

.post-badge {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  flex-shrink: 0;
  align-self: center;
}

.post-badge.mastodon {
  background: #6364ff;
  color: #fff;
}

.post-badge.bluesky {
  background: #0085ff;
  color: #fff;
}

.post-content {
  font-size: 0.9375rem;
  line-height: 1.6;
  padding-left: 48px;
  margin-top: 0.25rem;
  overflow-wrap: break-word;
}

.post-content p {
  margin-bottom: 0.5em;
}

.post-content p:last-child {
  margin-bottom: 0;
}

.post-content a {
  color: #3b82f6;
  text-decoration: none;
}

.post-content a:hover {
  text-decoration: underline;
}

/* Media Grid */

.post-media {
  padding-left: 48px;
  margin-top: 0.5rem;
  display: grid;
  gap: 0.25rem;
  border-radius: 0.5rem;
  overflow: hidden;
}

.post-media.media-1 {
  grid-template-columns: 1fr;
}

.post-media.media-2 {
  grid-template-columns: 1fr 1fr;
}

.post-media.media-3 {
  grid-template-columns: 1fr 1fr;
}

.post-media.media-4 {
  grid-template-columns: 1fr 1fr;
}

.post-media img,
.post-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  max-height: 300px;
  border-radius: 0.5rem;
}

.post-media.media-1 img,
.post-media.media-1 video {
  max-height: 400px;
}

.post-footer {
  padding-left: 48px;
  margin-top: 0.375rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.post-time {
  font-size: 0.75rem;
  color: #888;
}

.post-time a {
  color: inherit;
  text-decoration: none;
}

.post-time a:hover {
  text-decoration: underline;
}

/* Post Actions */

.post-actions {
  display: flex;
  gap: 1rem;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: none;
  border: none;
  cursor: pointer;
  color: #888;
  font-size: 0.75rem;
  padding: 0.25rem;
  border-radius: 0.25rem;
  transition: color 0.15s;
  min-height: 28px;
}

.action-btn:hover {
  color: #555;
}

.action-btn:disabled {
  pointer-events: none;
}

.action-btn.action-like.active {
  color: #f59e0b;
}

.action-btn.action-like:hover {
  color: #f59e0b;
}

.action-btn.action-boost.active {
  color: #19cf86;
}

.action-btn.action-boost:hover {
  color: #19cf86;
}

.action-btn.action-reply:hover {
  color: #3b82f6;
}

.action-count {
  font-variant-numeric: tabular-nums;
}

.action-btn svg {
  flex-shrink: 0;
}

/* Reply Composer */

.reply-composer {
  padding-left: 48px;
  margin-top: 0.5rem;
}

.reply-textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  border: 1px solid #ccc;
  border-radius: 0.5rem;
  resize: vertical;
  min-height: 60px;
  line-height: 1.5;
}

.reply-textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.reply-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.375rem;
}

.reply-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.reply-counter {
  font-size: 0.75rem;
  color: #888;
}

.reply-counter.over-limit {
  color: #e0245e;
  font-weight: 600;
}

.reply-cancel {
  background: none;
  border: none;
  color: #888;
  font-size: 0.8125rem;
  cursor: pointer;
  padding: 0.375rem 0.75rem;
  min-height: 32px;
}

.reply-cancel:hover {
  color: #555;
}

.reply-send {
  padding: 0.375rem 1rem;
  font-size: 0.8125rem;
  min-height: 32px;
}

/* Activity / Notifications */

#activity-list[hidden] {
  display: none;
}

.notification {
  padding: 0.75rem 0;
  border-bottom: 1px solid #e0e0e0;
}

.notification:last-child {
  border-bottom: none;
}

.notif-header {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.notif-icon {
  font-size: 1rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  padding-top: 0.25rem;
}

.notif-meta {
  flex: 1;
  min-width: 0;
  font-size: 0.875rem;
  line-height: 1.4;
}

.notif-actor {
  font-weight: 600;
  color: inherit;
  text-decoration: none;
}

.notif-actor:hover {
  text-decoration: underline;
}

.notif-label {
  color: #666;
}

.notif-time {
  display: block;
  font-size: 0.75rem;
  color: #888;
  margin-top: 0.125rem;
}

.notif-preview {
  margin-top: 0.375rem;
  margin-left: 68px;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid #e0e0e0;
  border-radius: 0 0.25rem 0.25rem 0;
}

.notif-content {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: #555;
  overflow-wrap: break-word;
}

.notif-content p {
  margin-bottom: 0.25em;
}

.notif-content p:last-child {
  margin-bottom: 0;
}

.notif-link {
  display: inline-block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: #3b82f6;
  text-decoration: none;
}

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

/* Pull to refresh */

.pull-indicator {
  text-align: center;
  font-size: 0.875rem;
  color: #888;
  padding: 0.5rem;
  transition: opacity 0.2s;
}

.pull-indicator[hidden] {
  display: none;
}

/* Dark Mode */

@media (prefers-color-scheme: dark) {
  body {
    background: #1a1a2e;
    color: #e0e0e0;
  }

  input[type="text"],
  input[type="password"] {
    background: #2a2a3e;
    border-color: #444;
    color: #e0e0e0;
  }

  fieldset {
    border-color: #444;
  }

  .platform-filter {
    color: #888;
  }

  .platform-filter.active {
    background: #2a2a3e;
    color: #e0e0e0;
  }

  #bottom-tabs {
    background: #1a1a2e;
    border-top-color: #444;
  }

  .bottom-tab {
    color: #888;
  }

  .bottom-tab.active {
    color: #60a5fa;
  }

  .btn.secondary {
    background: #3a3a4e;
    color: #e0e0e0;
  }

  .status.success {
    background: #1e3a2f;
    color: #a3d9a5;
  }

  .status.error {
    background: #3a1e1e;
    color: #d9a3a3;
  }

  .status.loading {
    background: #3a351e;
    color: #d9cfa3;
  }

  .post {
    border-bottom-color: #444;
  }

  .post-content a {
    color: #60a5fa;
  }

  .post-handle {
    color: #999;
  }

  .post-time {
    color: #999;
  }

  .post-reblog {
    color: #999;
  }

  .reply-context {
    background: #2a2a2a;
    border-left-color: #555;
    color: #aaa;
  }

  .reply-context:hover {
    background: #333;
  }

  .reply-context-label {
    color: #ccc;
  }

  .reply-context-text {
    color: #999;
  }

  .notification {
    border-bottom-color: #444;
  }

  .notif-label {
    color: #999;
  }

  .notif-time {
    color: #999;
  }

  .notif-preview {
    border-left-color: #444;
  }

  .notif-content {
    color: #aaa;
  }

  .notif-link {
    color: #60a5fa;
  }

  .action-btn {
    color: #888;
  }

  .action-btn:hover {
    color: #aaa;
  }

  .reply-textarea {
    background: #2a2a3e;
    border-color: #444;
    color: #e0e0e0;
  }

  .reply-textarea:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.15);
  }

  .reply-cancel {
    color: #888;
  }

  .reply-cancel:hover {
    color: #aaa;
  }

  .reply-counter {
    color: #888;
  }
}
