:root {
  --bg: #0f1419;
  --surface: #1a222d;
  --surface-2: #232d3a;
  --text: #e8eef4;
  --muted: #8b9aad;
  --accent: #3d8bfd;
  --accent-hover: #5a9dff;
  --success: #34c759;
  --error: #ff6b6b;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --touch-min: 48px;
  /* top, right, bottom, left */
  --page-pad: max(20px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px))
    max(24px, env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  background: radial-gradient(ellipse 120% 80% at 50% -20%, #1e3a5f 0%, var(--bg) 55%);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--page-pad);
  overflow-x: hidden;
}

.card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 26px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin: auto;
}

.title {
  margin: 0 0 6px;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0 0 22px;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.45;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.input.control {
  width: 100%;
  max-width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  min-height: var(--touch-min);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  touch-action: manipulation;
}

.input.control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61, 139, 253, 0.25);
}

.input.control.input-error {
  border-color: var(--error);
}

.input.control.input-error:focus {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.22);
}

.copy-hint {
  display: block;
  margin: -8px 0 10px;
  min-height: 1.1em;
}

.account-select {
  position: relative;
}

.account-select.input-error .account-trigger {
  border-color: var(--error);
}

.account-select.input-error .account-trigger:focus {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.22);
}

.account-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: var(--touch-min);
  padding-top: 14px;
  padding-bottom: 14px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.account-trigger-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-trigger-text.is-placeholder {
  color: var(--muted);
}

.account-chevron {
  flex-shrink: 0;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--muted);
  transition: transform 0.2s ease;
}

.account-select.is-open .account-chevron {
  transform: rotate(180deg);
}

.account-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  max-height: min(70dvh, 420px);
  overflow: hidden;
}

.account-panel[hidden] {
  display: none !important;
}

.account-filter {
  margin: 0;
}

.account-list {
  list-style: none;
  margin: 0;
  padding: 4px;
  flex: 1;
  min-height: 0;
  max-height: min(48dvh, 280px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.account-list::-webkit-scrollbar {
  width: 8px;
}

.account-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 99px;
}

.account-item {
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 10px;
  padding: 14px 14px;
  min-height: var(--touch-min);
  margin: 0;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  transition: background 0.12s;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
  .account-item:hover {
    background: rgba(255, 255, 255, 0.06);
  }

  .account-item.is-selected:hover {
    background: rgba(61, 139, 253, 0.28);
  }
}

.account-item:active {
  background: rgba(255, 255, 255, 0.08);
}

.account-item.is-selected {
  background: rgba(61, 139, 253, 0.2);
  color: var(--text);
}

.account-item.is-selected:active {
  background: rgba(61, 139, 253, 0.32);
}

.account-empty {
  padding: 14px 12px;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

textarea.result {
  resize: vertical;
  min-height: max(88px, 18dvh);
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.8rem;
  line-height: 1.45;
}

.hint {
  font-size: 0.75rem;
  min-height: 1.1em;
}

.hint.ok {
  color: var(--success);
}

.hint.err {
  color: var(--error);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 6px;
}

.btn {
  flex: 1;
  min-width: 120px;
  min-height: var(--touch-min);
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(145deg, var(--accent), #2563eb);
  color: #fff;
  box-shadow: 0 4px 14px rgba(61, 139, 253, 0.35);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(145deg, var(--accent-hover), #3d82f6);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
}

@media (max-width: 520px) {
  body {
    align-items: flex-start;
  }

  .card {
    max-width: none;
    width: 100%;
    margin: 0 0 max(24px, env(safe-area-inset-bottom, 0px));
    align-self: stretch;
    border-radius: var(--radius-sm);
    padding: 22px max(16px, env(safe-area-inset-left)) 22px max(16px, env(safe-area-inset-right));
  }

  .title {
    font-size: 1.22rem;
  }

  .subtitle {
    font-size: 0.84rem;
    margin-bottom: 18px;
  }

  .input.control,
  .account-trigger,
  .account-filter,
  .btn {
    font-size: 16px;
  }

  textarea.result {
    font-size: 15px;
    min-height: 100px;
  }

  .hint {
    font-size: 0.8rem;
  }

  .actions {
    flex-direction: column;
    gap: 12px;
  }

  .btn {
    width: 100%;
    min-width: 0;
    min-height: var(--touch-min);
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .account-panel {
    max-height: min(75dvh, 480px);
  }

  .account-list {
    max-height: min(52dvh, 320px);
  }
}
