* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --border: rgba(0,0,0,0.09);
  --text-primary: #1a1a18;
  --text-secondary: #6b6b67;
  --text-hint: #adadaa;
  --accent: #1a1a18;
  --accent-bg: #1a1a18;
  --accent-text: #ffffff;
  --thb: #3B6D11;
  --thb-bg: #EAF3DE;
  --php: #185FA5;
  --php-bg: #E6F1FB;
  --usd: #3C3489;
  --usd-bg: #EEEDFE;
}

body {
  font-family: -apple-system, 'SF Pro Display', BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0;
}

.app {
  width: 100%;
  max-width: 420px;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.header {
  padding: 40px 20px 8px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.title-group {
  display: flex;
  flex-direction: column;
}

.header h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.version {
  font-size: 10px;
  color: var(--text-hint);
  letter-spacing: 0.05em;
  margin-top: 1px;
}

.rate-badge {
  font-size: 11px;
  color: var(--text-hint);
  text-align: right;
  line-height: 1.4;
}

.rate-badge span {
  display: block;
  font-size: 10px;
}

.cards {
  padding: 6px 14px 0;
  flex: 1;
}

.card {
  background: var(--surface);
  border-radius: 18px;
  padding: 14px 16px 12px;
  margin-bottom: 6px;
  border: 0.5px solid var(--border);
  position: relative;
  transition: box-shadow 0.15s;
}

.card.active {
  box-shadow: 0 2px 16px rgba(0,0,0,0.08);
}

.card-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.flag {
  font-size: 20px;
  line-height: 1;
}

.currency-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.currency-code {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 6px;
}

.code-thb { background: var(--thb-bg); color: var(--thb); }
.code-php { background: var(--php-bg); color: var(--php); }
.code-usd { background: var(--usd-bg); color: var(--usd); }

.amount-display {
  font-size: 22px;
  font-weight: 300;
  letter-spacing: -1px;
  color: var(--text-primary);
  line-height: 1;
  min-height: 26px;
  cursor: text;
  display: flex;
  align-items: baseline;
  gap: 5px;
  transition: font-size 0.22s ease, min-height 0.22s ease;
}

.card.active .amount-display {
  font-size: 38px;
  min-height: 44px;
  letter-spacing: -1.5px;
}

.amount-display .symbol {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0;
  transition: font-size 0.22s ease;
}

.card.active .amount-display .symbol {
  font-size: 20px;
}

.amount-display .value {
  flex: 1;
}

.cursor {
  display: inline-block;
  width: 2px;
  height: 20px;
  background: var(--text-primary);
  margin-left: 1px;
  vertical-align: middle;
  border-radius: 1px;
  animation: blink 1s step-end infinite;
  transition: height 0.22s ease;
}

.card.active .cursor {
  height: 34px;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.rate-line {
  font-size: 11px;
  color: var(--text-hint);
  margin-top: 10px;
}

.divider {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 0;
  position: relative;
}

.swap-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface);
  border: 0.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-secondary);
  transition: transform 0.2s, background 0.15s;
  z-index: 2;
}

.swap-btn:active { transform: rotate(180deg); background: var(--bg); }

.tab-row {
  display: flex;
  gap: 8px;
  padding: 6px 14px 8px;
}

.tab {
  flex: 1;
  padding: 8px 0;
  border-radius: 12px;
  border: 0.5px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.tab.active {
  background: var(--accent-bg);
  color: var(--accent-text);
  border-color: var(--accent-bg);
}

.tab:active { opacity: 0.7; }

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 0 14px 16px;
}

.key {
  height: 54px;
  border-radius: 12px;
  border: none;
  background: var(--surface);
  font-size: 20px;
  font-weight: 400;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, transform 0.08s;
  -webkit-user-select: none;
  user-select: none;
  font-family: -apple-system, 'SF Pro Display', sans-serif;
}

.key:active {
  background: #e8e8e5;
  transform: scale(0.94);
}

.key.key-action {
  background: #e8e8e5;
  font-size: 16px;
  color: var(--text-secondary);
}

.key.key-action:active { background: #d8d8d5; }

.error-msg {
  text-align: center;
  font-size: 12px;
  color: #A32D2D;
  padding: 4px 16px;
  display: none;
}

.loading-dot {
  display: inline-block;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.card { cursor: pointer; }

.amount-display .value { cursor: copy; }

#copy-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: rgba(26,26,24,0.88);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 18px;
  border-radius: 20px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s, transform 0.18s;
  white-space: nowrap;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.toast-show {
  opacity: 1 !important;
  transform: translateX(-50%) translateY(0) !important;
}

.install-tip {
  text-align: center;
  font-size: 12px;
  color: var(--text-hint);
  padding: 0 16px 14px;
  line-height: 1.5;
}

.install-tip strong {
  color: var(--text-secondary);
}
