@import url("/partials/ui-tokens.css?v=force-20261119151405");

:root {
  color-scheme: light;
  --ink: #111118;
  --muted: #6d5f52;
  --paper: #f7f1e6;
  --card: rgba(255, 252, 246, 0.86);
  --line: rgba(90, 76, 64, 0.14);
  --charcoal: #1d232b;
  --pill-bg: #efe6d8;
  --shadow: 0 18px 40px rgba(15, 20, 28, 0.1);
  --radius-lg: 18px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #fff1d6 0%, #f2e6d5 40%, #e3d6c5 80%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: "Avenir Next", "Gill Sans", "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.page {
  display: grid;
  gap: 0.8rem;
  padding: 0.9rem clamp(0.8rem, 2.5vw, 1.6rem);
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
}

.stocks-shell {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.stocks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.stocks-title {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.market-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.market-status[hidden] {
  display: none;
}

/* Neutral status dot: filled when open, hollow when closed (shape, not colour). */
.market-status::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  border: 1.5px solid currentColor;
  box-sizing: border-box;
}

.market-status[data-open="true"]::before {
  background: currentColor;
}

.stocks-header h1 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}

.stocks-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.icon-button {
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 999px;
  background: #f1e3cf;
  color: #3f342b;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-button:hover {
  background: #e6d4bc;
}

.icon-button svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button.spinning svg {
  animation: spin 0.9s linear infinite;
}

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

.add-form {
  display: flex;
  gap: 0.5rem;
}

.add-form input {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font: inherit;
  font-size: 1rem; /* >=16px avoids mobile zoom on focus */
  text-transform: uppercase;
  color: var(--ink);
}

.add-form input::placeholder {
  text-transform: none;
  color: #9a8b7c;
}

.add-form input:focus {
  outline: 2px solid var(--charcoal);
  outline-offset: 1px;
}

.primary-button,
.ghost-button,
.danger-button {
  border: none;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
}

.primary-button {
  background: var(--charcoal);
  color: #fff8ef;
}

.add-form .primary-button {
  padding: 0.7rem 1.3rem;
  font-size: 0.95rem;
}

.primary-button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.ghost-button {
  background: #f1e3cf;
  color: #5a4c40;
}

.ghost-button:hover:not(:disabled) {
  background: #e6d4bc;
  color: #3f342b;
}

.ghost-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.danger-button {
  background: #c94a3a;
  color: #fff;
}

.small {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

.range-switcher {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: #f1e3cf;
}

.range-switcher button {
  border: none;
  border-radius: 999px;
  padding: 0.45rem 0;
  background: transparent;
  color: #5a4c40;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.range-switcher button[aria-checked="true"] {
  background: #fffaf2;
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(15, 20, 28, 0.08);
}

.range-switcher button:focus-visible {
  outline: 2px solid var(--charcoal);
  outline-offset: 1px;
}

/* Chart grid: plot + price gutter on top, time labels + corner below. */
.spark {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 4.4rem;
  grid-template-rows: auto 1.1rem;
  column-gap: 0.45rem;
}

.spark-svg {
  width: 100%;
  height: 96px;
  display: block;
  overflow: visible;
}

.spark-line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.75;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.spark-base {
  stroke: #9c8b76;
  stroke-width: 1;
  stroke-dasharray: 3 4;
  vector-effect: non-scaling-stroke;
}

.spark-grid {
  stroke: rgba(90, 76, 64, 0.07);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.spark-grid.major {
  stroke: rgba(90, 76, 64, 0.14);
}

.spark-plot {
  position: relative;
  border-bottom: 1px solid var(--line);
}

.spark-dot {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--ink);
  transform: translate(-50%, -50%);
}

.spark-y,
.spark-x {
  position: relative;
  font-size: 0.68rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.spark-y span {
  position: absolute;
  left: 0;
  transform: translateY(-50%);
  line-height: 1;
}

/* The reference price wears the same dashes as its line. */
.spark-y span.ref {
  padding-bottom: 1px;
  border-bottom: 1px dashed #9c8b76;
}

.spark-x span {
  position: absolute;
  top: 0.25rem;
  transform: translateX(-50%);
  line-height: 1;
}

.spark-x span.start {
  transform: none;
}

.spark-x span.end {
  transform: translateX(-100%);
}

.spark-corner {
  padding-top: 0.25rem;
  font-size: 0.68rem;
  line-height: 1;
  color: var(--muted);
}

.spark-empty {
  display: grid;
  height: 96px;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  color: var(--muted);
  background: rgba(241, 227, 207, 0.35);
  border-radius: var(--radius-md);
}

.banner {
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-md);
  background: #fff4dd;
  color: #7a4a1c;
  font-size: 0.9rem;
}

.pull-indicator {
  height: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.8rem;
  opacity: 0.5;
  transition: opacity 0.15s ease;
}

.pull-indicator.ready {
  opacity: 1;
}

.quote-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.quote-list:empty {
  display: none;
}

.quote-row {
  position: relative;
  background: var(--card);
}

.quote-row + .quote-row {
  border-top: 1px solid var(--line);
}

.quote-top {
  display: flex;
  align-items: stretch;
}

.drag-handle {
  flex: 0 0 auto;
  width: 2.4rem;
  border: none;
  background: transparent;
  color: #b3a491;
  display: grid;
  place-items: center;
  cursor: grab;
  touch-action: none; /* let pointer events drive the drag on touch screens */
  padding: 0 0 0 0.4rem;
}

.drag-handle svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: currentColor;
}

.drag-handle:hover,
.drag-handle:focus-visible {
  color: #5a4c40;
}

.drag-handle:focus-visible {
  outline: 2px solid var(--charcoal);
  outline-offset: -4px;
  border-radius: 8px;
}

.reordering .quote-row {
  transition: transform 0.15s ease;
}

.reordering .quote-row.dragging {
  transition: none;
  z-index: 2;
  box-shadow: 0 10px 28px rgba(15, 20, 28, 0.18);
  border-radius: var(--radius-md);
}

.reordering,
.reordering * {
  cursor: grabbing !important;
  user-select: none;
}

.quote-main {
  width: 100%;
  display: grid;
  flex: 1;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) auto 6.2rem;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 1rem 0.8rem 0.35rem;
  border: none;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.quote-main:hover {
  background: rgba(241, 227, 207, 0.45);
}

.quote-ident {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.quote-name {
  font-size: 0.78rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quote-symbol {
  font-weight: 650;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quote-price {
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  text-align: right;
}

.quote-change {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-width: 6.2rem;
  padding: 0.3rem 0.5rem;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--pill-bg);
  color: var(--ink);
}

.spark-empty.spark-note {
  height: auto;
  padding: 0.55rem 0.75rem;
}

.quote-change .arrow {
  font-size: 0.65rem;
}

.quote-change[data-dir="error"] {
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}

.quote-detail {
  padding: 0 1rem 1rem 2.75rem;
  display: grid;
  gap: 0.9rem;
}

/* Stats come in three pairs (reference, low/high, change). Wide: one column
   per pair, the two values stacked. Narrow: one row per pair. */
.detail-stats {
  display: grid;
  grid-template-columns: repeat(var(--groups, 3), minmax(0, 1fr));
}

.detail-group {
  margin: 0;
  display: grid;
  gap: 0.7rem;
  padding: 0 1rem;
  border-left: 1px solid var(--line);
}

.detail-group:first-child {
  padding-left: 0;
  border-left: 0;
}

.ref-swatch {
  display: inline-block;
  width: 0.9rem;
  margin-right: 0.35rem;
  vertical-align: middle;
  border-top: 1.5px dashed #9c8b76;
}

/* Each stat is a small label stacked directly above its value, so the pair
   reads as one unit instead of being split across the row. */
.detail {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.detail dt {
  color: var(--muted);
  font-size: 0.75rem;
}

.detail dd {
  margin: 0;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.detail-actions {
  position: relative;
  display: flex;
  justify-content: flex-end;
  margin-top: -0.4rem;
}

/* Quiet "⋯" button, same look as the Notes/Chat list menus. */
.row-menu-button {
  width: 2rem;
  height: 1.8rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: #7b6f63;
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.row-menu-button:hover,
.row-menu-button[aria-expanded="true"] {
  border-color: var(--line);
  background: #fffaf2;
  color: #3f342b;
}

.row-menu-button:focus-visible {
  outline: 2px solid var(--charcoal);
  outline-offset: 1px;
}

/* Opens upward over the tile's stats, so the list's rounded clipping never
   cuts it off. */
.row-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.3rem);
  min-width: 190px;
  padding: 0.3rem;
  background: #fff;
  border: 1px solid #ecdcc7;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 22px rgba(51, 33, 21, 0.12);
  z-index: 5;
}

.row-menu-item {
  display: block;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #4c3a2e;
  font: inherit;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
}

.row-menu-item:hover,
.row-menu-item:focus-visible {
  background: #f4e5d6;
  outline: none;
}

.row-menu-item--top::before {
  content: "\2191";
  display: inline-block;
  width: 1.3rem;
}

.row-menu-item--remove::before {
  content: "\1F5D1";
  display: inline-block;
  width: 1.3rem;
}

.muted {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.empty-state {
  padding: 1.25rem;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  text-align: center;
}

.empty-state p {
  margin: 0 0 0.9rem;
  color: var(--muted);
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.chip {
  border: 1px solid var(--line);
  background: #fffaf2;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.chip:hover {
  background: #f1e3cf;
}


@media (max-width: 480px) {
  .stocks-header h1 {
    font-size: 1.3rem;
  }

  .quote-main {
    grid-template-columns: minmax(0, 1fr) auto 5.6rem;
    gap: 0.5rem;
    padding: 0.8rem 0.85rem 0.8rem 0.2rem;
  }

  .drag-handle {
    width: 2.1rem;
  }

  .quote-change {
    min-width: 5.6rem;
    font-size: 0.85rem;
  }

  .detail-stats {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.7rem;
  }

  .detail-group,
  .detail-group:first-child {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    padding: 0.7rem 0 0;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .detail-group:first-child {
    padding-top: 0;
    border-top: 0;
  }

  .spark {
    grid-template-columns: minmax(0, 1fr) 3.9rem;
  }
}

/* Installed app (no browser chrome): a little more breathing room up top. */
@media (display-mode: standalone) {
  .page {
    padding-top: max(0.9rem, env(safe-area-inset-top));
  }
}
