:root {
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --accent: #3B82F6;
  --accent-hover: #2563EB;
  --text: #1A1D23;
  --text-muted: #6B7280;
  --border: #E2E5EA;
  --success: #10B981;
  --error: #EF4444;

  --ring-accent: 0 0 0 3px rgba(59, 130, 246, .15);
  --ring-error: 0 0 0 3px rgba(239, 68, 68, .15);
  --shadow-card: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);

  --radius-control: 10px;
  --radius-card: 16px;
  --radius-segment: 8px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1115;
    --surface: #1A1D23;
    --accent: #3B82F6;
    --accent-hover: #60A5FA;
    --text: #E8EAED;
    --text-muted: #9AA0AB;
    --border: #2A2E37;
    --success: #34D399;
    --error: #F87171;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  overflow-x: hidden;
}

.container {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 48px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Header */
.header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.title {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
}

.subtitle {
  margin: 0;
  font-size: 15px;
  color: var(--text-muted);
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.form {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Fields */
.field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

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

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Amount input */
.amount-input {
  width: 100%;
  height: 56px;
  padding: 0 16px;
  font-family: inherit;
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.amount-input::placeholder {
  color: var(--text-muted);
  font-weight: 600;
}

.amount-input:focus {
  border-color: var(--accent);
  box-shadow: var(--ring-accent);
}

.amount-input.is-error {
  border-color: var(--error);
}

.amount-input.is-error:focus {
  box-shadow: var(--ring-error);
}

.field-error {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--error);
}

/* Selects */
.select-wrap {
  position: relative;
}

.select {
  width: 100%;
  height: 44px;
  padding: 0 38px 0 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 10px;
  height: 10px;
  transform: translateY(-60%) rotate(45deg);
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  pointer-events: none;
}

.select:hover {
  border-color: var(--text-muted);
}

.select:focus {
  border-color: var(--accent);
  box-shadow: var(--ring-accent);
}

/* Separator segmented control */
.separator-field {
  margin: 0;
  padding: 0;
  border: 0;
  min-inline-size: 0;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-segment);
}

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

.seg-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 18px;
  font-size: 14px;
  color: var(--text-muted);
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.seg-input:checked + .seg-label {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08);
}

.seg-input:focus-visible + .seg-label {
  box-shadow: var(--ring-accent);
}

/* Results */
.results {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.results-title {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.results-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

/* Empty state */
.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
}

/* Result row */
.result-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background-color .15s ease;
}

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

.result-row:hover {
  background: var(--bg);
}

.result-main {
  flex: 1;
  min-width: 0;
}

.result-name {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.result-text {
  font-size: 16px;
  color: var(--text);
  word-break: break-word;
}

/* Copy button */
.copy-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-segment);
  cursor: pointer;
  outline: none;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.copy-btn:hover {
  background: var(--bg);
}

.copy-btn:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--ring-accent);
}

.copy-btn .icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.copy-btn .icon-check {
  display: none;
}

.copy-btn.is-copied {
  color: var(--success);
  border-color: var(--success);
}

.copy-btn.is-copied .icon-copy {
  display: none;
}

.copy-btn.is-copied .icon-check {
  display: inline-block;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(8px);
  padding: 8px 14px;
  font-size: 12px;
  color: #FFFFFF;
  background: var(--text);
  border-radius: var(--radius-segment);
  box-shadow: var(--shadow-card);
  max-width: calc(100vw - 32px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 50;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Focus-visible ring for native controls */
.select:focus-visible,
.amount-input:focus-visible {
  box-shadow: var(--ring-accent);
}

/* Responsive */
@media (max-width: 480px) {
  .container {
    padding: 24px 16px 64px;
  }

  .title {
    font-size: 24px;
  }

  .amount-input {
    height: 52px;
    font-size: 20px;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .segmented {
    display: flex;
    width: 100%;
  }

  .seg-label {
    flex: 1;
  }

  .copy-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
  }

  .copy-btn .copy-label-text {
    display: none;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
