/* Twin Indonesia (codename Satu) — mobile-first styles. No build step, no external fonts. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #ccfbf1;
  --up: #15803d;
  --up-soft: #dcfce7;
  --down: #b91c1c;
  --down-soft: #fee2e2;
  --warn: #92400e;
  --warn-soft: #fef3c7;
  --info: #3730a3;
  --info-soft: #e0e7ff;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(15 23 42 / 6%), 0 4px 16px rgb(15 23 42 / 6%);
  --tabbar: 64px;
  color-scheme: light;
}

/* Twin's theme switch (theme.js) sets data-theme on <html>; the media query is
   only the fallback when this page is opened without it. */
:root[data-theme="dark"] {
    --bg: #0b1220;
    --surface: #111a2c;
    --surface-2: #0f1727;
    --line: #22304a;
    --text: #e5edf7;
    --muted: #93a3bb;
    --brand: #2dd4bf;
    --brand-ink: #042f2e;
    --brand-soft: #134e4a;
    --up: #4ade80;
    --up-soft: #14532d;
    --down: #f87171;
    --down-soft: #4c1d1d;
    --warn: #fbbf24;
    --warn-soft: #422006;
    --info: #a5b4fc;
    --info-soft: #1e2a4a;
    --shadow: none;
    color-scheme: dark;
  }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0b1220;
    --surface: #111a2c;
    --surface-2: #0f1727;
    --line: #22304a;
    --text: #e5edf7;
    --muted: #93a3bb;
    --brand: #2dd4bf;
    --brand-ink: #042f2e;
    --brand-soft: #134e4a;
    --up: #4ade80;
    --up-soft: #14532d;
    --down: #f87171;
    --down-soft: #4c1d1d;
    --warn: #fbbf24;
    --warn-soft: #422006;
    --info: #a5b4fc;
    --info-soft: #1e2a4a;
    --shadow: none;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0 0 8px;
}

h1 {
  font-size: 1.45rem;
}

h2 {
  font-size: 1.1rem;
}

h3 {
  font-size: 1rem;
}

p {
  margin: 0 0 8px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.tiny {
  font-size: 0.75rem;
}

.up {
  color: var(--up);
}

.down {
  color: var(--down);
}

.num {
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- layout */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand-text small {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--brand);
  color: var(--brand-ink);
  display: grid;
  place-items: center;
  font-size: 0.95rem;
}

.topbar .spacer {
  flex: 1;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-chip .dot {
  flex: none;
}

.lbl-short {
  display: none;
}

/* Phones: short labels so brand, demo badge, data chip, plan and avatar fit
   on one line down to 320px wide. */
@media (max-width: 520px) {
  .topbar {
    gap: 6px;
    padding: 10px 12px;
  }

  .topbar .lbl-long {
    display: none;
  }

  .topbar .lbl-short {
    display: inline;
  }

  .topbar .badge {
    flex: none;
  }
}

@media (max-width: 360px) {
  .topbar .status-chip {
    padding: 4px 7px;
  }

  .topbar .status-chip .lbl-short {
    display: none;
  }
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.dot.live {
  background: var(--up);
}

.dot.sim {
  background: #a855f7;
}

.avatar-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  font-weight: 700;
}

.shell {
  display: block;
}

.view {
  padding: 16px 16px calc(var(--tabbar) + 24px);
  max-width: 1080px;
  margin: 0 auto;
}

.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  height: var(--tabbar);
  display: flex;
  justify-content: space-around;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  text-decoration: none;
}

.nav a .ico {
  font-size: 1.25rem;
  line-height: 1;
}

.nav a.active {
  color: var(--brand);
  font-weight: 700;
}

@media (min-width: 960px) {
  .shell {
    display: grid;
    grid-template-columns: 220px 1fr;
  }

  .nav {
    position: sticky;
    top: 57px;
    height: calc(100vh - 57px);
    flex-direction: column;
    justify-content: flex-start;
    gap: 4px;
    padding: 16px 12px;
    border-top: 0;
    border-right: 1px solid var(--line);
    background: transparent;
  }

  .nav a {
    flex: 0;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.95rem;
  }

  .nav a.active {
    background: var(--brand-soft);
  }

  .view {
    padding: 24px 28px 48px;
  }
}

.grid-2 {
  display: grid;
  gap: 14px;
}

.grid-3 {
  display: grid;
  gap: 14px;
}

/* Grid items default to min-width:auto, so a long nowrap subtitle would widen
   the column past a phone screen. Let them shrink and ellipsize instead. */
.grid-2 > *,
.grid-3 > * {
  min-width: 0;
}

@media (min-width: 760px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }

  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.stack > * + * {
  margin-top: 14px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row.wrap {
  flex-wrap: wrap;
}

.row.between {
  justify-content: space-between;
}

.grow {
  flex: 1;
  min-width: 0;
}

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.card.flat {
  box-shadow: none;
}

.card.hero {
  background: linear-gradient(135deg, var(--brand) 0%, #115e59 100%);
  color: #ffffff;
  border: 0;
}

.card.hero .muted {
  color: rgb(255 255 255 / 78%);
}

.card.hero .up,
.card.hero .down {
  color: #ffffff;
  font-weight: 700;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 22px 0 10px;
}

.section-title h2 {
  margin: 0;
}

.big-number {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 760px) {
  .kpis {
    grid-template-columns: repeat(4, 1fr);
  }
}

.kpi {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.kpi .label {
  font-size: 0.75rem;
  color: var(--muted);
}

.kpi .value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* allocation bar */
.alloc {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgb(255 255 255 / 25%);
  margin: 12px 0 6px;
}

.alloc span {
  display: block;
  height: 100%;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 0.78rem;
}

.legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: -1px;
}

/* ----------------------------------------------------------------- lists */

.list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  background: transparent;
  width: 100%;
  text-align: left;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
}

.list-item:first-child {
  border-top: 0;
}

.list-item:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.sym-badge {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.72rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  letter-spacing: -0.02em;
}

.sym-badge.US {
  background: #e0e7ff;
  color: #3730a3;
}

.sym-badge.IDX {
  background: #fee2e2;
  color: #991b1b;
}

.sym-badge.CRYPTO {
  background: #ede9fe;
  color: #5b21b6;
}

.sym-badge.GOLD {
  background: #fef3c7;
  color: #92400e;
}

/* Drawn market marks (see MARKET_ICONS in app.js). */
.micon {
  display: inline-block;
  flex: none;
  width: 1.5em;
  height: 1em;
  vertical-align: -0.14em;
}

.micon.flag {
  border-radius: 0.16em;
  box-shadow: 0 0 0 1px rgba(127, 127, 127, 0.35);
}

.mlabel {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

.li-main {
  flex: 1;
  min-width: 0;
}

.li-main > span,
.li-right > span {
  display: block;
}

.li-title {
  font-weight: 700;
}

.li-sub {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.li-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.spark {
  width: 72px;
  height: 28px;
  flex: none;
}

/* --------------------------------------------------------------- controls */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  font-weight: 650;
  text-decoration: none;
  color: var(--text);
}

.btn:hover {
  text-decoration: none;
  background: var(--surface-2);
}

.btn.primary {
  background: var(--brand);
  color: var(--brand-ink);
  border-color: transparent;
}

.btn.primary:hover {
  filter: brightness(1.05);
}

.btn.buy {
  background: var(--up);
  color: #ffffff;
  border-color: transparent;
}

.btn.sell {
  background: var(--down);
  color: #ffffff;
  border-color: transparent;
}

.btn.ghost {
  background: transparent;
}

.btn.small {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 0.82rem;
}

.btn.block {
  width: 100%;
}

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.chip {
  flex: none;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
  color: var(--text);
  text-decoration: none;
}

.chip.active {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}

.chip:hover {
  text-decoration: none;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.segmented button {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}

.segmented button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.segmented button.active.buy {
  background: var(--up);
  color: #ffffff;
}

.segmented button.active.sell {
  background: var(--down);
  color: #ffffff;
}

label.field {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 10px;
}

label.field > span {
  display: block;
  margin-bottom: 4px;
}

input[type="text"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
.btn:focus-visible,
.chip:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--brand);
}

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.toggle:first-child {
  border-top: 0;
}

/* ------------------------------------------------------------- badges etc */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.badge.brand {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: transparent;
}

.badge.up {
  background: var(--up-soft);
  color: var(--up);
  border-color: transparent;
}

.badge.down {
  background: var(--down-soft);
  color: var(--down);
  border-color: transparent;
}

.badge.warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: transparent;
}

.badge.info {
  background: var(--info-soft);
  color: var(--info);
  border-color: transparent;
}

.notice {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.notice.warn {
  background: var(--warn-soft);
  border-color: transparent;
  color: var(--warn);
}

.notice.error {
  background: var(--down-soft);
  border-color: transparent;
  color: var(--down);
}

.notice.ok {
  background: var(--up-soft);
  border-color: transparent;
  color: var(--up);
}

.notice.info {
  background: var(--info-soft);
  border-color: transparent;
}

.notice ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--brand);
}

.lock {
  filter: blur(4px);
  user-select: none;
  pointer-events: none;
}

.paywall {
  text-align: center;
  padding: 22px 16px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 22px 12px;
}

hr.sep {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 12px 0;
}

/* ---------------------------------------------------------------- charts */

.chart-wrap {
  position: relative;
  width: 100%;
  height: 220px;
  touch-action: pan-y;
}

.chart-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-tip {
  position: absolute;
  top: 4px;
  left: 8px;
  font-size: 0.78rem;
  color: var(--muted);
  pointer-events: none;
}

.chart-cursor {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--muted);
  opacity: 0.5;
  pointer-events: none;
  display: none;
}

/* ----------------------------------------------------------------- posts */

.post {
  padding: 14px;
  border-top: 1px solid var(--line);
}

.post:first-child {
  border-top: 0;
}

.post-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.post-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.post-text {
  white-space: pre-wrap;
  word-wrap: break-word;
}

.post-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.shielded {
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.85rem;
}

/* ----------------------------------------------------------------- learn */

.lesson-card {
  display: flex;
  gap: 12px;
  align-items: center;
}

.lesson-num {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.lesson-num.done {
  background: var(--up);
  color: #ffffff;
  border-color: transparent;
}

.quiz-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  margin: 6px 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}

.quiz-option.correct {
  background: var(--up-soft);
  border-color: var(--up);
}

.quiz-option.wrong {
  background: var(--down-soft);
  border-color: var(--down);
}

.widget {
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

/* ---------------------------------------------------------------- modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgb(2 6 23 / 55%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal {
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 18px 18px 22px;
}

@media (min-width: 760px) {
  .modal-backdrop {
    align-items: center;
  }

  .modal {
    border-radius: 18px;
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.close-x {
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.preview-table td {
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}

.preview-table td:last-child {
  text-align: right;
}

.preview-table tr.total td {
  font-weight: 800;
  border-bottom: 0;
}

/* ---------------------------------------------------------------- toast */

.toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabbar) + 16px);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 420px);
}

.toast {
  background: var(--text);
  color: var(--surface);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--down);
  color: #ffffff;
}

.toast.ok {
  background: var(--up);
  color: #ffffff;
}

/* ----------------------------------------------------------- onboarding */

.onboard {
  max-width: 560px;
  margin: 0 auto;
  padding: 28px 18px 40px;
}

.onboard .hero-title {
  font-size: 2rem;
  font-weight: 850;
  letter-spacing: -0.03em;
  margin: 18px 0 8px;
}

.pick {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  width: 100%;
  text-align: left;
  margin-bottom: 10px;
}

.pick.selected {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.pick .pick-ico {
  font-size: 1.6rem;
  line-height: 1;
}

.steps {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.steps span {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
}

.steps span.on {
  background: var(--brand);
}

.plan-card.current {
  outline: 2px solid var(--brand);
}

.price-tag {
  font-size: 1.6rem;
  font-weight: 800;
}

.feature-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 14px;
}

.feature-list li {
  padding: 4px 0 4px 22px;
  position: relative;
  font-size: 0.9rem;
}

.feature-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--brand);
  font-weight: 800;
}

.footnote {
  margin-top: 24px;
  font-size: 0.75rem;
  color: var(--muted);
}

@media print {
  .nav,
  .topbar {
    display: none;
  }
}
