:root {
  --bg: #fbf6ec;
  --bg2: #f3e8d3;
  --panel: #ffffff;
  --panel2: #fdf9f1;
  --ink: #2b2119;
  --muted: #8a7a68;
  --line: #e7dcc8;
  --teal: #0f766e;
  --teal-soft: #d7f0ec;
  --saffron: #e9a23b;
  --saffron-deep: #d4831f;
  --mine: #0f766e;
  --mine-ink: #ffffff;
  --shadow: 0 8px 24px rgba(90, 66, 30, 0.12);
}
[data-theme="dark"] {
  --bg: #17130e;
  --bg2: #221a11;
  --panel: #221b13;
  --panel2: #2a2117;
  --ink: #f3e9da;
  --muted: #a89680;
  --line: #3a2f21;
  --teal: #2dd4bf;
  --teal-soft: #123935;
  --saffron: #f0b258;
  --saffron-deep: #e9a23b;
  --mine: #0d6b63;
  --mine-ink: #ecfdf9;
  --shadow: 0 8px 28px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
#root { height: 100%; }

.th-app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 500px at 90% -10%, var(--teal-soft), transparent 60%),
    radial-gradient(900px 400px at -10% 110%, rgba(233,162,59,0.18), transparent 55%),
    linear-gradient(var(--bg), var(--bg2));
  position: relative;
  overflow: hidden;
}

/* header */
.th-header {
  background: linear-gradient(120deg, var(--teal), #0e5f58);
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 20;
}
[data-theme="dark"] .th-header { background: linear-gradient(120deg, #0d6b63, #06403c); }
.th-header-inner {
  max-width: 720px; margin: 0 auto;
  padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.th-brand { display: flex; align-items: center; gap: 10px; }
.th-logo { font-size: 30px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.25)); animation: steam 3s ease-in-out infinite; }
@keyframes steam { 0%,100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-2px) rotate(-4deg); } }
.th-title { font-weight: 900; font-size: 20px; line-height: 1; letter-spacing: .5px; }
.th-sub { font-size: 11px; opacity: .85; font-weight: 300; margin-top: 3px; }

.th-hactions { display: flex; align-items: center; gap: 8px; }
.th-online {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,.15); padding: 5px 9px; border-radius: 999px;
  white-space: nowrap;
}
.th-dot { width: 8px; height: 8px; border-radius: 50%; background: #7cf6b3; box-shadow: 0 0 0 0 rgba(124,246,179,.7); animation: pulse 2s infinite; }
.th-dot-off { background: #f0a; animation: none; box-shadow: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(124,246,179,.6);} 70% { box-shadow: 0 0 0 7px rgba(124,246,179,0);} 100% { box-shadow: 0 0 0 0 rgba(124,246,179,0);} }

.th-me {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.15); border: none; color: #fff;
  padding: 4px 8px 4px 4px; border-radius: 999px; cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 600;
}
.th-me:hover { background: rgba(255,255,255,.25); }
.th-mename { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-edit { font-size: 11px; opacity: .8; }
.th-theme {
  background: rgba(255,255,255,.15); border: none; border-radius: 50%;
  width: 34px; height: 34px; font-size: 16px; cursor: pointer;
}
.th-theme:hover { background: rgba(255,255,255,.28); }

.th-avatar {
  width: 34px; height: 34px; min-width: 34px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 13px;
  box-shadow: 0 2px 5px rgba(0,0,0,.18);
}

/* feed */
.th-feed { flex: 1; overflow-y: auto; padding: 14px 10px 4px; scroll-behavior: smooth; }
.th-feed-inner { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }

.th-row { display: flex; gap: 8px; align-items: flex-start; animation: slidein .35s cubic-bezier(.2,.8,.2,1); }
.th-row-mine { flex-direction: row-reverse; }
@keyframes slidein { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.th-bubwrap { max-width: 78%; display: flex; flex-direction: column; }
.th-bubwrap-mine { align-items: flex-start; }
.th-author { font-size: 12px; font-weight: 800; margin: 0 4px 3px; }

.th-quote {
  background: var(--panel2); border-inline-start: 3px solid var(--saffron);
  padding: 4px 8px; border-radius: 8px; margin-bottom: 4px;
  font-size: 11px; display: flex; flex-direction: column; gap: 1px;
}
.th-quote-name { color: var(--saffron-deep); font-weight: 700; }
.th-quote-text { color: var(--muted); }

.th-bubble {
  background: var(--panel); color: var(--ink);
  padding: 9px 13px; border-radius: 16px; border-top-right-radius: 4px;
  font-size: 15px; line-height: 1.65; box-shadow: var(--shadow);
  word-break: break-word; white-space: pre-wrap;
  border: 1px solid var(--line);
}
.th-bubble-mine {
  background: linear-gradient(135deg, var(--mine), #0c655d);
  color: var(--mine-ink); border: none;
  border-top-right-radius: 16px; border-top-left-radius: 4px;
}
[data-theme="dark"] .th-bubble-mine { background: linear-gradient(135deg, #0d6b63, #08514b); }

.th-meta { display: flex; align-items: center; gap: 10px; margin: 4px 4px 0; }
.th-time { font-size: 10px; color: var(--muted); }
.th-replybtn {
  background: none; border: none; color: var(--teal); font-family: inherit;
  font-size: 11px; font-weight: 700; cursor: pointer; padding: 0;
}
.th-replybtn:hover { text-decoration: underline; }

.th-reacts { display: flex; gap: 5px; margin: 5px 2px 0; flex-wrap: wrap; }
.th-react {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 999px;
  padding: 2px 8px; font-size: 13px; cursor: pointer; display: flex; align-items: center; gap: 4px;
  transition: transform .12s, background .15s;
}
.th-react:hover { transform: scale(1.12); }
.th-react:active { transform: scale(.9); }
.th-react-on { background: var(--saffron); border-color: var(--saffron-deep); }
.th-rcount { font-size: 11px; font-weight: 700; color: var(--ink); }
.th-react-on .th-rcount { color: #3a2600; }

/* empty */
.th-empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.th-empty-emoji { font-size: 52px; margin-bottom: 12px; animation: bob 2.5s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.th-empty-title { font-size: 18px; font-weight: 800; color: var(--ink); }
.th-empty-sub { font-size: 13px; margin-top: 4px; }

/* new pill */
.th-newpill {
  position: absolute; bottom: 108px; left: 50%; transform: translateX(-50%);
  background: var(--saffron); color: #3a2600; border: none;
  padding: 7px 16px; border-radius: 999px; font-family: inherit; font-weight: 800;
  font-size: 12px; cursor: pointer; box-shadow: var(--shadow); z-index: 15;
  animation: slidein .3s;
}

/* composer */
.th-composer {
  background: var(--panel); border-top: 1px solid var(--line);
  z-index: 20; box-shadow: 0 -6px 20px rgba(0,0,0,.06);
}
.th-replybar {
  max-width: 720px; margin: 0 auto; padding: 7px 14px 0;
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted);
}
.th-replybar-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-replybar-x {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 50%;
  width: 22px; height: 22px; cursor: pointer; color: var(--muted); font-size: 12px;
}
.th-composer-inner {
  max-width: 720px; margin: 0 auto; padding: 10px 12px;
  display: flex; align-items: flex-end; gap: 10px;
}
.th-input {
  flex: 1; resize: none; font-family: inherit; font-size: 15px; line-height: 1.5;
  padding: 11px 15px; border-radius: 18px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--ink); outline: none;
  max-height: 140px; transition: border .15s;
}
.th-input:focus { border-color: var(--teal); }
.th-input::placeholder { color: var(--muted); }
.th-send {
  width: 46px; height: 46px; min-width: 46px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, var(--saffron), var(--saffron-deep));
  color: #fff; font-size: 20px; cursor: pointer; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s;
}
.th-send:hover:not(:disabled) { transform: scale(1.08) rotate(-8deg); }
.th-send:active:not(:disabled) { transform: scale(.92); }
.th-send:disabled { opacity: .45; cursor: not-allowed; }
.th-spinner {
  width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.th-foot {
  max-width: 720px; margin: 0 auto; padding: 0 14px 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 10px;
}
.th-warn { color: #d4831f; font-weight: 600; }
.th-remix { color: var(--muted); text-decoration: none; margin-inline-start: auto; }
.th-remix:hover { color: var(--teal); text-decoration: underline; }

/* modal */
.th-modal-bg {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20,15,8,.55); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadein .25s;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.th-modal {
  background: var(--panel); border-radius: 22px; padding: 28px 24px;
  width: 100%; max-width: 360px; text-align: center; box-shadow: var(--shadow);
  border: 1px solid var(--line); animation: popin .35s cubic-bezier(.2,1.2,.4,1);
}
@keyframes popin { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.th-modal-emoji { font-size: 46px; margin-bottom: 6px; }
.th-modal-title { font-size: 20px; font-weight: 900; margin: 0; color: var(--ink); }
.th-modal-sub { font-size: 13px; color: var(--muted); margin: 6px 0 18px; }
.th-modal-input {
  width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--ink); font-family: inherit; font-size: 15px;
  outline: none; text-align: center; margin-bottom: 14px;
}
.th-modal-input:focus { border-color: var(--teal); }
.th-modal-btn {
  width: 100%; padding: 12px; border: none; border-radius: 14px;
  background: linear-gradient(135deg, var(--teal), #0c655d); color: #fff;
  font-family: inherit; font-weight: 800; font-size: 15px; cursor: pointer;
  transition: transform .12s;
}
.th-modal-btn:hover:not(:disabled) { transform: translateY(-2px); }
.th-modal-btn:disabled { opacity: .5; cursor: not-allowed; }

/* roses */
.th-roses { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.th-rose {
  position: absolute; top: -40px; font-size: 26px;
  animation-name: fall; animation-timing-function: ease-in; animation-fill-mode: forwards;
}
@keyframes fall {
  0% { transform: translateY(-40px) rotate(0deg); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translateY(105vh) rotate(360deg); opacity: 0; }
}

/* scrollbar */
.th-feed::-webkit-scrollbar { width: 8px; }
.th-feed::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
.th-feed::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 480px) {
  .th-title { font-size: 17px; }
  .th-mename { max-width: 54px; }
  .th-online { font-size: 10px; padding: 4px 7px; }
  .th-bubwrap { max-width: 82%; }
}