/* =========================
   Theme tokens
   ========================= */
:root {
  --bg: #ffffff;
  --fg: #111;
  --search: #fff;
  --link: #000;
  --stroke: #E6E6E6;
  --muted: #8F8F8F;
  --border: #D0D0D0;
  --ring: #2AC9A3;
  --shadow: rgba(0,0,0,0.06);
  --gray: #71717A;
  --btn-dark-bg: #111827;
  --btn-light-bg: #ECECEC;
  --btn-dark-fg: #f9fafb;
  --btn-light-fg: #0D0D0D;  
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #212121;
    --fg: #ffffff;
    --link: #fff;
    --stroke: #3C3C3C;
    --search: #303030;
    --muted: #AFAFAF;
    --border: #3C3C3C;
    --shadow: rgba(0,0,0,0.4);
    --btn-dark-bg: #424242;
    --btn-light-bg: #424242;
    --btn-dark-fg: #e5e7eb;
    --btn-light-fg: #fff;  
  }
}

/* =========================
   Fonts (loaded via CDN)
   ========================= */

/* =========================
   Reset & globals
   ========================= */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system,
               Segoe UI, Roboto, Helvetica, Arial,
               Apple Color Emoji, Segoe UI Emoji;
  font-weight: 400;
}

main {
  padding-bottom: 40px;
}

/* =========================
   Header
   ========================= */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 0;
  backdrop-filter: saturate(1.2) blur(4px);
}

.logo {
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 140px;
  height: 24px;
  display: block;
}

.logo-link {
  display: inline-flex;
  align-items: center;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-link {
  color: var(--fg);
  text-decoration: none;
  opacity: .8;
  display: inline-flex;
  align-items: center;
}
.nav-link:hover { opacity: 1; }

/* Language switcher icon that adapts to theme */
.lang-icon{
  width:20px; height:20px; display:inline-block;
  vertical-align:middle; margin-right:6px;
  background-color: var(--fg);
  -webkit-mask: url('assets/lang-switcher.svg') no-repeat center / contain;
          mask: url('assets/lang-switcher.svg') no-repeat center / contain;
}

.nav-links:has(#accountChip:not([hidden])) #connectBtn { display: none; }
#accountChip[hidden] { display: none !important; }
#connectBtn[hidden] { display: none !important; }

/* =========================
   Buttons
   ========================= */
.btn {
  border: 1px solid var(--border);
  background: var(--btn-light-bg);
  color: #111;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
}
.btn:focus {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.btn-dark {
  background: var(--btn-dark-bg);
  color: var(--btn-dark-fg);
  border-color: #000;
}

/* =========================
   Wallet chip
   ========================= */
.account-chip { position: relative; }

.chip-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  color: #27272A;
  border: 1px solid #E4E4E7;
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo,
               Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
}
.chip-btn:focus {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
.chip-btn .icon { display: inline-flex; width: 20px; height: 20px; }
.chip-btn .icon img { width: 20px; height: 20px; }

/* =========================
   Chip menu
   ========================= */
.menu {
  position: absolute;
  right: 0;
  margin-top: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 20px var(--shadow);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 180px;
  z-index: 10;
}
.menu > button {
  background: none;
  border: 0;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  color: var(--fg);
  border-radius: 8px;
}
.menu > button:hover { background: rgba(128,128,128,0.12); }

.menu-card {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 280px;
}

.menu-title { font-size: 12px; color: var(--muted); }
.menu-identity { display: flex; align-items: center; gap: 12px; }
.menu-identity .avatar { display: none; }
.menu-identity .id-block { display: flex; flex-direction: column; }

.menu-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}
.menu-actions #disconnectBtn.btn {
  display: inline-flex;
  align-items: center;
}

.menu-close {
  position: absolute;
  right: 10px;
  top: 8px;
  border: 0;
  background: none;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
}

.menu[hidden] { display: none; }

/* =========================
   Layout
   ========================= */
.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 48px 20px;
}

.hero {
  padding: 40px 0 16px;
  text-align: center; /* centers text + inline elements */
}

.search {
  max-width: 768px;   /* your updated width */
  margin: 0 auto;     /* center the block itself */
}
.hero h1 {
  font-size: 36px;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
  font-family: 'Inter', ui-sans-serif;
  font-weight: 600;
}
.sub {
  color: var(--muted);
  margin: 0 0 24px;
  font-size: 18px;
}

/* =========================
   Search
   ========================= */
.search {
  max-width: 768px;
  margin: 48px auto 0; /* top margin 32px, center horizontally */
}

.search-input {
  display: flex;
  align-items: center;
  gap: 10px;

  background: var(--search);
  border: 1px solid var(--border);     /* uniform 1px stroke */
  border-radius: 24px;

  padding: 14px 18px;

  box-shadow: 0 2px 4px rgba(0,0,0,0.04);  /* lighter, softer shadow */
}

.search-input:focus-within {
  border-color: var(--ring);         /* purple focus border */
  box-shadow: 0 0 0 2px rgba(42, 201, 163, 0.35);
}


.search-input textarea::placeholder {
  color: var(--muted);                    /* muted gray placeholder */
}

.search-icon img,
#submitBtn img {
  display: block;        /* removes baseline alignment issues */
  width: 18px;           /* tweak size if needed */
  height: 18px;
}
.search-input textarea {
  flex: 1;
  font-size: 18px;
  border: 0;
  background: transparent;
  outline: 0;
  color: var(--fg);
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo,
               Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  resize: vertical;
  min-height: 28px;
  max-height: 240px;
  line-height: 1.5;
  padding: 0;
  overflow: hidden;
}
.submit-btn {
  margin-left: auto;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 0;
  background: #ECECEC;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.submit-btn:disabled { opacity: .5; cursor: not-allowed; }
.submit-btn img { width: 22px; height: 22px; }

.clear-btn {
  margin-left: 8px;
  padding: 8px 12px;
  background: var(--btn-light-bg);
  color: var(--btn-light-fg);
  border-color: var(--border);
}

.icon-btn {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
}

.help {
  color: #F87171;
  font-size: 14px;
  min-height: 20px;
  padding: 6px 18px;
  text-align: left;
}

/* =========================
   Results table
   ========================= */
.table-wrap {
  margin-top: 28px;
  border: 0;
  border-radius: 14px;
  overflow: hidden;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
}
.results-table thead {
  border-bottom: 1px solid var(--stroke);
}

.results-table thead th {
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  padding: 12px 16px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.results-table tbody td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--stroke);
}

.results-table thead th:last-child {
  text-align: right;
}

.results-table tbody td:last-child button{
  float: right;
}

.sortable { cursor: pointer; user-select: none; }

.action-btn {
  background: var(--btn-light-bg);
  color: var(--btn-light-fg);
  border: 1px solid var(--btn-light-bg);
  border-radius: 999px;
  padding: 6px 12px;
}
.action-btn:disabled { opacity: .5; cursor: not-allowed; }

main {
  margin: 0;
}

/* =========================
   App-specific
   ========================= */

.calc-icon {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: var(--muted);
  font-size: 18px;
}

.calc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.results-panel {
  order: 1;
}

.settings-panel {
  order: 2;
}

.panel {
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 20px;
  background: var(--search);
  box-shadow: 0 8px 20px var(--shadow);
}

.panel h2 {
  margin: 0 0 18px;
  font-size: 18px;
  font-weight: 600;
  font-family: 'Inter', ui-sans-serif;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.field-label {
  font-size: 13px;
  color: var(--muted);
}

.field input,
.field select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--bg);
  color: var(--fg);
}

.field input:focus,
.field select:focus {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.checkbox-field label {
  font-size: 14px;
  color: var(--fg);
}

.examples {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.example-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.results-table .label {
  width: 160px;
  color: var(--muted);
  font-size: 13px;
}

.results-table .value-cell {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 14px;
  word-break: break-all;
  display: flex;
  align-items: center;
  gap: 8px;
}

.value-text {
  flex: 1;
}

.copy-btn {
  border: 0;
  background: none;
  padding: 2px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, color 0.15s ease;
  color: #B3B3B3;
  position: relative;
}

.copy-btn:hover {
  color: #6B7280;
}

.value-cell:hover .copy-btn {
  opacity: 1;
  pointer-events: auto;
}

.copy-icon {
  width: 16px;
  height: 16px;
  display: inline-block;
  background-color: currentColor;
  -webkit-mask: url('assets/content_copy.svg') no-repeat center / contain;
          mask: url('assets/content_copy.svg') no-repeat center / contain;
}

.copy-tooltip {
  position: absolute;
  right: 22px;
  top: -6px;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--stroke);
  border-radius: 8px;
  padding: 2px 6px;
  font-size: 11px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  white-space: nowrap;
}

.copy-btn.show-tooltip .copy-tooltip {
  opacity: 1;
  transform: translateY(0);
}

.overflow-indicator {
  color: #F87171;
  font-size: 12px;
  margin-left: 6px;
  white-space: nowrap;
}

.note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.site-footer {
  max-width: 1000px;
  margin: 24px auto 40px;
  padding: 0 20px;
  text-align: center;
  font-weight: 300;
}

.functions {
  max-width: 1000px;
  margin: 32px auto 0;
  padding: 0 20px;
}

.functions h3 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
}

.functions-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.functions-list strong {
  color: var(--fg);
  font-weight: 600;
}

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

  .results-table .label {
    width: auto;
  }
}
