:root {
  --bg-dark: #0f1115;
  --bg-elevated: #141820;
  --panel-bg: #1a1d23;
  --accent: #ca8a04;
  --accent-soft: #eab308;
  --accent-glow: rgba(202, 138, 4, 0.32);
  --text-main: #e2e8f0;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  --border: #2d333f;
  --bg-control: #0f1318;
  --bg-control-muted: #1a1d23;
  --radius: 14px;
  --radius-sm: 10px;
  --editor-block-gap: 28px;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text-main);
  font-family: "Pretendard", system-ui, sans-serif;
  background-color: var(--bg-dark);
  background-image:
    radial-gradient(ellipse 70% 46% at 50% -18%, rgba(202, 138, 4, 0.14), transparent),
    radial-gradient(ellipse 50% 36% at 100% 12%, rgba(234, 179, 8, 0.05), transparent);
}

.app-container {
  min-height: 100vh;
}

.main-content {
  max-width: 1288px;
  margin: 0 auto;
  padding: 40px 20px 80px;
  overflow-x: hidden;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-header {
  margin-bottom: 28px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-soft);
  background: rgba(202, 138, 4, 0.14);
  padding: 4px 10px;
  border-radius: 6px;
  margin-bottom: 0;
}

.logo-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.logo-title-row h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.logo-title-row .accent {
  color: var(--accent-soft);
}

.btn-to-dashboard {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-to-dashboard:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent-soft);
}

.btn-to-dashboard::before {
  content: "←";
  font-size: 12px;
  opacity: 0.85;
}

.header-tagline {
  margin: 10px 0 0;
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.55;
  max-width: 52rem;
}

.lang-field select {
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-control);
  color: var(--text-main);
  font: inherit;
  font-size: 13px;
}

.editor-ad {
  min-height: var(--itz-ad-height, 90px);
  margin: 0 0 var(--editor-block-gap);
  border-radius: var(--radius);
  background: var(--bg-control, #0a0c10);
  border: 1px dashed var(--border);
  display: block;
  overflow: hidden;
  line-height: 0;
}

.editor-ad.editor-ad-exempt {
  position: relative;
  z-index: 50;
  isolation: isolate;
}

.fx-main {
  position: relative;
  height: var(--fx-shell-h, auto);
  overflow: hidden;
  margin-bottom: var(--editor-block-gap);
}

.fx-layout {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
  height: 100%;
  min-height: 0;
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.fx-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.fx-base-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-control);
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.fx-base-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.fx-base-flag {
  flex: 0 0 auto;
}

.fx-flag-stack {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  width: max-content;
  line-height: 1;
}

.fx-flag-img {
  display: block;
  width: 0;
  min-width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.fx-flag-code {
  margin-top: 3px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-align: center;
  white-space: nowrap;
  color: var(--text-main);
}

.fx-card-flag.fx-flag-stack .fx-flag-code {
  font-size: 11px;
}

.fx-base-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.fx-base-copy strong {
  font-size: 15px;
  letter-spacing: 0.04em;
}

.fx-base-copy span {
  font-size: 12px;
  color: var(--text-dim);
}

.fx-base-caret {
  color: var(--text-muted);
}

.fx-display {
  margin: 16px 0 16px;
  padding: 18px 16px 16px;
  border-radius: 12px;
  background: var(--bg-control);
  border: 1px solid var(--border);
  min-height: 108px;
}

.fx-display-label {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.fx-display-value {
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: clamp(1.7rem, 4vw, 2.35rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.15;
  word-break: break-all;
}

.fx-display-expr {
  margin: 6px 0 0;
  min-height: 1.2em;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
}

.fx-pad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}

.fx-key {
  height: 52px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-control-muted);
  color: var(--text-main);
  font-family: inherit;
  font-size: 18px;
  font-weight: 650;
  cursor: pointer;
}

.fx-key:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

.fx-key:active {
  transform: scale(0.98);
}

.fx-key--op {
  color: var(--accent-soft);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-control-muted));
}

.fx-key--muted {
  color: var(--text-dim);
  font-size: 16px;
}

.fx-key--eq {
  grid-column: span 3;
  background: linear-gradient(135deg, #ca8a04, #eab308);
  border-color: transparent;
  color: #1c1403;
  font-weight: 800;
}

.fx-results {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.fx-results-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.fx-results-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.fx-rate-meta {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.45;
}

.btn-primary {
  flex-shrink: 0;
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #1c1403;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.fx-result-list {
  display: grid;
  gap: 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.fx-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 14px 10px 14px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-control);
  color: inherit;
  font-family: inherit;
  cursor: pointer;
}

.fx-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.fx-card-flag {
  align-self: center;
}

.fx-card-name {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.fx-card-name strong {
  font-size: 14px;
}

.fx-card-name span {
  font-size: 11px;
  color: var(--text-dim);
}

.fx-card-amount {
  text-align: right;
}

.fx-card-amount strong {
  display: block;
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  word-break: break-all;
}

.fx-card-amount span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-dim);
}

.fx-card-remove {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
}

.fx-card-remove:hover {
  color: var(--text-main);
  background: var(--bg-control-muted);
}

.fx-empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}

.picker-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: 100%;
  z-index: 11001;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.22);
}

.picker-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 16px 18px 14px;
}

.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.picker-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.picker-x {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-main);
  font-size: 22px;
  cursor: pointer;
}

.picker-search {
  width: 100%;
  height: 40px;
  margin-bottom: 12px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-control);
  color: var(--text-main);
  font-family: inherit;
  font-size: 16px;
  flex-shrink: 0;
}

.picker-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  padding-right: 4px;
}

.picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-control);
  cursor: pointer;
  color: var(--text-main);
  font-size: 13px;
}

.picker-flag {
  flex: 0 0 28px;
  width: 28px;
  height: 20px;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.picker-item input {
  margin-top: 3px;
  accent-color: var(--accent);
}

.picker-item small {
  display: block;
  margin-top: 2px;
  color: var(--text-dim);
  font-size: 11px;
}

.picker-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  flex-shrink: 0;
}

.picker-count {
  margin: 0;
  font-size: 13px;
  color: var(--text-dim);
}

html:has(body.is-picker-open),
body.is-picker-open {
  overflow: hidden;
  overscroll-behavior: none;
}

body.is-picker-open::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(8, 12, 20, 0.58);
  pointer-events: auto;
}

body.is-picker-open #editor-ad-above-path,
body.is-picker-open #editor-ad-below-export {
  z-index: 20000;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 13px;
}

html[data-theme="light"] .fx-key--eq,
html[data-theme="light"] .btn-primary {
  color: #1c1403;
}

html[data-theme="light"] .fx-card,
html[data-theme="light"] .fx-base-btn,
html[data-theme="light"] .fx-display,
html[data-theme="light"] .fx-key,
html[data-theme="light"] .picker-item,
html[data-theme="light"] .picker-search,
html[data-theme="light"] .lang-field select {
  background: var(--bg-control, #f8fafc);
  color: #0f172a;
}

html[data-theme="light"] .fx-flag-code {
  color: #0f172a;
}

html[data-theme="dark"] .fx-flag-code {
  color: #e2e8f0;
}

html[data-theme="light"] .picker-item small,
html[data-theme="light"] .fx-card-name span,
html[data-theme="light"] .fx-card-amount span,
html[data-theme="light"] .fx-base-copy span,
html[data-theme="light"] .fx-rate-meta,
html[data-theme="light"] .fx-display-expr {
  color: #475569;
}

html[data-theme="dark"] .fx-card,
html[data-theme="dark"] .fx-base-btn,
html[data-theme="dark"] .fx-display {
  color: #e2e8f0;
}

@media (max-width: 900px) {
  .fx-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .picker-list {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  html {
    -webkit-text-size-adjust: 100%;
  }

  .main-content {
    padding: 16px 14px calc(28px + env(safe-area-inset-bottom, 0px));
  }

  .logo-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .logo-title-row h1 {
    font-size: 1.35rem;
    line-height: 1.25;
  }

  .header-tagline {
    font-size: 13.5px;
  }

  .btn-to-dashboard {
    min-height: 40px;
  }

  .panel {
    padding: 16px;
  }

  .fx-display {
    min-height: 88px;
    padding: 14px 12px 12px;
  }

  .fx-display-value {
    font-size: clamp(1.45rem, 7vw, 2rem);
  }

  .fx-pad {
    gap: 6px;
  }

  .fx-key {
    height: 48px;
    min-height: 48px;
    font-size: 17px;
    touch-action: manipulation;
  }

  .fx-results-head {
    flex-direction: column;
    align-items: stretch;
  }

  .fx-results-head .btn-primary {
    width: 100%;
    height: 44px;
  }

  .fx-card {
    grid-template-columns: auto minmax(0, 1fr) 36px;
    grid-template-areas:
      "flag name remove"
      "flag amount remove";
    align-items: start;
    padding: 12px 8px 12px 12px;
  }

  .fx-card-flag {
    grid-area: flag;
    align-self: start;
    margin-top: 2px;
  }

  .fx-card-name {
    grid-area: name;
  }

  .fx-card-amount {
    grid-area: amount;
    text-align: left;
  }

  .fx-card-amount strong {
    font-size: 15px;
  }

  .fx-card-remove {
    grid-area: remove;
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  .picker-list {
    grid-template-columns: 1fr;
  }

  .picker-item {
    min-height: 48px;
  }

  .picker-foot .btn-primary {
    min-height: 44px;
    padding: 0 18px;
  }

  .toast {
    right: 12px;
    left: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    max-width: none;
  }
}

@media (max-width: 560px) {
  .picker-list {
    grid-template-columns: 1fr;
  }

  .fx-key {
    height: 46px;
  }
}
