:root {
  --ink: #17201b;
  --muted: #65726b;
  --paper: #f5f7f2;
  --panel: #ffffff;
  --line: #cfd8ce;
  --accent: #0b6b5d;
  --accent-strong: #084b42;
  --warn: #9c3f22;
  --gain: #0b6b35;
  --loss: #9c2525;
  --shadow: 0 18px 60px rgb(23 32 27 / 12%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", "Helvetica Neue", Helvetica, sans-serif;
  background:
    linear-gradient(135deg, rgb(11 107 93 / 6%), transparent 34%),
    linear-gradient(315deg, rgb(155 63 34 / 5%), transparent 32%),
    var(--paper);
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 0 22px;
}

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

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgb(255 255 255 / 72%);
  color: var(--ink);
  font-size: 0.9rem;
  text-decoration: none;
}

.nav-link:hover {
  border-color: var(--accent);
}

h1 {
  max-width: 920px;
  margin: 0;
  font-size: clamp(1.45rem, 2.25vw, 2.15rem);
  line-height: 1.12;
  letter-spacing: 0;
  font-weight: 400;
  white-space: nowrap;
}

.status {
  min-width: 140px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgb(255 255 255 / 72%);
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
}

.status.busy {
  color: var(--accent-strong);
}

.status.error {
  color: var(--warn);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 22px;
  align-items: start;
}

.controls,
.results {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 86%);
  box-shadow: 0 16px 48px rgb(23 32 27 / 9%);
}

.controls {
  position: sticky;
  top: 20px;
  display: grid;
  gap: 18px;
  padding: 18px;
}

.dropzone {
  display: grid;
  gap: 8px;
  min-height: 176px;
  place-content: center;
  padding: 24px;
  border: 1.5px dashed var(--accent);
  border-radius: 8px;
  background: rgb(11 107 93 / 7%);
  cursor: pointer;
  text-align: center;
}

.dropzone.dragging {
  background: rgb(11 107 93 / 14%);
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-title {
  font-weight: 700;
}

.drop-meta,
.empty {
  color: var(--muted);
}

.file-list {
  display: grid;
  gap: 6px;
  max-height: 190px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.file-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 7px 8px 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font-size: 0.82rem;
}

.file-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remove-file {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}

.remove-file:hover,
.remove-file:focus-visible {
  border-color: rgb(156 63 34 / 24%);
  background: rgb(156 63 34 / 10%);
  color: var(--warn);
  outline: 0;
}

.control-grid {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

input[type="number"],
select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
}

fieldset {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.88rem;
}

.choice {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  cursor: pointer;
}

.choice input {
  margin: 0 6px 0 0;
}

.primary {
  min-height: 46px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 700;
}

.secondary {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-weight: 650;
}

.primary:disabled,
.secondary:disabled {
  background: #aeb8b1;
  border-color: #aeb8b1;
  color: white;
  cursor: not-allowed;
}

.results {
  overflow: hidden;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.summary article {
  display: grid;
  gap: 6px;
  min-height: 96px;
  padding: 18px;
  border-right: 1px solid var(--line);
}

.summary article:nth-child(3n) {
  border-right: 0;
}

.summary span {
  color: var(--muted);
  font-size: 0.82rem;
}

.summary strong {
  font-size: 1.45rem;
  letter-spacing: 0;
}

.asset-table {
  width: 100%;
}

.table-head,
.asset-row summary {
  display: grid;
  grid-template-columns: minmax(150px, 1.5fr) 120px 110px 120px;
  gap: 12px;
  align-items: center;
}

.table-head {
  padding: 12px 18px;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--line);
}

.asset-list {
  min-height: 180px;
}

.empty {
  margin: 0;
  padding: 28px 18px;
}

.asset-row {
  border-bottom: 1px solid var(--line);
}

.asset-row summary {
  min-height: 54px;
  padding: 12px 18px;
  cursor: pointer;
  list-style-position: outside;
  transition:
    background-color 160ms ease,
    color 160ms ease;
}

.asset-row summary:hover,
.asset-row summary:focus-visible {
  background: rgb(11 107 93 / 10%);
  outline: 0;
}

.asset-row summary:hover .symbol,
.asset-row summary:focus-visible .symbol {
  background: var(--accent);
  color: white;
  transform: translateX(2px);
}

.asset-row summary::marker {
  color: var(--accent);
}

.symbol {
  justify-self: start;
  padding: 4px 8px;
  border-radius: 999px;
  overflow-wrap: anywhere;
  font-weight: 700;
  transition:
    background-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.gain {
  color: var(--gain);
}

.loss {
  color: var(--loss);
}

.asset-detail {
  display: grid;
  gap: 14px;
  padding: 0 18px 18px;
}

.mini-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
}

.mini-summary span {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}

pre {
  max-width: 100%;
  margin: 0;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101815;
  color: #eef5ef;
  font-family: "Berkeley Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.5;
}

.match-log:empty {
  display: none;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  padding: 22px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.help-shell {
  width: min(900px, calc(100vw - 32px));
}

.help-page {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  box-shadow: 0 16px 48px rgb(23 32 27 / 9%);
}

.help-page section {
  display: grid;
  gap: 12px;
  padding: 24px;
  background: rgb(255 255 255 / 88%);
}

.help-page h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 500;
}

.help-page p {
  max-width: 72ch;
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.help-page a {
  color: var(--accent-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.help-page ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
  line-height: 1.55;
}

.disclaimer {
  border-left: 3px solid var(--warn);
}

@media (max-width: 860px) {
  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  h1 {
    white-space: normal;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .controls {
    position: static;
  }

  .summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary article:nth-child(3n) {
    border-right: 1px solid var(--line);
  }

  .summary article:nth-child(2n) {
    border-right: 0;
  }

  .table-head {
    display: none;
  }

  .asset-row summary {
    grid-template-columns: 1fr 90px;
  }

  .asset-row summary span:nth-child(3),
  .asset-row summary span:nth-child(4) {
    color: var(--muted);
  }
}
