:root {
  --paper: #fffdf8;
  --ink: #102230;
  --muted: #5f6e7b;
  --line: #dfd6ca;
  --accent: #0d8b78;
  --accent-soft: #ddf4ef;
  --danger: #c94b3d;
  --shadow: 0 10px 30px rgba(16, 34, 48, 0.08);
  --trade-columns: 3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 10% 10%, #fff8ed 0, #f3f0e9 40%, #ede7dc 100%);
  min-height: 100vh;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(to right, rgba(16, 34, 48, 0.03) 1px, transparent 1px), linear-gradient(to bottom, rgba(16, 34, 48, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: -1;
}

.shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  border-right: 1px solid var(--line);
  padding: 1.2rem;
  background: rgba(255, 253, 248, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.brand { display: flex; gap: 0.75rem; align-items: center; }
.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(150deg, #0d8b78, #1260a8);
  color: white;
  font-weight: 800;
  display: grid;
  place-items: center;
}
.brand h1 { margin: 0; font-family: "Manrope", sans-serif; font-size: 1.2rem; }
.brand p { margin: 0; color: var(--muted); font-size: 0.9rem; }

.menu { display: grid; gap: 0.45rem; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-align: left;
  background: transparent;
  border: 0;
  font: inherit;
  color: var(--ink);
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  cursor: pointer;
  position: relative;
}
.menu-icon {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  background: #fffaf0;
  flex: 0 0 auto;
}
.menu-icon svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}
.menu-item.active,
.menu-item:hover { background: var(--accent-soft); color: #096757; }
.late-badge {
  margin-left: auto;
  min-width: 22px;
  padding: 0 0.35rem;
  height: 22px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: #ffe5e5;
  color: #b94747;
  border: 1px solid #efcaca;
  font-size: 0.82rem;
  font-weight: 800;
}
.review-shell {
  padding: 1rem;
}
.review-queue {
  display: grid;
  gap: 0.8rem;
}
.review-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
  background: #fff;
}
.review-card-kicker {
  display: inline-block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.review-card h3 {
  margin: 0;
  font-family: "Manrope", sans-serif;
  font-size: 1.15rem;
}
.review-card p {
  margin: 0.3rem 0 0;
  color: var(--muted);
}
.review-card-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sidebar-card {
  margin-top: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: var(--shadow);
}
.sidebar-card h3, .sidebar-card p { margin: 0; }
.sidebar-card p { margin-top: 0.35rem; color: var(--muted); }

.content { padding: 2rem; }
.view { display: none; }
.view.active { display: grid; gap: 1rem; }

.topbar { display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
#strategiesView .topbar,
#systemsView .topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 1.25rem;
}
#strategiesView .topbar > div:first-child,
#systemsView .topbar > div:first-child {
  min-width: 0;
}
.topbar h2 { margin: 0; font-family: "Manrope", sans-serif; font-size: clamp(1.7rem, 2.8vw, 2.6rem); }
.topbar p { margin: 0.2rem 0 0; color: var(--muted); }

.top-actions { display: flex; gap: 0.65rem; flex-wrap: wrap; justify-content: flex-end; }
#strategiesView .top-actions,
#systemsView .top-actions {
  align-items: flex-start;
  align-self: start;
  justify-self: end;
  justify-content: flex-end;
  flex-wrap: nowrap;
  margin-top: 0;
}
.danger-soft {
  background: #fff1f1;
  border-color: #efcaca;
  color: #b94747;
}
.danger-soft:hover {
  background: #ffe7e7;
}

button, input, select, textarea { font: inherit; }
button {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.68rem 1rem;
  background: var(--paper);
  cursor: pointer;
}
button.primary { border-color: transparent; background: linear-gradient(135deg, #0c8e7a, #0f7db8); color: white; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.8rem; }
.stat-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: var(--shadow);
}
.stat-card span { display: block; color: var(--muted); font-size: 0.88rem; }
.stat-card strong { margin-top: 0.4rem; display: block; font-size: 1.55rem; font-family: "Manrope", sans-serif; }
.stat-card .negative { color: var(--danger); }
.stat-card .positive { color: var(--accent); }

.date-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.entity-tags {
  margin-top: -0.35rem;
}
.date-tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.42rem 0.72rem;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}
.date-tag.active {
  background: var(--accent-soft);
  color: #096757;
  border-color: #9fdacb;
}

.filters { display: grid; grid-template-columns: 1fr; gap: 0.7rem; }
input, select, textarea {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  padding: 0.72rem 0.8rem;
  width: 100%;
}

.trades { display: grid; grid-template-columns: repeat(var(--trade-columns), minmax(0, 1fr)); gap: 0.9rem; }
@media (max-width: 1320px) { .trades { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.trade-card {
  position: relative;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1rem;
  display: grid;
  gap: 0.8rem;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.trade-card:focus-visible {
  outline: 2px solid #0d8b78;
  outline-offset: 2px;
}
.trade-card--win {
  background: #effcf4;
  border-color: #c9e9d4;
}
.trade-card--loss {
  background: #fff2f2;
  border-color: #efcaca;
}
.trade-card--flat {
  background: #f7f8fa;
  border-color: #d8dde4;
}
.trade-card > * { position: relative; z-index: 1; }
.hover-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 180ms ease;
  pointer-events: none;
  z-index: 0;
}
.trade-card:hover .hover-preview { opacity: 0.95; }
.trade-card:hover > :not(.hover-preview):not(.trade-head):not(.card-actions) { opacity: 0.08; }
.trade-card:hover .card-actions { opacity: 1; }
.trade-card:hover .status-action { opacity: 1; border-color: #0d8b78; background: #e4f7f2; color: #0b6f60; }
.trade-card:hover .symbol {
  color: #0b6f60;
  background: #dff5ef;
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 8px;
}
.trade-card:hover .meta { opacity: 0; }

.trade-head { display: flex; justify-content: space-between; gap: 0.6rem; align-items: flex-start; }
.trade-head-main {
  min-width: 0;
}
.trade-head h3 { margin: 0; font-family: "Manrope", sans-serif; font-size: 1.32rem; overflow-wrap: anywhere; }
.symbol-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.position-badge {
  display: none;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid transparent;
}
.position-badge.visible {
  display: inline-flex;
}
.position-badge.short {
  background: #ffe6e6;
  border-color: #f0bcbc;
  color: #b94747;
}
.position-badge.long {
  background: #e9f8ef;
  border-color: #bde0c8;
  color: #158053;
}
.trade-head .meta { margin: 0.2rem 0 0; color: var(--muted); }

.status-pill { border: 1px solid var(--line); border-radius: 999px; padding: 0.3rem 0.55rem; font-size: 0.82rem; text-transform: capitalize; }
.status-action { cursor: pointer; }
.status-pill.draft { background: #fff4d8; }
.status-pill.closed { background: #edf2f6; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; }
.grid span { display: block; color: var(--muted); font-size: 0.8rem; }
.grid strong { margin-top: 0.15rem; display: block; }

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

.page-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.page-tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.42rem 0.72rem;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}
.page-tag.active {
  background: var(--accent-soft);
  color: #096757;
  border-color: #9fdacb;
}
.pages-shell {
  min-height: 520px;
  align-content: start;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}
.page-story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.9rem;
}
.page-story-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  background: var(--paper);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: grid;
}
.page-story-card--no-cover {
  align-content: start;
}
.page-story-card:focus-visible {
  outline: 2px solid #0d8b78;
  outline-offset: 2px;
}
.page-story-cover {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  background: #f2ede3;
}
.page-story-cover--empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
}
.page-story-body {
  padding: 1rem;
  display: grid;
  gap: 0.55rem;
}
.page-story-body h3,
.page-story-body p {
  margin: 0;
}
.page-story-body h3 {
  font-family: "Manrope", sans-serif;
  font-size: 1.2rem;
}
.page-story-body p {
  color: var(--muted);
  line-height: 1.55;
}
.page-list-meta {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.86rem;
}
.page-type-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff8ed;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 700;
}
.pages-empty {
  min-height: 280px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
  padding: 1.25rem;
}
.pages-editor {
  display: grid;
  gap: 1rem;
}
.page-reader {
  width: min(860px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 1.2rem;
}
#strategiesApp .page-reader,
#systemsApp .page-reader {
  width: min(1280px, 100%);
}
.page-reader-topline {
  color: var(--muted);
  font-size: 0.92rem;
}
.page-reader-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.strategy-folder-rail {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: nowrap;
  justify-content: flex-end;
  width: max-content;
  max-width: 100%;
}
.strategy-header-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}
.strategy-header-row h1 {
  max-width: 420px;
}
.page-reader-header h1 {
  margin: 0.35rem 0 0;
  font-family: "Manrope", sans-serif;
  font-size: clamp(2rem, 4vw, 3.4rem);
}
.page-reader-content {
  display: grid;
  gap: 1rem;
}
.strategy-reader-content {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 0 30px 10px;
}
.page-reader-subtitle {
  margin: 0;
  font-family: "Manrope", sans-serif;
  font-size: 1.5rem;
}
.page-reader-paragraph {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.8;
}
.page-reader-supporting {
  margin: 0 0 0.7rem;
  color: #57626d;
  font-size: 0.9rem;
  line-height: 1.6;
}
.page-reader-image {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #f9f6ef;
}
.page-reader-split {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(320px, 0.88fr);
  gap: 1.6rem;
  align-items: start;
}
.strategy-folder-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}
.strategy-folder-grid--inline {
  grid-template-columns: repeat(3, minmax(136px, 1fr));
  min-width: min(460px, 100%);
}
.strategy-folder-card {
  text-align: left;
  padding: 0.95rem 1rem;
  border-radius: 16px;
  background: linear-gradient(180deg, #fdf6ea 0%, #fff8f0 100%);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
.strategy-folder-card--rail {
  min-width: 132px;
  justify-content: center;
  background: linear-gradient(180deg, #fdf6ea 0%, #fff9f3 100%);
}
.strategy-folder-card--rail.is-active {
  border-color: #9fdacb;
  background: linear-gradient(180deg, #ddf4ef 0%, #eefcf8 100%);
  color: #096757;
}
.strategy-folder-card strong {
  font-family: "Manrope", sans-serif;
  font-size: 1.05rem;
  margin: 0;
}
.strategy-folder-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  margin-top: 0.15rem;
}
.strategy-folder-chip {
  text-align: left;
  padding: 0.68rem 0.8rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #eef7ff 0%, #f7fbff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.strategy-folder-chip strong {
  font-size: 0.88rem;
  margin: 0;
}
.strategy-header-main {
  min-width: 0;
}
#strategiesApp .page-reader-actions,
#systemsApp .page-reader-actions,
#strategiesApp .page-reader-header,
#systemsApp .page-reader-header,
#strategiesApp .strategy-reader-content,
#systemsApp .strategy-reader-content,
#learningsApp .page-reader-actions,
#learningsApp .page-reader-header,
#learningsApp .strategy-reader-content {
  padding-left: 30px;
  padding-right: 30px;
}
#strategiesView[data-mode="view"] .top-actions,
#strategiesView[data-mode="folder"] .top-actions,
#strategiesView[data-mode="edit"] .top-actions,
#systemsView[data-mode="view"] .top-actions,
#systemsView[data-mode="folder"] .top-actions,
#systemsView[data-mode="edit"] .top-actions {
  min-width: fit-content;
}
#strategiesApp .page-reader-header h1,
#systemsApp .page-reader-header h1,
#learningsApp .page-reader-header h1 {
  max-width: 760px;
  line-height: 1.12;
}
.page-canvas-wrap {
  width: min(920px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 1rem;
}
.page-canvas {
  background: #fff;
  border: 1px solid #efe5d6;
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
  display: grid;
  gap: 1rem;
}
.page-title-input {
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  font-family: "Manrope", sans-serif;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
}
.page-title-input:focus {
  outline: none;
}
.page-static-title {
  margin: 0;
  font-family: "Manrope", sans-serif;
  font-size: clamp(2rem, 4vw, 3rem);
}
.strategy-overview-input {
  min-height: 96px;
  color: var(--muted);
}
.page-canvas-block {
  --page-block-handle-width: 30px;
  --page-block-column-gap: 0.8rem;
  position: relative;
  display: grid;
  grid-template-columns: var(--page-block-handle-width) minmax(0, 1fr);
  align-items: start;
  column-gap: var(--page-block-column-gap);
  row-gap: 0.8rem;
  padding-top: 0.2rem;
  transition: box-shadow 140ms ease, transform 140ms ease, opacity 140ms ease;
}
.page-canvas-block--dragging {
  opacity: 0.45;
}
.page-canvas-block--over-before {
  box-shadow: inset 0 3px 0 var(--accent);
}
.page-canvas-block--over-after {
  box-shadow: inset 0 -3px 0 var(--accent);
}
.page-canvas-block > :not(.page-block-drag-handle):not(.page-block-trash) {
  min-width: 0;
}
.page-block-drag-handle {
  width: var(--page-block-handle-width);
  min-height: 56px;
  margin-top: 0.1rem;
  border: 0;
  border-radius: 14px;
  background: #eef2ff;
  color: #a7b6f7;
  display: inline-grid;
  place-items: center;
  padding: 0;
  cursor: grab;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-6px);
  transition: opacity 140ms ease, transform 140ms ease, background 140ms ease, color 140ms ease;
}
.page-block-drag-handle svg {
  width: 14px;
  height: 24px;
  fill: currentColor;
}
.page-block-drag-handle:active {
  cursor: grabbing;
}
.page-canvas-block:hover .page-block-drag-handle,
.page-canvas-block:focus-within .page-block-drag-handle,
.page-canvas-block--dragging .page-block-drag-handle {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}
.page-block-drag-handle:hover,
.page-block-drag-handle:focus-visible {
  background: #e3e9ff;
  color: #8ea0f5;
  outline: none;
}
.page-canvas-block--insert-target::after {
  content: "";
  position: absolute;
  left: calc(var(--page-block-handle-width) + var(--page-block-column-gap));
  right: 0;
  bottom: -0.45rem;
  height: 3px;
  border-radius: 999px;
  background: rgba(13, 139, 120, 0.32);
  pointer-events: none;
}
.page-canvas-block--insert-target.page-canvas-block--over-before::after,
.page-canvas-block--insert-target.page-canvas-block--over-after::after {
  opacity: 0;
}
.page-canvas-input {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  line-height: 1.8;
  width: 100%;
  resize: none;
  overflow: hidden;
}
.page-canvas-input:focus {
  outline: none;
}
.page-canvas-input--subtitle {
  font-family: "Manrope", sans-serif;
  font-size: 1.45rem;
  font-weight: 700;
}
.page-block-tools--canvas {
  justify-content: flex-start;
}
.page-block-tools--sticky {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(20px);
  width: min(920px, calc(100vw - 3rem));
  justify-content: center;
  padding: 0.8rem 1rem;
  border: 1px solid #e6d8c0;
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.96);
  box-shadow: 0 18px 40px rgba(17, 37, 62, 0.16);
  backdrop-filter: blur(16px);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
.page-block-tools--sticky.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.page-block-tools--sticky .ghost {
  background: rgba(255, 255, 255, 0.7);
}
.pages-editor-header {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  align-items: flex-start;
}
.pages-editor-title h3,
.pages-editor-title p {
  margin: 0;
}
.pages-editor-title p {
  color: var(--muted);
  margin-top: 0.2rem;
}
.page-blocks {
  display: grid;
  gap: 0.9rem;
}
.page-blocks--drag-tail {
  position: relative;
}
.page-blocks--drag-tail::after {
  content: "";
  display: block;
  height: 3px;
  border-radius: 999px;
  background: var(--accent);
}
.page-block {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 0.9rem;
  display: grid;
  gap: 0.8rem;
}
.page-block-head {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: center;
}
.page-block-tools {
  display: inline-flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.page-block-trash {
  position: absolute;
  top: 0.2rem;
  right: 0.2rem;
  z-index: 3;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #efcaca;
  background: rgba(255, 241, 241, 0.95);
  color: #b94747;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
  padding: 0;
}
.page-block-trash svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}
.page-canvas-block:hover .page-block-trash,
.page-canvas-block:focus-within .page-block-trash {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.page-block-tools button {
  padding: 0.4rem 0.6rem;
}
.page-block textarea {
  min-height: 160px;
  resize: none;
}
.page-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}
.page-images--single {
  grid-template-columns: minmax(0, 1fr);
}
.page-image-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #fffaf0;
}
.page-image-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}
.page-image-card--single img {
  height: auto;
  max-height: none;
  object-fit: contain;
}
.page-image-card button {
  width: calc(100% - 0.8rem);
  margin: 0.4rem;
}
.page-image-card--single button {
  width: auto;
  justify-self: end;
}
.page-image-uploader {
  border: 1px dashed var(--line);
  border-radius: 14px;
  min-height: 180px;
  display: grid;
  place-items: center;
  background: #fffaf0;
  cursor: pointer;
  position: relative;
  text-align: center;
  padding: 1rem;
}
.page-image-uploader.is-dragover {
  border-color: var(--accent);
  background: #eef9f4;
  box-shadow: 0 0 0 2px rgba(10, 134, 105, 0.16);
  color: #096757;
}
.page-image-uploader input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.page-canvas-block input,
.page-canvas-block textarea {
  cursor: text;
}

@media (max-width: 720px) {
  .page-canvas-block {
    --page-block-handle-width: 24px;
    --page-block-column-gap: 0.6rem;
  }
  .page-block-drag-handle {
    min-height: 50px;
    border-radius: 12px;
  }
  .page-block-tools--sticky {
    width: calc(100vw - 1.5rem);
    bottom: 12px;
    padding: 0.7rem 0.8rem;
    border-radius: 22px;
  }
}
.split-block {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);
  gap: 0.9rem;
}
.split-panel {
  display: grid;
  gap: 0.8rem;
}
.strategy-test-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  padding: 1rem;
  display: grid;
  gap: 0.9rem;
}
.strategy-folder-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}
.strategy-folder-stat {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffdfa;
  padding: 1rem;
  display: grid;
  gap: 0.35rem;
}
.strategy-folder-stat span {
  color: var(--muted);
  font-size: 0.84rem;
}
.strategy-folder-stat strong {
  font-family: "Manrope", sans-serif;
  font-size: 1.4rem;
}
.strategy-folder-stat p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.metric-positive {
  color: #158053;
}
.metric-negative {
  color: #b94747;
}
.strategy-test-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: flex-start;
}
.strategy-test-head p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.strategy-test-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}
.strategy-test-metrics--wide {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.strategy-trade-assign-list {
  display: grid;
  gap: 0.75rem;
  max-height: min(60vh, 520px);
  overflow: auto;
  padding-right: 0.2rem;
}
.strategy-trade-assign-row {
  display: flex;
  gap: 0.8rem;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85rem 0.95rem;
  background: #fffdfa;
  cursor: pointer;
}
.strategy-trade-assign-row input {
  margin-top: 0.15rem;
}
.strategy-trade-assign-row strong {
  display: block;
  font-family: "Manrope", sans-serif;
}
.strategy-trade-assign-row span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.2rem;
}
.strategy-test-metrics span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}
.strategy-test-metrics strong {
  display: block;
  margin-top: 0.2rem;
}
.strategy-test-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}
.strategy-test-image-full {
  width: 100%;
}
.strategy-test-image-full img {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #f9f6ef;
}
.strategy-test-images img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #f9f6ef;
}

.trade-number {
  margin: 0;
  text-align: right;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}
.inline-icon {
  width: 15px;
  height: 15px;
  display: inline-grid;
  place-items: center;
}
.inline-icon svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}
.notes.pnl-positive { color: #158053; font-weight: 700; }
.notes.pnl-negative { color: #b94747; font-weight: 700; }
.notes.pnl-neutral { color: var(--muted); font-weight: 700; }
.notes .pnl-icon {
  display: inline-grid;
  width: 14px;
  height: 14px;
  vertical-align: text-bottom;
  margin-right: 0.25rem;
}
.notes .pnl-icon svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.empty {
  background: var(--paper);
  border: 1px dashed var(--line);
  color: var(--muted);
  padding: 1rem;
  border-radius: 16px;
  text-align: center;
}

.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.rules-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1rem;
  display: grid;
  gap: 0.8rem;
}
.rules-card h3 { margin: 0; font-family: "Manrope", sans-serif; }
.rules-help, .import-status { margin: 0; color: var(--muted); font-size: 0.9rem; }

.question-list { display: grid; gap: 0.55rem; }
.rule-row {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 0.45rem;
  align-items: center;
}
.rule-row .seq { color: var(--muted); font-size: 0.75rem; }
.rule-actions { display: flex; gap: 0.3rem; }
.rule-actions button { padding: 0.45rem 0.6rem; }

.row-actions { display: flex; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; }
.menu-order-row {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
  background: #fff;
}
.menu-order-actions {
  display: inline-flex;
  gap: 0.35rem;
}
.menu-order-actions button {
  padding: 0.38rem 0.55rem;
}
dialog {
  border: 0;
  padding: 0;
  border-radius: 16px;
  width: min(820px, calc(100% - 1rem));
  box-shadow: 0 16px 50px rgba(16, 34, 48, 0.2);
}
dialog::backdrop { background: rgba(9, 20, 31, 0.5); }

#tradeForm, .details-card { background: var(--paper); padding: 1rem; }
#missingFieldsForm {
  background: var(--paper);
  padding: 1.35rem;
}
#editTradeForm {
  background: var(--paper);
  padding: 1.35rem;
}
#newPageForm {
  background: var(--paper);
  padding: 1.35rem;
}
#newStrategyForm,
#newSystemForm,
#newLearningForm,
#reviewForm,
#strategyTestForm,
#strategyTradeAssignForm {
  background: var(--paper);
  padding: 1.45rem;
}
#tradeForm h3, .details-card h3 { margin: 0 0 0.55rem; font-family: "Manrope", sans-serif; }
#missingFieldsForm h3 { margin: 0 0 0.55rem; font-family: "Manrope", sans-serif; }
#editTradeForm h3 { margin: 0 0 0.55rem; font-family: "Manrope", sans-serif; }
#newPageForm h3 { margin: 0 0 0.55rem; font-family: "Manrope", sans-serif; }
#newStrategyForm h3,
#newSystemForm h3,
#newLearningForm h3,
#reviewForm h3,
#strategyTestForm h3,
#strategyTradeAssignForm h3 { margin: 0 0 0.55rem; font-family: "Manrope", sans-serif; }
#missingFieldsForm .rules-help {
  margin-bottom: 1rem;
}
#editTradeForm .rules-help {
  margin-bottom: 1rem;
}
#newPageForm .rules-help {
  margin-bottom: 1rem;
}
#newStrategyForm .rules-help,
#newSystemForm .rules-help,
#newLearningForm .rules-help,
#reviewForm .rules-help,
#strategyTestForm .rules-help,
#strategyTradeAssignForm .rules-help {
  margin-bottom: 1rem;
}
#missingFieldsGrid {
  margin-top: 0.35rem;
}
#editTradeGrid {
  margin-top: 0.35rem;
}

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.form-grid label { display: grid; gap: 0.3rem; color: var(--muted); font-size: 0.9rem; }
.form-grid .full { grid-column: 1 / -1; }

.dialog-actions { margin-top: 0.9rem; display: flex; justify-content: flex-end; gap: 0.5rem; }
.hidden-block { display: none; }

.file-input { border: 1px dashed var(--line); border-radius: 10px; padding: 0.45rem; background: #faf6ee; }
.image-upload {
  display: grid;
  gap: 0.45rem;
}
.image-upload.is-dragover .file-input {
  border-color: var(--accent);
  background: #eef9f4;
  box-shadow: 0 0 0 2px rgba(10, 134, 105, 0.16);
}
.image-preview {
  display: none;
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f9f6ef;
}
.image-preview.visible { display: block; }

.details-image {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f9f6ef;
}
.details-image--stretch {
  min-height: 0;
  max-height: none;
  height: 100%;
  flex: 1;
  object-fit: cover;
  cursor: zoom-in;
}
.trade-sheet {
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: #fffdf9;
}
.trade-sheet-head {
  display: grid;
  grid-template-columns: 1fr auto;
  border-bottom: 1px solid var(--line);
  background: #fffaf2;
}
.trade-sheet-head > div {
  padding: 0.8rem 1rem;
}
.trade-sheet-head span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}
.trade-sheet-head strong {
  display: block;
  margin-top: 0.2rem;
  font-family: "Manrope", sans-serif;
  font-size: 1.05rem;
}
.trade-sheet-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
}
.trade-sheet-image,
.trade-sheet-details {
  padding: 0.9rem;
}
.trade-sheet-image {
  border-right: 1px solid var(--line);
  min-height: 560px;
  display: flex;
  flex-direction: column;
}
.trade-sheet h4 {
  margin: 0 0 0.6rem;
  font-family: "Manrope", sans-serif;
  font-size: 1rem;
}
.image-frame {
  position: relative;
  flex: 1;
  min-height: 360px;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
}
.image-frame--block {
  min-height: 460px;
}
.image-frame-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(16, 34, 48, 0.12);
  opacity: 0;
  transition: opacity 180ms ease;
  pointer-events: none;
}
.image-frame:hover .image-frame-overlay,
.image-frame:focus-visible .image-frame-overlay,
.image-frame.is-dragover .image-frame-overlay {
  opacity: 1;
}
.image-frame.is-dragover {
  box-shadow: 0 0 0 2px rgba(10, 134, 105, 0.2);
}
.image-frame-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 170px;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 700;
  box-shadow: var(--shadow);
}
.trade-sheet-details ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.5rem;
}
.trade-sheet-details li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 0.35rem;
}
.trade-sheet-details li span {
  color: var(--muted);
}
.missing-info-alert {
  margin-top: 0.85rem;
  width: 100%;
  background: #fff4d8;
  border-color: #ecd38e;
  color: #7f5b09;
  text-align: center;
  font-weight: 700;
}
.details-image-placeholder {
  min-height: 360px;
  height: 100%;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #f6f1e7;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.trade-sheet-block {
  padding: 0.9rem;
  border-bottom: 1px solid var(--line);
}
.trade-sheet-block--image {
  display: grid;
  align-content: start;
  gap: 1.15rem;
  padding: 1.45rem 1.45rem 1.6rem;
}
.trade-sheet-block--image h4 {
  margin: 0;
}
.trade-sheet-block--image .image-frame--block {
  margin: 0.2rem 0 0.1rem;
}
.trade-sheet-block-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  align-items: center;
}
.trade-sheet-block-head h4 {
  margin: 0;
}
.close-trade-media-section {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
}
.close-trade-media-list {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.8rem;
}
.close-trade-media-empty {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 1rem;
  color: var(--muted);
  text-align: center;
  background: #fdfaf3;
}
.close-trade-media-item {
  display: grid;
  grid-template-columns: minmax(180px, 230px) minmax(0, 1fr);
  gap: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85rem;
  background: #fff;
}
.close-trade-media-item.is-dragover {
  border-color: var(--accent);
  background: #fffcf6;
  box-shadow: 0 0 0 2px rgba(10, 134, 105, 0.14);
}
.close-trade-media-preview {
  min-height: 180px;
  border-radius: 12px;
  overflow: hidden;
  background: #f6f1e7;
  border: 1px dashed var(--line);
}
.close-trade-media-item.is-dragover .close-trade-media-preview {
  border-color: var(--accent);
  background: #eef9f4;
}
.close-trade-media-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.close-trade-media-placeholder {
  min-height: 180px;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  padding: 1rem;
  text-align: center;
}
.close-trade-media-body {
  display: grid;
  gap: 0.65rem;
  align-content: start;
}
.close-trade-media-body textarea {
  min-height: 120px;
}
.close-trade-media-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.close-trade-media-actions .danger {
  color: #b23d3d;
  border-color: rgba(178, 61, 61, 0.28);
  background: rgba(255, 237, 237, 0.9);
}
.trade-sheet-block--pre {
  margin-top: 1rem;
}
.trade-sheet-block:last-child {
  border-bottom: 0;
}
.analysis-stack {
  margin-top: 0.8rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
}
.analysis-stack article {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem;
  background: #fff;
}
.analysis-stack span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}
.analysis-stack strong {
  margin-top: 0.25rem;
  display: block;
  overflow-wrap: anywhere;
}
.trade-post-note-list {
  margin-top: 0.8rem;
  display: grid;
  gap: 1rem;
}
.trade-post-note {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
}
.trade-post-note--annotated {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(0, 3fr);
  align-items: stretch;
}
.trade-post-note--annotated .trade-post-note-image {
  width: 100%;
  height: 100%;
  min-height: 220px;
  max-height: 260px;
  object-fit: cover;
  display: block;
  background: #f6f1e7;
}
.trade-post-note--annotated .trade-post-note-copy {
  display: grid;
  align-content: start;
  gap: 0.5rem;
  padding: 1rem 1.1rem;
}
.trade-post-note--annotated .trade-post-note-copy span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.trade-post-note--annotated .trade-post-note-copy p {
  margin: 0;
  color: var(--ink);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.details-grid { margin-top: 0.8rem; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
.details-grid div { border: 1px solid var(--line); border-radius: 10px; padding: 0.55rem; }
.details-grid span { display: block; color: var(--muted); font-size: 0.8rem; }
.details-grid strong { margin-top: 0.2rem; display: block; overflow-wrap: anywhere; }

dialog.image-preview-dialog {
  width: min(1200px, calc(100% - 1.2rem));
  background: #09141f;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.image-preview-wrap {
  position: relative;
  padding: 0.8rem;
  display: grid;
  gap: 0.55rem;
}
.image-preview-close {
  position: absolute;
  top: 0.95rem;
  right: 0.95rem;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(11, 18, 27, 0.7);
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 5;
}
.image-preview-wrap img {
  width: 100%;
  max-height: min(84vh, 920px);
  object-fit: contain;
  border-radius: 10px;
  background: #101d2b;
}

.tasks-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}
.tasks-toggle {
  display: inline-flex;
  gap: 0.45rem;
}
.tasks-toggle button.active {
  background: var(--accent-soft);
  color: #096757;
  border-color: #b5e8dd;
}
.tasks-date-tools {
  display: grid;
  gap: 0.25rem;
  justify-items: end;
}
.tasks-create-row {
  display: flex;
  justify-content: flex-end;
}
.tasks-add-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}
.tasks-checklist {
  display: grid;
  gap: 0.45rem;
}
.tasks-calendar-dialog {
  width: min(360px, calc(100% - 1rem));
  border: 1px solid var(--line);
  border-radius: 16px;
}
.tasks-calendar-dialog::backdrop {
  background: rgba(9, 20, 31, 0.45);
}
.tasks-calendar-dialog-inner {
  background: #fff;
  padding: 0.9rem;
  display: grid;
  gap: 0.7rem;
}
.tasks-calendar-dialog-inner h3 {
  margin: 0;
  font-family: "Manrope", sans-serif;
}
.tasks-calendar-dialog-inner input[type="date"] {
  width: 100%;
}
.task-row {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.6rem 0.7rem;
}
.task-age-tag {
  font-size: 0.78rem;
  color: #7a5c2f;
  background: #fff5dd;
  border: 1px solid #efd8a4;
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
  white-space: nowrap;
}
.task-toggle {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 2px solid #8ca0ad;
  background: #fff;
  cursor: pointer;
  padding: 0;
}
.task-row.completed .task-toggle {
  border-color: #209d6a;
  background: #dcf7e8;
}
.task-row.completed .task-text {
  color: #6a7b87;
  text-decoration: line-through;
}
.tasks-empty {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 0.8rem;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1140px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .menu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar-card { margin-top: 0; }
  .stats { grid-template-columns: 1fr; }
  .rules-grid { grid-template-columns: 1fr; }
  .page-reader-split { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .content { padding: 1rem; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .top-actions, .top-actions button { width: 100%; }
  .filters, .stats, .trades, .form-grid, .details-grid, .rule-row { grid-template-columns: 1fr; }
  .tasks-add-row { grid-template-columns: 1fr; }
  .split-block { grid-template-columns: 1fr; }
  .strategy-folder-overview { grid-template-columns: 1fr; }
  .review-card { grid-template-columns: 1fr; }
  .review-card-actions { justify-content: stretch; }
  .trade-sheet-head, .trade-sheet-top { grid-template-columns: 1fr; }
  .trade-sheet-image { border-right: 0; border-bottom: 1px solid var(--line); min-height: 320px; }
  .trade-post-note--annotated { grid-template-columns: 1fr; }
  .details-image--stretch, .details-image-placeholder { min-height: 260px; }
  .image-frame,
  .image-frame--block { min-height: 260px; }
  .close-trade-media-item { grid-template-columns: 1fr; }
  .menu { grid-template-columns: 1fr; }
  .card-actions { grid-template-columns: 1fr; }
}
