:root {
  --bg: #0f172a;
  --panel: rgba(15, 23, 42, 0.82);
  --panel-strong: #111c34;
  --line: rgba(148, 163, 184, 0.24);
  --text: #e5edf8;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --green: #22c55e;
  --red: #fb7185;
  --warning: #facc15;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(56, 189, 248, 0.18), transparent 280px),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

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

.app-shell {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 14px 12px 28px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: -14px -12px 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(15, 23, 42, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

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

.logo {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #60a5fa);
  color: #03101d;
  font-size: 0.82rem;
  font-weight: 950;
}

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

.brand h1 {
  font-size: 1.08rem;
  line-height: 1.15;
}

.brand p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
}

.nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  background: rgba(2, 6, 23, 0.32);
  border-radius: 14px;
}

.nav a {
  min-height: 42px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-decoration: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 900;
}

.nav a.active {
  color: #061525;
  background: var(--accent);
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 16px;
}

.card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 16px;
  box-shadow: none;
  backdrop-filter: blur(18px);
}

.control-card,
.chart-card,
.watchlist {
  padding: 16px;
}

.section-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 950;
}

h2 {
  font-size: 1.22rem;
  line-height: 1.2;
}

.supporting-copy,
.chart-header p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.field {
  margin-top: 16px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

input[type="text"] {
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  color: var(--text);
  background: rgba(2, 6, 23, 0.35);
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  outline: none;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segment {
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(2, 6, 23, 0.35);
  color: var(--text);
  font-weight: 950;
  cursor: pointer;
}

.segment.active {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.16);
  color: var(--accent);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.stat {
  min-width: 0;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(2, 6, 23, 0.32);
}

.stat span {
  color: var(--muted);
  font-size: 0.68rem;
}

.stat strong {
  display: block;
  margin-top: 5px;
  font-size: 0.98rem;
}

.actions {
  position: sticky;
  bottom: 0;
  z-index: 9;
  display: grid;
  gap: 12px;
  margin: 18px -16px -16px;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  background: rgba(15, 23, 42, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.primary,
.secondary {
  min-height: 56px;
  border-radius: 14px;
  padding: 14px 16px;
  font-weight: 950;
  cursor: pointer;
}

.primary {
  border: 0;
  background: linear-gradient(135deg, var(--accent), #60a5fa);
  color: #03101d;
}

.secondary {
  border: 1px solid rgba(56, 189, 248, 0.32);
  background: rgba(56, 189, 248, 0.12);
  color: #bae6fd;
}

.primary:disabled,
.secondary:disabled {
  opacity: 0.62;
  cursor: wait;
}

.chart-header,
.watch-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

.pill {
  width: fit-content;
  padding: 7px 10px;
  border: 1px solid rgba(34, 197, 94, 0.24);
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.14);
  color: #86efac;
  font-size: 0.76rem;
  font-weight: 950;
}

.pill.loading {
  border-color: rgba(250, 204, 21, 0.32);
  background: rgba(250, 204, 21, 0.12);
  color: #fde68a;
}

.pill.error {
  border-color: rgba(251, 113, 133, 0.36);
  background: rgba(251, 113, 133, 0.14);
  color: #fecdd3;
}

.chart-wrap {
  height: min(62vw, 300px);
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px),
    rgba(2, 6, 23, 0.26);
  background-size: 100% 55px, 64px 100%;
  overflow: hidden;
  padding: 12px;
}

svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.axis {
  stroke: rgba(226, 232, 240, 0.42);
  stroke-width: 1;
}

.threshold {
  stroke: rgba(226, 232, 240, 0.78);
  stroke-width: 2.5;
  stroke-dasharray: 7 7;
}

.threshold-label {
  fill: #e5edf8;
  font-size: 14px;
  font-weight: 950;
}

.curve {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.curve-above {
  stroke: var(--red);
  filter: drop-shadow(0 0 12px rgba(251, 113, 133, 0.34));
}

.curve-below {
  stroke: var(--accent);
  filter: drop-shadow(0 0 12px rgba(56, 189, 248, 0.42));
}

.dot {
  fill: #e0f2fe;
  stroke: var(--accent);
  stroke-width: 3;
}

.axis-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.7rem;
}

.mood-meter {
  margin-top: 14px;
}

.mood-title,
.mood-values {
  display: grid;
  align-items: center;
  gap: 8px;
}

.mood-title {
  grid-template-columns: 1fr auto 1fr;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.mood-title strong {
  padding: 5px 10px;
  border-radius: 10px;
  background: rgba(226, 232, 240, 0.12);
  color: var(--text);
  font-size: 0.78rem;
}

.mood-title span:last-child,
.mood-values span:last-child {
  text-align: right;
}

.mood-bar {
  display: flex;
  height: 26px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(2, 6, 23, 0.35);
}

.mood-fill {
  min-width: 0;
  transition: width 180ms ease;
}

.mood-fill.call {
  background: rgba(56, 189, 248, 0.78);
}

.mood-fill.put {
  background: rgba(251, 113, 133, 0.72);
}

.mood-values {
  grid-template-columns: 1fr 1fr;
  margin-top: 7px;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 950;
}

.legend {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.72rem;
}

.legend span {
  white-space: nowrap;
}

.legend span::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--red);
}

.legend .below::before {
  background: var(--accent);
}

.legend .neutral::before {
  background: rgba(226, 232, 240, 0.78);
}

.sorter {
  display: grid;
  gap: 8px;
  width: 100%;
  color: var(--muted);
  font-size: 0.84rem;
}

.watch-tools {
  display: grid;
  gap: 10px;
}

.refresh-watch {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(56, 189, 248, 0.32);
  border-radius: 14px;
  background: rgba(56, 189, 248, 0.12);
  color: #bae6fd;
  font-weight: 950;
  cursor: pointer;
}

.refresh-watch span {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  font-size: 1rem;
  line-height: 1;
}

.refresh-watch.loading span {
  animation: spin 900ms linear infinite;
}

.refresh-watch:disabled {
  opacity: 0.62;
  cursor: wait;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: var(--panel-strong);
  padding: 10px 12px;
  font-weight: 900;
}

.watch-grid {
  display: grid;
  gap: 12px;
}

.mini-card {
  position: relative;
  min-height: 220px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(2, 6, 23, 0.28);
}

.remove {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(251, 113, 133, 0.4);
  border-radius: 50%;
  background: rgba(251, 113, 133, 0.14);
  color: #fecdd3;
  font-size: 1.3rem;
  font-weight: 950;
  cursor: pointer;
}

.mini-symbol {
  padding-right: 48px;
  font-size: 1.16rem;
  font-weight: 950;
  letter-spacing: 0.08em;
}

.mini-date {
  margin-top: 4px;
  padding-right: 46px;
  color: var(--muted);
  font-size: 0.8rem;
}

.mini-chart {
  height: 96px;
  margin-top: 12px;
}

.mini-mood {
  margin-top: 10px;
}

.mini-mood-bar {
  display: flex;
  height: 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(2, 6, 23, 0.35);
}

.mini-mood-fill.call {
  background: rgba(56, 189, 248, 0.78);
}

.mini-mood-fill.put {
  background: rgba(251, 113, 133, 0.72);
}

.mini-mood-values {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.mini-status {
  margin-top: 8px;
  color: #fecdd3;
  font-size: 0.76rem;
  font-weight: 900;
}

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

@media (min-width: 720px) {
  body {
    background:
      radial-gradient(circle at top left, rgba(56, 189, 248, 0.24), transparent 34rem),
      radial-gradient(circle at 85% 15%, rgba(34, 197, 94, 0.12), transparent 28rem),
      var(--bg);
  }

  .app-shell {
    max-width: 1120px;
    padding: 32px 24px 48px;
  }

  .topbar {
    position: static;
    margin: 0 0 24px;
    flex-direction: row;
    justify-content: space-between;
    border: 0;
    border-radius: 20px;
  }

  .nav {
    width: 300px;
  }

  #main-page.view.active {
    grid-template-columns: 360px 1fr;
    align-items: start;
  }

  .actions {
    position: static;
    margin: 22px 0 0;
    padding: 0;
    background: transparent;
    border: 0;
    backdrop-filter: none;
  }

  .chart-wrap {
    height: 340px;
  }

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