* { box-sizing: border-box; }
:root {
  --bg: #0e1116;
  --panel: #161b23;
  --panel2: #1d242f;
  --border: #2a3340;
  --text: #e6ebf2;
  --muted: #8b96a5;
  --accent: #4f8cff;
  --danger: #e5484d;
}
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', sans-serif;
}
.hidden { display: none !important; }
button {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
}
button:hover { border-color: var(--accent); }
button.muted { color: var(--muted); }
button.danger { color: var(--danger); border-color: var(--danger); }
input {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  width: 100%;
}
input:focus { outline: none; border-color: var(--accent); }
.error { color: var(--danger); font-size: 13px; margin-top: 8px; }

/* auth */
#auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-box {
  width: 340px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
}
.auth-box h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: 0.5px; }
.auth-box .sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab { flex: 1; }
.tab.active { border-color: var(--accent); color: var(--accent); }
#auth-form { display: flex; flex-direction: column; gap: 10px; }
#auth-form button[type='submit'] { margin-top: 6px; }

/* layout */
#app { display: flex; height: 100vh; }
#sidebar {
  width: 260px;
  min-width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
.side-head { display: flex; justify-content: space-between; align-items: baseline; }
.logo { font-weight: 700; letter-spacing: 0.5px; }
.me { color: var(--muted); font-size: 13px; }
.side-actions { display: flex; flex-direction: column; gap: 6px; }
#thread-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.thread-item {
  text-align: left;
  display: flex; flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
}
.thread-item .t-name { font-weight: 600; }
.thread-item .t-meta { color: var(--muted); font-size: 12px; }
.thread-item.active { border-color: var(--accent); background: rgba(79, 140, 255, 0.08); }

.invites { border-top: 1px solid var(--border); padding-top: 10px; }
.invites-title { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.invite-row {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}
.invite-row button { padding: 4px 10px; font-size: 12px; margin-left: auto; }
.invite-row button + button { margin-left: 0; }
.inv-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#main { flex: 1; overflow-y: auto; padding: 24px; }
.empty { color: var(--muted); text-align: center; margin-top: 12vh; }

/* thread */
.thread-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.thread-head h2 { margin: 0 0 6px; }
.members { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--muted);
}
.head-actions { display: flex; gap: 8px; }
.t-invites { margin-bottom: 12px; }

.upload-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.hint { color: var(--muted); font-size: 12px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}
.grid-empty { color: var(--muted); grid-column: 1 / -1; text-align: center; padding: 30px 0; }

.card {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
  user-select: none;
}
.card-face {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.25s;
}
.card-label { font-weight: 600; }
.card-sub { color: var(--muted); font-size: 11px; padding: 0 10px; text-align: center; }
.card-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.25s;
}
.card.open .card-img { opacity: 1; }
.card.open .card-face { opacity: 0; pointer-events: none; }
.card:hover { border-color: var(--accent); }

/* css lock icon */
.lock { position: relative; width: 26px; height: 24px; }
.lock-body {
  position: absolute; bottom: 0; left: 2px;
  width: 22px; height: 15px;
  border: 2px solid var(--muted);
  border-radius: 4px;
}
.lock-shackle {
  position: absolute; top: 0; left: 6px;
  width: 14px; height: 12px;
  border: 2px solid var(--muted);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
}

.timer {
  position: absolute;
  top: 8px; right: 10px;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* modal */
#modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
}
.modal {
  width: 400px;
  max-width: 92vw;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
}
.modal h3 { margin: 0 0 14px; }
.modal p { color: var(--muted); font-size: 13px; }
.modal input { margin-bottom: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* toast */
#toast {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 18px;
  z-index: 20;
  max-width: 80vw;
}

@media (max-width: 640px) {
  #app { flex-direction: column; height: auto; }
  #sidebar { width: 100%; min-width: 0; border-right: none; border-bottom: 1px solid var(--border); }
  #main { padding: 14px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

