:root {
  color-scheme: light;
  --bg: #f1efe8;
  --panel: #fffefa;
  --panel-muted: #f7f5ee;
  --ink: #17211e;
  --muted: #66716c;
  --line: #ddd7ca;
  --green: #0c8062;
  --green-dark: #075f4a;
  --green-soft: #e8f7f1;
  --red: #bd3e54;
  --red-soft: #fff0f2;
  --amber: #9a6411;
  --amber-soft: #fff6df;
  --shadow: 0 14px 40px rgb(43 52 47 / 8%);
  --radius: 20px;
  font-family: Inter, Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgb(19 146 111 / 10%), transparent 26rem),
    radial-gradient(circle at 100% 14%, rgb(241 189 78 / 9%), transparent 28rem),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

[hidden] {
  display: none !important;
}

.page-shell {
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto;
  padding: 40px 0 72px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
}

h2 {
  margin: 0;
  font-size: clamp(1.28rem, 2vw, 1.7rem);
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.hero-copy {
  max-width: 760px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.65;
}

.back-link {
  flex: 0 0 auto;
  color: var(--green-dark);
  font-weight: 750;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  padding: 7px 0;
}

.back-link:hover {
  color: var(--green);
}

.private-category-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(620px, 100%);
  margin: 0 0 22px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgb(255 254 250 / 82%);
  box-shadow: var(--shadow);
}

.private-category-tab {
  min-height: 46px;
  padding: 10px 16px;
  border: 0;
  border-radius: 11px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.private-category-tab[aria-selected="true"] {
  color: #fff;
  background: var(--green-dark);
}

.panel,
.summary-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-panel {
  width: min(760px, 100%);
  margin: 60px auto 0;
  padding: clamp(24px, 5vw, 48px);
}

.auth-heading,
.section-heading,
.toolbar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-muted);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-safe {
  color: var(--green-dark);
  border-color: rgb(12 128 98 / 22%);
  background: var(--green-soft);
}

.muted {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.55;
}

.support-panel {
  margin-bottom: 22px;
  padding: 22px 24px;
}

.support-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.support-group {
  min-width: 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-muted);
}

.support-group strong,
.support-group p,
.support-group small {
  display: block;
}

.support-group p {
  margin: 7px 0 5px;
  font-size: 0.91rem;
  font-weight: 800;
}

.support-group small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.55;
}

.support-enabled strong {
  color: var(--green-dark);
}

.support-disabled strong {
  color: #8e2739;
}

.security-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 28px 0 18px;
}

.security-item {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-muted);
}

.security-item strong {
  font-size: 0.92rem;
}

.security-item span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.45;
}

.notice {
  margin: 18px 0;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.55;
}

.notice-danger {
  color: #8e2739;
  border-color: rgb(189 62 84 / 23%);
  background: var(--red-soft);
}

.stack-form {
  display: grid;
  gap: 17px;
  margin-top: 24px;
}

label {
  display: grid;
  gap: 8px;
  min-width: 0;
  color: var(--ink);
  font-size: 0.87rem;
  font-weight: 750;
}

label small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.4;
}

input,
select {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgb(12 128 98 / 17%);
  outline: none;
}

.primary-button,
.secondary-button,
.danger-button,
.remove-wallet-button {
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 800;
}

.primary-button {
  color: #fff;
  background: var(--green-dark);
}

.primary-button:hover:not(:disabled) {
  background: var(--green);
}

.secondary-button {
  color: var(--ink);
  border-color: var(--line);
  background: var(--panel);
}

.secondary-button:hover:not(:disabled) {
  border-color: var(--green);
  color: var(--green-dark);
}

.danger-button,
.remove-wallet-button {
  color: var(--red);
  border-color: rgb(189 62 84 / 25%);
  background: var(--red-soft);
}

.danger-button:hover:not(:disabled),
.remove-wallet-button:hover:not(:disabled) {
  border-color: var(--red);
}

.form-message {
  min-height: 1.4em;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.45;
}

.form-message[data-tone="error"] {
  color: var(--red);
}

.form-message[data-tone="success"] {
  color: var(--green-dark);
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.danger-zone strong {
  color: var(--red);
  font-size: 0.88rem;
}

.danger-zone p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.45;
}

.dashboard-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 22px 24px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.privacy-toggle {
  display: flex;
  min-height: 44px;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-muted);
  cursor: pointer;
}

.privacy-toggle input {
  width: 18px;
  min-height: 18px;
  margin: 0;
  accent-color: var(--green);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 16px 0;
}

.summary-card {
  min-width: 0;
  padding: 20px;
}

.summary-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.summary-card strong {
  display: block;
  font-size: clamp(1.45rem, 3vw, 2.15rem);
  line-height: 1.1;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}

.summary-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  line-height: 1.45;
}

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

.summary-card-accent {
  border-color: rgb(12 128 98 / 30%);
  background: linear-gradient(145deg, var(--green-soft), var(--panel));
}

.source-note {
  margin: 16px 0 0;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  background: var(--panel-muted);
  font-size: 0.76rem;
  font-weight: 650;
  line-height: 1.5;
}

.value-positive {
  color: var(--green);
}

.value-negative {
  color: var(--red);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(330px, 0.76fr) minmax(0, 1.45fr);
  gap: 16px;
  align-items: start;
}

.wallet-panel,
.positions-panel,
.privacy-explainer {
  padding: 24px;
}

.wallet-form {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 22px;
}

.wallet-form .address-field,
.wallet-form .primary-button {
  grid-column: 1 / -1;
}

.onchain-wallet-form {
  grid-template-columns: 1fr;
}

.onchain-wallet-form .address-field,
.onchain-wallet-form .primary-button {
  grid-column: auto;
}

.unsupported-note {
  margin: 22px 0;
  padding: 15px;
  border: 1px solid rgb(154 100 17 / 20%);
  border-radius: 13px;
  color: var(--amber);
  background: var(--amber-soft);
}

.unsupported-note strong {
  font-size: 0.82rem;
}

.unsupported-note p {
  margin: 5px 0 0;
  font-size: 0.76rem;
  font-weight: 650;
  line-height: 1.55;
}

.wallet-list,
.position-list,
.onchain-wallet-snapshots {
  display: grid;
  gap: 10px;
}

.wallet-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel-muted);
}

.wallet-row-main {
  min-width: 0;
}

.wallet-row-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.wallet-row-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.provider-badge,
.side-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 0.68rem;
  font-weight: 850;
}

.wallet-address {
  margin-top: 5px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 650;
}

.remove-wallet-button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 7px 10px;
  font-size: 0.75rem;
}

.empty-state {
  padding: 34px 20px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: var(--panel-muted);
  text-align: center;
  font-size: 0.86rem;
  font-weight: 650;
  line-height: 1.6;
}

.provider-errors {
  display: grid;
  gap: 8px;
  margin: 17px 0;
}

.provider-error {
  padding: 11px 13px;
  border: 1px solid rgb(189 62 84 / 20%);
  border-radius: 11px;
  color: #922c3f;
  background: var(--red-soft);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.45;
}

.position-list {
  margin-top: 18px;
}

.position-card {
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel-muted);
}

.onchain-wallet-snapshots {
  margin-top: 18px;
}

.onchain-wallet-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel-muted);
}

.onchain-wallet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 15px;
}

.onchain-wallet-header h3 {
  margin: 0;
  font-size: 1.08rem;
  letter-spacing: -0.015em;
}

.onchain-wallet-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 650;
}

.onchain-wallet-total {
  text-align: right;
}

.onchain-wallet-total span,
.onchain-wallet-total small {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.onchain-wallet-total strong {
  display: block;
  margin: 4px 0;
  font-size: 1.12rem;
  font-variant-numeric: tabular-nums;
}

.onchain-balance-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.onchain-balance-item {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.onchain-balance-item span,
.onchain-balance-item small {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.45;
}

.onchain-balance-item strong {
  display: block;
  margin: 5px 0;
  overflow: hidden;
  font-size: 0.9rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.morpho-position-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.morpho-position-row {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.morpho-position-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.morpho-position-heading strong {
  font-size: 0.82rem;
}

.morpho-position-heading span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.morpho-position-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.morpho-position-metrics div {
  min-width: 0;
}

.morpho-position-metrics span,
.morpho-position-metrics small {
  display: block;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 700;
  line-height: 1.4;
}

.morpho-position-metrics strong {
  display: block;
  margin: 4px 0;
  overflow: hidden;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.position-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 15px;
}

.position-market {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 850;
  letter-spacing: -0.015em;
}

.position-source {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 650;
}

.side-long {
  color: var(--green-dark);
  background: var(--green-soft);
}

.side-short {
  color: var(--red);
  background: var(--red-soft);
}

.position-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.position-metric {
  min-width: 0;
}

.position-metric span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
}

.position-metric strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.position-metric strong.value-positive {
  color: var(--green);
}

.position-metric strong.value-negative {
  color: var(--red);
}

.privacy-explainer {
  margin-top: 16px;
}

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

.privacy-grid > div {
  min-width: 0;
  padding-left: 15px;
  border-left: 3px solid rgb(12 128 98 / 28%);
}

.privacy-grid strong {
  font-size: 0.86rem;
}

.privacy-grid p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.6;
}

@media (max-width: 1050px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

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

  .position-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .onchain-balance-grid,
  .morpho-position-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 24px, 1480px);
    padding: 24px 0 48px;
  }

  .hero,
  .dashboard-toolbar,
  .danger-zone {
    align-items: stretch;
    flex-direction: column;
  }

  .back-link {
    align-self: flex-start;
  }

  .auth-panel {
    margin-top: 30px;
  }

  .auth-heading,
  .section-heading {
    align-items: flex-start;
  }

  .security-grid,
  .support-grid,
  .privacy-grid {
    grid-template-columns: 1fr;
  }

  .toolbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .privacy-toggle {
    grid-column: 1 / -1;
  }

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

  .onchain-wallet-header {
    flex-direction: column;
  }

  .onchain-wallet-total {
    text-align: left;
  }
}

@media (max-width: 500px) {
  .page-shell {
    width: min(100% - 16px, 1480px);
    padding-top: 18px;
  }

  .hero {
    margin-bottom: 18px;
  }

  .private-category-tabs {
    width: 100%;
    margin-bottom: 16px;
  }

  .hero-copy {
    font-size: 0.9rem;
  }

  .auth-panel,
  .support-panel,
  .wallet-panel,
  .positions-panel,
  .privacy-explainer,
  .dashboard-toolbar {
    padding: 18px;
    border-radius: 16px;
  }

  .auth-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }

  .summary-card {
    padding: 15px;
    border-radius: 15px;
  }

  .summary-card span {
    min-height: 2.4em;
  }

  .summary-card strong {
    font-size: 1.35rem;
  }

  .wallet-form {
    grid-template-columns: 1fr;
  }

  .wallet-form .address-field,
  .wallet-form .primary-button {
    grid-column: auto;
  }

  .wallet-row {
    align-items: stretch;
    flex-direction: column;
  }

  .remove-wallet-button {
    width: 100%;
  }

  .position-card {
    padding: 14px;
  }

  .position-metrics {
    grid-template-columns: 1fr 1fr;
    gap: 14px 8px;
  }

  .onchain-balance-grid,
  .morpho-position-metrics {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .position-metric strong {
    font-size: 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
