:root {
  color-scheme: light;
  --bg: #f6f1e8;
  --panel: rgba(255, 251, 244, 0.9);
  --ink: #20242b;
  --muted: #5c6875;
  --line: rgba(32, 36, 43, 0.12);
  --accent: #7f4e2f;
  --accent-strong: #4f2d1d;
  --good: #1e733f;
  --bad: #9d2d2d;
  --font-size-header: 12px;
  --font-size-body: 11px;
  --font-size-small: 9px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  width: 100%;
  height: 100%;
  color: var(--ink);

  display: flex;
  justify-content: center;

  font-family: "Pretendard", "Apple SD Gothic Neo", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(127, 78, 47, 0.18), transparent 30%),
    linear-gradient(180deg, #fbf7f0 0%, var(--bg) 100%);
}

.app-shell {
  max-width: 600px;
  width: 100%;
  height: 120%;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  backdrop-filter: blur(12px);
}

.topbar {
  display: flex;
  justify-content: space-between;
}
.topbar-title {
  min-width: 0;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.panel h2 {
  margin: 0;
}

.topbar-meta-line {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.4;
}

.topbar-meta-line span {
  margin-left: 10px;
}

.topbar-meta-line span:first-child {
  margin-left: 0;
}

.topbar-meta-line strong {
  color: var(--accent-strong);
  font-weight: 700;
}

.dashboard-grid {
  display: grid;
  gap: 14px;
  margin-top: 6px;
}

.panel {
  padding: 16px 16px 14px;
}

.panel-head {
  margin-bottom: 12px;
}

.panel-head-inline {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.panel-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.card {
  min-height: 100%;
}

.input-block {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.input-block span {
  font-weight: 700;
}

.input-block input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
}

.scrap-select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
  font-size: 16px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
}

.formula-summary {
  margin: 10px 0 0;
  color: var(--muted);
  min-height: 2.2em;
  font-size: 0.85rem;
  line-height: 1.35;
}

.formula-name-line {
  margin: 8px 0 0;
  color: var(--accent-strong);
  gap: 10px;
  font-weight: 700;
}

.market-table {
  width: 100%;
  display: flex;
  flex-direction: row;

  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}


.market-cell {
  display: grid;
  gap: 4px;
  min-height: 72px;
  /* padding: 8px 10px; */


}
.market-cell span{
  border-top: 1px solid var(--line);
}
.market-cell strong {
  font-size: 14px;
}

.market-usd,
.market-krw {
  color: var(--muted);
  font-size: 12px;
}

.market-cell-empty {
  background: transparent;
  border-style: dashed;
}

.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  font-weight: 700;
}

.picker-toggle,
.filter-toggle {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--accent-strong);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.scrap-filter-wrap {
  display: none;
  margin-top: 10px;
}

.scrap-filter-wrap.is-open {
  display: block;
}

.scrap-filter-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  font-size: 15px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
}

.scrap-picker {
  display: none;
  margin-top: 10px;
}

.scrap-picker.is-open  {
  display: block;
}

.scrap-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}

.scrap-choice {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  display: grid;
  gap: 4px;
}

.scrap-choice.is-active {
  border-color: rgba(127, 78, 47, 0.45);
  background: rgba(127, 78, 47, 0.12);
  color: var(--accent-strong);
}

.scrap-choice:disabled,
.scrap-choice-empty {
  cursor: not-allowed;
  opacity: 0.6;
}

.scrap-choice-title {
  font-weight: 700;
}

.scrap-choice-summary {
  color: var(--muted);
  font-size: 0.85em;
  line-height: 1.35;
}

.info-tip {
  position: relative;
}

.info-tip > summary {
  list-style: none;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 800;
  user-select: none;
}

.info-tip > summary::-webkit-details-marker {
  display: none;
}

.tip-box {
  position: absolute;
  right: 0;
  top: 34px;
  z-index: 4;
  width: min(260px, 70vw);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdf9;
  box-shadow: 0 12px 30px rgba(32, 36, 43, 0.16);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.metric-stack {
  display: grid;
  gap: 10px;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.metric-row:last-child {
  border-bottom: 0;
}

.metric-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.result-value,
.target-rate {
  margin-top: 0;
  font-size: 26px;
  line-height: 1.1;
}

.gap-line {
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.status-message {
  margin: 12px 4px 0;
  color: var(--muted);
  font-size: 13px;
}

.status-message.is-success {
  color: var(--good);
}

.status-message.is-error {
  color: var(--bad);
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .tip-box {
    right: 0;
    left: auto;
    width: min(260px, 86vw);
  }
}
