/* ================= DESIGN TOKENS ================= */
:root {
  --blue: #285ccc;
  --blue-dark: #1e46a3;
  --cream: #fff2db;
  --white: #f1f1f1;
  --black: #1a1a1a;
  --pink: #ff6f91;

  --font-pixel: 'Press Start 2P', cursive;
  --font-body: 'VT323', monospace;

  --border: 3px solid var(--black);
  --shadow-hard: 4px 4px 0 var(--black);
  --shadow-hard-sm: 2px 2px 0 var(--black);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--black);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

img { image-rendering: -webkit-optimize-contrast; }

.hidden { display: none !important; }

button {
  font-family: var(--font-body);
  cursor: pointer;
}

/* ================= LOADING SCREEN ================= */
#loading-screen {
  position: fixed;
  inset: 0;
  background: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  transition: opacity 0.4s ease;
}

.loading-box {
  text-align: center;
  padding: 24px;
  color: var(--cream);
}

.loading-heart {
  font-size: 48px;
  color: var(--pink);
  animation: pulse 1s infinite steps(4);
  text-shadow: 3px 3px 0 var(--black);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}

.loading-text {
  font-family: var(--font-body);
  font-size: 22px;
  margin: 16px 0;
  line-height: 1.4;
  min-height: 2.8em;
}

.loading-bar {
  width: 180px;
  height: 14px;
  background: var(--black);
  border: 2px solid var(--cream);
  margin: 0 auto;
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--pink);
  animation: loadbar 1.6s ease-in-out infinite;
}

@keyframes loadbar {
  0% { width: 0%; }
  50% { width: 85%; }
  100% { width: 0%; }
}

/* ================= HEADER ================= */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--blue);
  border-bottom: var(--border);
}

.header-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-pixel);
  color: var(--cream);
  font-size: 14px;
}

.brand-heart {
  color: var(--pink);
  text-shadow: 2px 2px 0 var(--black);
}

.user-badge {
  font-family: var(--font-pixel);
  font-size: 11px;
  background: var(--cream);
  color: var(--blue-dark);
  border: var(--border);
  box-shadow: var(--shadow-hard-sm);
  padding: 8px 10px;
}

/* ================= SWITCH BAR ================= */
.switch-bar {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  padding: 12px 16px 0;
}

.switch-btn {
  flex: 1;
  text-align: center;
  padding: 10px 8px;
  background: var(--white);
  border: var(--border);
  box-shadow: var(--shadow-hard-sm);
  color: var(--black);
  text-decoration: none;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.1s;
}

.switch-btn:active { transform: translate(2px, 2px); box-shadow: none; }

.switch-btn.active {
  background: var(--blue);
  color: var(--cream);
}

/* ================= LAYOUT ================= */
.feed-wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 12px 40px;
}

/* ================= COMPOSER ================= */
.composer {
  background: var(--white);
  border: var(--border);
  box-shadow: var(--shadow-hard);
  padding: 14px;
  margin-bottom: 18px;
}

.composer-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.composer-avatar, .post-avatar, .comment-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: var(--border);
  background: var(--blue);
  color: var(--cream);
  font-family: var(--font-pixel);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.comment-avatar {
  width: 30px;
  height: 30px;
  font-size: 9px;
}

.composer-input {
  flex: 1;
  border: 2px solid var(--black);
  background: var(--cream);
  font-family: var(--font-body);
  font-size: 19px;
  padding: 8px 10px;
  resize: none;
  min-height: 44px;
}

.composer-input:focus { outline: 2px solid var(--blue); }

.composer-preview-wrap {
  position: relative;
  margin-top: 10px;
  border: var(--border);
  overflow: hidden;
  max-height: 260px;
}

.composer-preview {
  width: 100%;
  display: block;
  object-fit: cover;
  max-height: 260px;
}

.preview-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--black);
  color: var(--cream);
  border: 2px solid var(--cream);
  width: 30px;
  height: 30px;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.composer-action {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 17px;
  color: var(--blue-dark);
  cursor: pointer;
  padding: 8px 10px;
  border: 2px dashed var(--blue-dark);
}

.btn-post {
  background: var(--blue);
  color: var(--cream);
  border: var(--border);
  box-shadow: var(--shadow-hard-sm);
  font-family: var(--font-pixel);
  font-size: 11px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.1s;
}

.btn-post:active { transform: translate(2px, 2px); box-shadow: none; }
.btn-post:disabled { opacity: 0.5; cursor: not-allowed; }

.composer-progress {
  margin-top: 10px;
  position: relative;
  background: var(--cream);
  border: 2px solid var(--black);
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.composer-progress-bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 40%;
  background: var(--pink);
  animation: loadbar 1.2s ease-in-out infinite;
}

#composer-progress-text {
  position: relative;
  font-size: 13px;
  z-index: 1;
}

/* ================= FEED / POST CARD ================= */
.feed { display: flex; flex-direction: column; gap: 16px; }

.post-card {
  background: var(--white);
  border: var(--border);
  box-shadow: var(--shadow-hard);
  padding: 14px;
  animation: pop-in 0.25s ease;
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.post-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.post-headinfo {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.post-author {
  font-family: var(--font-pixel);
  font-size: 11px;
}

.post-time {
  font-size: 15px;
  color: #555;
}

.post-delete {
  background: none;
  border: none;
  color: #999;
  font-size: 18px;
  padding: 6px;
}

.post-delete:hover { color: #d33; }

.post-text {
  font-size: 20px;
  line-height: 1.4;
  margin: 12px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.post-image-wrap {
  margin-top: 12px;
  border: 2px solid var(--black);
  overflow: hidden;
  background: repeating-conic-gradient(#e8e8e8 0% 25%, #f5f5f5 0% 50%) 50% / 16px 16px;
}

.post-image {
  width: 100%;
  display: block;
  max-height: 480px;
  object-fit: cover;
}

.post-stats {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  color: #555;
  margin-top: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid #ddd;
}

.post-actions {
  display: flex;
  margin-top: 6px;
}

.post-action {
  flex: 1;
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: 18px;
  padding: 8px 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--black);
  transition: transform 0.15s;
}

.post-action.liked {
  color: var(--pink);
}

.post-action.liked i::before {
  content: "\f470"; /* ri-heart-3-fill */
}

.post-action:active { transform: scale(0.92); }

.comment-section {
  margin-top: 10px;
  border-top: 2px solid #ddd;
  padding-top: 10px;
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.comment-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.comment-bubble {
  flex: 1;
  background: var(--cream);
  border: 2px solid var(--black);
  padding: 6px 10px;
}

.comment-author {
  font-family: var(--font-pixel);
  font-size: 9px;
  display: block;
  margin-bottom: 2px;
  color: var(--blue-dark);
}

.comment-text {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
  word-break: break-word;
}

.comment-delete {
  background: none;
  border: none;
  color: #999;
  font-size: 16px;
  flex-shrink: 0;
  padding: 4px;
}

.comment-input-row {
  display: flex;
  gap: 8px;
}

.comment-input {
  flex: 1;
  border: 2px solid var(--black);
  background: var(--white);
  font-family: var(--font-body);
  font-size: 17px;
  padding: 8px 10px;
}

.comment-input:focus { outline: 2px solid var(--blue); }

.comment-send {
  background: var(--blue);
  color: var(--cream);
  border: 2px solid var(--black);
  width: 42px;
  font-size: 16px;
}

/* ================= EMPTY STATE ================= */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #777;
}

.empty-state i {
  font-size: 40px;
  color: var(--blue);
}

.empty-state p {
  font-size: 19px;
  margin-top: 10px;
  line-height: 1.4;
}

/* ================= TOAST ================= */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--black);
  color: var(--cream);
  border: 2px solid var(--cream);
  padding: 10px 18px;
  font-size: 16px;
  z-index: 200;
  box-shadow: var(--shadow-hard-sm);
  animation: toast-in 0.25s ease;
  max-width: 90vw;
  text-align: center;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ================= SCROLLBAR (desktop niceties) ================= */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--cream); }
::-webkit-scrollbar-thumb { background: var(--blue); border: 2px solid var(--black); }

/* ================= DESKTOP (progressive enhancement, tetap mobile-first) ================= */
@media (min-width: 600px) {
  .loading-text { font-size: 24px; }
  .post-text { font-size: 21px; }
}

/* Reduced motion respect */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}