:root {
  color-scheme: light;
  --bg: #f7fbf6;
  --surface: #ffffff;
  --surface-soft: #eff8ef;
  --surface-strong: #dff1df;
  --text: #17231a;
  --muted: #667266;
  --line: #dce8dc;
  --green: #70c98b;
  --green-deep: #2f8f58;
  --mint: #c9f0d2;
  --red: #df5b6a;
  --blue: #4a88d8;
  --yellow: #bd8b2e;
  --shadow: 0 14px 34px rgba(48, 97, 58, 0.12);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f7fbf6 0%, #eef8ef 100%);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px 96px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 18px;
}

.topbar h1,
.section-heading h2,
.dialog-header h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 31px;
  font-weight: 900;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green-deep);
  font-size: 12px;
  font-weight: 800;
}

.icon-button,
.text-button,
.primary-button,
.nav-item {
  border: 0;
  cursor: pointer;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--green-deep);
  font-size: 23px;
  font-weight: 800;
}

.text-button {
  border-radius: 999px;
  background: var(--mint);
  color: var(--green-deep);
  padding: 10px 14px;
  font-weight: 900;
}

.primary-button {
  width: 100%;
  border-radius: 14px;
  background: var(--green);
  color: #ffffff;
  padding: 14px 16px;
  font-weight: 900;
}

main {
  min-height: calc(100vh - 170px);
}

.tab-panel {
  display: none;
  animation: fadeIn 0.18s ease-out;
}

.tab-panel.active {
  display: grid;
  gap: 14px;
}

.hero-panel,
.tab-panel > .section-heading,
.summary-grid article,
.brief-card,
.stock-card,
.source-card,
.setting-row,
.insight-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 18px;
  background: linear-gradient(135deg, #ffffff 0%, #ebf8ed 100%);
}

.tab-panel > .section-heading {
  padding: 16px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0;
}

.section-heading h2 {
  font-size: 20px;
}

.status-pill,
.tag,
.source-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--surface-soft);
  color: var(--green-deep);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.brief-score {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.brief-score > div {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.brief-score span,
.summary-grid span,
.stock-meta,
.source-card p,
.insight-card p {
  color: var(--muted);
  font-size: 13px;
}

.brief-score strong {
  color: var(--green-deep);
  font-size: 46px;
  line-height: 1;
}

.brief-score p {
  margin: 0;
  color: #314237;
  line-height: 1.48;
}

.brief-grid,
.stock-list,
.source-list,
.settings-list,
.insight-list {
  display: grid;
  gap: 10px;
}

.brief-card,
.stock-card,
.source-card,
.setting-row,
.insight-card {
  padding: 14px;
}

.brief-card h3,
.stock-card h3,
.source-card h3,
.insight-card h3 {
  margin: 0 0 7px;
  font-size: 16px;
}

.brief-card p,
.source-card p,
.insight-card p {
  margin: 0;
  line-height: 1.45;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.summary-grid article {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.summary-grid strong {
  font-size: 16px;
}

.stock-card {
  display: grid;
  gap: 12px;
}

.stock-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.stock-price {
  text-align: right;
}

.stock-price strong {
  display: block;
  margin-bottom: 4px;
  font-size: 20px;
}

.stock-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.positive {
  color: var(--red);
}

.negative {
  color: var(--blue);
}

.neutral {
  color: var(--yellow);
}

.action-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.setting-row strong {
  display: block;
  color: var(--text);
  font-size: 15px;
}

.setting-row em {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-style: normal;
  font-weight: 600;
  line-height: 1.4;
}

.setting-row input {
  appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 48px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #e4ece4;
  padding: 0;
}

.setting-row input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #aab7aa;
  transition: transform 0.18s ease, background 0.18s ease;
}

.setting-row input:checked {
  background: var(--mint);
}

.setting-row input:checked::after {
  transform: translateX(20px);
  background: var(--green-deep);
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
}

.nav-item {
  display: grid;
  flex: 1;
  max-width: 122px;
  gap: 3px;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  padding: 8px 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 900;
}

.nav-item span {
  color: #b8c8b8;
  font-size: 13px;
  line-height: 1;
}

.nav-item.active {
  background: var(--surface-strong);
  color: var(--green-deep);
}

.nav-item.active span {
  color: var(--green-deep);
}

dialog {
  width: min(calc(100% - 28px), 460px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
}

dialog::backdrop {
  background: rgba(25, 43, 31, 0.38);
}

form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfefb;
  color: var(--text);
  padding: 13px 12px;
}

input:focus {
  border-color: var(--green);
  outline: 3px solid rgba(112, 201, 139, 0.22);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  .stock-row {
    display: grid;
  }

  .stock-price {
    text-align: left;
  }
}
