:root {
  --bg: #f1eee7;
  --panel: rgba(251, 250, 246, 0.88);
  --panel-soft: #f4f0e8;
  --input: #fffdf9;
  --line: rgba(20, 20, 20, 0.08);
  --line-strong: rgba(20, 20, 20, 0.14);
  --ink: #141414;
  --muted: #6d685f;
  --green: #19c463;
  --green-soft: rgba(25, 196, 99, 0.12);
  --blue: #3b82f6;
  --blue-soft: rgba(59, 130, 246, 0.12);
  --gold: #d79d1c;
  --gold-soft: rgba(215, 157, 28, 0.16);
  --red: #e45b4a;
  --red-soft: rgba(228, 91, 74, 0.14);
  --shadow: 0 18px 45px rgba(48, 32, 12, 0.08);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(25, 196, 99, 0.08), transparent 18%),
    radial-gradient(circle at top right, rgba(59, 130, 246, 0.06), transparent 14%),
    linear-gradient(180deg, #f6f2ea 0%, #f0ece4 100%);
}

.hidden {
  display: none !important;
}

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

svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(520px, 100%);
  padding: 28px;
  border-radius: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.auth-copy,
.auth-hint {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.auth-user {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(17, 17, 17, 0.05);
  color: var(--ink);
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.google-btn {
  margin-top: 4px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 16px;
  background: #111111;
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.google-btn:hover {
  transform: translateY(-1px);
}

.app-shell {
  width: min(1500px, calc(100% - 24px));
  margin: 0 auto;
  padding: 18px 0 24px;
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  border-radius: 18px;
  background: rgba(251, 250, 246, 0.78);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.titlebar-tab {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 12px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.titlebar-tab:hover {
  transform: translateY(-1px);
  background: rgba(17, 17, 17, 0.05);
  color: var(--ink);
}

.titlebar-tab.is-active {
  background: #111111;
  color: #ffffff;
}

.topbar,
.panel,
.clock-box,
.feed-item,
.history-card,
.stat-card,
.account-box {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  padding: 18px 20px;
  margin-bottom: 14px;
  border-radius: var(--radius-xl);
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  margin-top: 8px;
  font-size: clamp(28px, 3vw, 42px);
  line-height: 0.95;
}

#build-version {
  display: inline-block;
  margin-left: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.06);
  font-size: 12px;
  font-weight: 700;
  vertical-align: middle;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 16px;
}

.subcopy {
  margin-top: 8px;
  max-width: 560px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}

.subcopy.quote-copy {
  max-width: 860px;
  line-height: 1.8;
  color: rgba(20, 20, 20, 0.72);
}

.quote-copy p + p {
  margin-top: 10px;
}

.topbar-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 10px;
}

.clock-box,
.nav-box,
.account-box {
  padding: 14px 16px;
  border-radius: 20px;
}

.clock-box span {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.clock-box strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.nav-box {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.nav-box span {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.nav-box a {
  justify-content: center;
}

.account-box {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.account-box span {
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}

#logout-btn {
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 12px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(380px, 1.02fr) minmax(430px, 0.98fr);
  gap: 14px;
  align-items: start;
}

.feed-column,
.plan-column {
  min-width: 0;
}

.panel {
  border-radius: var(--radius-xl);
  padding: 14px;
}

.panel + .panel {
  margin-top: 14px;
}

.panel-header,
.section-row,
.action-row,
.toolbar,
.feed-item-head,
.history-head,
.history-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.refresh-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.refresh-countdown {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.history-toolbar select {
  min-width: 180px;
}

.toolbar {
  margin-top: 10px;
}

.toolbar-item {
  min-width: 160px;
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 14px;
  background: var(--input);
  color: var(--ink);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(25, 196, 99, 0.4);
  box-shadow: 0 0 0 4px rgba(25, 196, 99, 0.08);
}

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

.mini-stats,
.stat-grid,
.meta-strip {
  display: grid;
  gap: 10px;
}

.mini-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 10px 0 4px;
}

.stat-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 12px 0;
}

.history-stats {
  margin-top: 12px;
  margin-bottom: 6px;
}

.stat-card {
  border-radius: 20px;
  padding: 14px;
}

.stat-card span {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.history-stats .stat-card {
  padding: 12px 14px;
}

.history-stats .stat-card strong {
  font-size: 18px;
  line-height: 1.1;
}

.trade-form {
  display: grid;
  gap: 14px;
}

.market-logic-note {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(17, 17, 17, 0.05);
  color: var(--muted);
  font-size: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.field.full {
  grid-column: 1 / -1;
}

.price-group,
.review-block {
  border-radius: 22px;
  padding: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.rr-box,
.meta-strip {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(25, 196, 99, 0.12);
  border: 1px solid rgba(25, 196, 99, 0.16);
  color: #0f9951;
  font-size: 13px;
  font-weight: 700;
}

.meta-strip {
  background: rgba(17, 17, 17, 0.04);
  border-color: transparent;
  color: var(--muted);
  font-weight: 500;
}

.section-row span {
  font-size: 12px;
  color: var(--muted);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.tiny-btn {
  border: none;
  border-radius: 16px;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.tiny-btn:hover {
  transform: translateY(-1px);
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  padding: 11px 14px;
}

.primary-btn {
  background: #111111;
  color: #fff;
  flex: 1;
}

.secondary-btn {
  background: rgba(17, 17, 17, 0.06);
  color: var(--ink);
}

.ghost-btn {
  background: rgba(17, 17, 17, 0.05);
  color: var(--ink);
}

.primary-btn:disabled,
.secondary-btn:disabled,
.ghost-btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
  transform: none;
}

.refresh-btn {
  background: #111111;
  color: #fff;
}

.collapse-btn {
  display: none;
}

.collapse-btn.is-active {
  background: rgba(17, 17, 17, 0.1);
}

.icon-text-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.feed-list,
.history-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.panel-feed.is-collapsed .toolbar,
.panel-feed.is-collapsed .mini-stats,
.panel-feed.is-collapsed .feed-list {
  display: none;
}

.feed-item,
.history-card {
  border-radius: 24px;
  padding: 16px;
}

.feed-item-head,
.history-head,
.history-foot {
  align-items: flex-start;
}

.feed-item-title-wrap {
  display: grid;
  gap: 6px;
}

.feed-source-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.feed-source-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.feed-avatar {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: rgba(17, 17, 17, 0.05);
}

.feed-badges,
.history-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.badge,
.market-tag,
.signal-tag {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.badge {
  background: rgba(17, 17, 17, 0.05);
  color: var(--muted);
}

.badge.hot,
.market-tag.crypto {
  background: var(--red-soft);
  color: var(--red);
}

.badge.focus,
.market-tag.us {
  background: var(--blue-soft);
  color: var(--blue);
}

.market-tag.hk {
  background: var(--green-soft);
  color: #0f9951;
}

.market-tag.cn {
  background: rgba(228, 91, 74, 0.12);
  color: #c84c3d;
}

.market-tag.macro {
  background: var(--gold-soft);
  color: #a9780e;
}

.feed-summary,
.history-thesis,
.history-meta {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.feed-summary-wrap {
  margin-top: 10px;
}

.feed-summary-wrap p {
  margin: 0;
}

.feed-expand-btn {
  margin-top: 10px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.feed-translation {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(17, 17, 17, 0.04);
  border: 1px solid var(--line);
}

.feed-translation span {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.feed-translation p {
  margin-top: 8px;
  color: var(--ink);
  line-height: 1.55;
  font-size: 13px;
}

.feed-media {
  margin-top: 12px;
  display: inline-block;
  width: auto;
  max-width: 50%;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: transparent;
}

.feed-media img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 180px;
  object-fit: contain;
  object-position: left center;
}

.feed-actions,
.history-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.feed-link {
  text-decoration: none;
}

.feed-title-link {
  color: var(--ink);
  text-decoration: none;
}

.feed-title-link:hover {
  text-decoration: underline;
}

.tiny-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-size: 12px;
  background: rgba(17, 17, 17, 0.06);
  color: var(--ink);
}

.tiny-btn.use {
  background: var(--green-soft);
  color: #0f9951;
}

.tiny-btn.view {
  text-decoration: none;
  background: rgba(17, 17, 17, 0.06);
  color: var(--ink);
}

.tiny-btn.delete {
  background: var(--red-soft);
  color: var(--red);
}

.icon-square {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(17, 17, 17, 0.05);
  color: var(--ink);
}

.empty-state {
  padding: 24px 16px;
  border-radius: 18px;
  border: 1px dashed var(--line-strong);
  text-align: center;
  color: var(--muted);
}

.save-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 30;
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(17, 17, 17, 0.92);
  color: #ffffff;
  border: 1px solid rgba(25, 196, 99, 0.22);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.18);
  font-size: 13px;
  font-weight: 700;
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.save-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.history-pnl {
  font-size: 26px;
  font-weight: 800;
}

.history-pnl-wrap {
  display: grid;
  justify-items: end;
  gap: 4px;
}

.history-pnl-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.history-pnl.positive {
  color: #0f9951;
}

.history-pnl.negative {
  color: var(--red);
}

.history-pnl.pending {
  color: var(--muted);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-meta {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .subcopy.quote-copy {
    max-width: 100%;
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 16px, 1500px);
    padding-top: 14px;
  }

  .titlebar {
    overflow-x: auto;
  }

  .topbar-meta,
  .stat-grid,
  .mini-stats,
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }

  .panel {
    padding: 12px;
  }

  .refresh-stack {
    width: 100%;
    align-items: stretch;
  }

  .collapse-btn {
    display: inline-flex;
  }

  .refresh-btn,
  .collapse-btn,
  .history-toolbar button,
  .history-toolbar select {
    width: 100%;
  }

  .feed-media {
    max-width: 76%;
  }

  .panel-header,
  .section-row,
  .action-row,
  .history-toolbar,
  .feed-item-head,
  .history-head,
  .history-foot {
    flex-direction: column;
    align-items: stretch;
  }

  .time-pill {
    margin-left: 0;
  }
}

@media (max-width: 560px) {
  body {
    overflow-x: hidden;
  }

  h1 {
    font-size: 24px;
    line-height: 1.08;
  }

  .topbar,
  .panel,
  .feed-item,
  .history-card,
  .stat-card,
  .clock-box,
  .account-box {
    border-radius: 18px;
  }

  .topbar-meta,
  .stat-grid,
  .mini-stats,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 14px;
    gap: 14px;
  }

  .subcopy,
  .subcopy.quote-copy {
    max-width: 100%;
    font-size: 12px;
    line-height: 1.72;
  }

  .panel-header {
    gap: 10px;
  }

  .history-toolbar {
    width: 100%;
  }

  .history-toolbar > * {
    width: 100%;
  }

  .account-box {
    width: 100%;
    padding: 12px 14px;
  }

  .account-box span {
    font-size: 12px;
  }

  #logout-btn {
    padding: 7px 9px;
    font-size: 11px;
  }

  .feed-item,
  .history-card {
    padding: 14px;
  }

  .panel-feed.is-collapsed {
    padding-bottom: 12px;
  }

  .feed-item-head {
    gap: 10px;
  }

  .feed-source-meta {
    gap: 6px;
  }

  .feed-source-name {
    font-size: 12px;
  }

  .feed-summary,
  .history-thesis,
  .history-meta {
    font-size: 13px;
  }

  .feed-media {
    max-width: 100%;
  }

  .feed-media img {
    max-height: 160px;
  }

  .primary-btn,
  .secondary-btn,
  .ghost-btn {
    width: 100%;
  }

  .action-row {
    gap: 8px;
  }

  .clock-box strong,
  .history-pnl {
    font-size: 22px;
  }

  .save-toast {
    left: 12px;
    right: 12px;
    bottom: 12px;
    transform: translate(0, 16px);
  }

  .save-toast.is-visible {
    transform: translate(0, 0);
  }
}
