/* Core Design System & Tokens */
:root {
  /* HSL Color Palette */
  --bg-primary: #0a0b10;
  --bg-secondary: #12131a;
  --bg-card: rgba(22, 24, 37, 0.6);
  --bg-card-hover: rgba(30, 33, 50, 0.7);
  --border-glass: rgba(255, 255, 255, 0.07);
  --border-active: rgba(124, 58, 237, 0.4);
  
  --accent-primary: #7c3aed; /* Violet */
  --accent-primary-gradient: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
  --accent-secondary: #06b6d4; /* Cyan */
  --accent-secondary-gradient: linear-gradient(135deg, #06b6d4 0%, #22d3ee 100%);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
  --shadow-glow: 0 0 20px rgba(124, 58, 237, 0.25);
  
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-sans: 'Noto Sans KR', sans-serif;
}

/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html {
  height: 100%;
  height: -webkit-fill-available;
  height: 100dvh;
  overflow: hidden; /* Lock scroll on viewport */
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100%;
  height: -webkit-fill-available;
  height: 100dvh;
  overflow: hidden; /* Lock scroll on viewport */
  position: relative;
  display: flex;
  justify-content: center;
}

/* Ambient Ambient Glows */
.glow-bg {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  z-index: 0;
  opacity: 0.15;
  pointer-events: none;
  animation: float-glow 15s infinite ease-in-out alternate;
}

.glow-primary {
  width: 300px;
  height: 300px;
  background: var(--accent-primary);
  top: 10%;
  left: -50px;
}

.glow-secondary {
  width: 350px;
  height: 350px;
  background: var(--accent-secondary);
  bottom: 10%;
  right: -50px;
  animation-delay: -5s;
}

@keyframes float-glow {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(40px, 30px) scale(1.1); }
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Layout Container */
.app-container {
  width: 100%;
  max-width: 520px;
  height: 100%;
  height: 100dvh; /* Lock height to viewport */
  overflow-y: auto; /* Enable scroll inside container */
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  padding-top: calc(14px + env(safe-area-inset-top));
  padding-bottom: calc(225px + env(safe-area-inset-bottom, 6px)); /* Reserve spacing for fixed bottom keypad */
  position: relative;
  z-index: 1;
  -webkit-overflow-scrolling: touch; /* Buttery smooth iOS scroll */
}

/* Header Section */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: var(--shadow-glow);
}

.logo-icon svg {
  animation: logo-bounce 4s infinite ease-in-out;
}

@keyframes logo-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.app-header h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 0%, #e2e8f0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: 0.5px;
}

/* Buttons */
.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-glass);
  background: var(--bg-card);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-button:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.08);
}

.icon-button svg.spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.header-right-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Status Update Bar */
.update-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  padding: 6px 12px;
  border-radius: 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.update-time-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}

.update-title-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.update-title {
  font-size: 8px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

#update-time {
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.status-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.status-indicator.online {
  background-color: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.status-indicator.offline {
  background-color: #ef4444;
  box-shadow: 0 0 8px #ef4444;
}

/* Glassmorphism Generic Card */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Calculator Card */
.base-calculator-section {
  margin-bottom: 14px;
}

.calculator-card {
  padding: 14px 16px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.calculator-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--accent-primary-gradient);
}

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

.card-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.base-badge {
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(124, 58, 237, 0.15);
  border: 1px solid rgba(124, 58, 237, 0.25);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  color: #a78bfa;
  cursor: pointer;
  transition: background 0.2s;
}

.base-badge:active {
  background: rgba(124, 58, 237, 0.3);
}

.input-container {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
  margin-bottom: 16px;
}

.input-container input {
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 700;
  color: var(--text-primary);
  width: 85%;
  padding: 0;
  user-select: text; /* Allow user text selection/typing */
}

/* Style input placeholder */
.input-container input::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

/* Hide spin buttons */
.input-container input::-webkit-outer-spin-button,
.input-container input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.currency-symbol {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  color: var(--text-secondary);
}

/* Presets Row */
.presets-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

/* Hide scrollbar for presets */
.presets-row::-webkit-scrollbar {
  display: none;
}

.preset-btn {
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-glass);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.preset-btn:active {
  transform: scale(0.95);
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

/* Dashboard List Section */
.dashboard-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-grow: 1;
}

.section-header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.section-header h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.section-info-group {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.section-info {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

.usd-krw-rate {
  font-family: var(--font-display);
  font-size: 15px; /* Same as '내 대시보드' */
  font-weight: 600;
  color: var(--accent-secondary);
  white-space: nowrap;
}

.rate-symbol {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.currency-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

/* Currency Card */
.currency-card {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  gap: 6px;
  cursor: pointer;
  border: 1px solid var(--border-glass);
  position: relative;
  min-height: 94px;
}

.currency-card:hover {
  background: var(--bg-card-hover);
}

.currency-card.is-base {
  border-color: var(--border-active);
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.1);
}

.currency-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.flag-wrapper {
  font-size: 24px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.currency-details {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-width: calc(100% - 46px);
}

.currency-code-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.currency-code {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
}

.currency-name {
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rate-calc-preview {
  font-size: 9px;
  color: var(--text-muted);
  font-family: var(--font-display);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.currency-value {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  max-width: 100%;
}

.converted-amount {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  word-break: break-all;
  text-align: left;
}

.converted-symbol {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 2px;
}

/* Card actions */
.card-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
}

.delete-card-btn {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.delete-card-btn:active {
  background: rgba(239, 68, 110, 0.2);
  color: #ef4444;
}

/* Add Currency Action Card */
.add-currency-card {
  width: 100%;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.01);
  cursor: pointer;
  margin-top: 12px;
}

.add-currency-card:active {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.add-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* PWA Footer Tip */
.app-footer {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}

.pwa-tip {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(6, 182, 212, 0.04);
  border: 1px solid rgba(6, 182, 212, 0.12);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.pwa-tip strong {
  color: var(--text-primary);
}

.tip-desc {
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-secondary);
}

.share-icon {
  font-weight: bold;
  color: var(--accent-secondary);
  border: 1px solid rgba(6, 182, 212, 0.2);
  padding: 0 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
}

.api-info {
  font-size: 9px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(5, 5, 8, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 2000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  width: 100%;
  max-width: 480px;
  height: 80vh;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  display: flex;
  flex-direction: column;
  padding: 20px;
  border-bottom: none;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.open .modal-container {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 600;
}

/* Search Container */
.search-container {
  position: relative;
  width: 100%;
  margin-bottom: 16px;
}

.search-container input {
  width: 100%;
  padding: 12px 16px;
  padding-left: 44px;
  border-radius: 12px;
  border: 1px solid var(--border-glass);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  user-select: text; /* Allow typing */
  transition: all 0.2s;
}

.search-container input:focus {
  border-color: var(--accent-primary);
  background: rgba(255, 255, 255, 0.05);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* Search Results List */
.modal-results-list {
  flex-grow: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 20px;
}

.search-item {
  width: 100%;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.search-item:active {
  background: rgba(124, 58, 237, 0.1);
  border-color: var(--border-active);
}

.search-item-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-item-flag {
  font-size: 24px;
}

.search-item-code {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
}

.search-item-name {
  font-size: 11px;
  color: var(--text-secondary);
  margin-left: 6px;
}

.search-item-check {
  color: var(--accent-primary);
  display: flex;
  align-items: center;
}

/* Toast System */
.toast-container {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: 50%;
  transform: translate(-50%, -100px);
  background: rgba(18, 19, 26, 0.85);
  border: 1px solid var(--border-glass);
  padding: 10px 20px;
  border-radius: 30px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-md);
  z-index: 3000;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  max-width: 90%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast-container.show {
  transform: translate(-50%, 0);
}

.toast-container span {
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 500;
}

/* KRW Multiplier & Arrival Price Styling */
.multiplier-container {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.multiplier-input-row, .arrival-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.multiplier-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.multiplier-input-wrap {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 2px;
}

.mult-adj-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.mult-adj-btn:active {
  background: rgba(255, 255, 255, 0.08);
  transform: scale(0.9);
}
.multiplier-value-display {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  width: 48px;
  height: 32px;
  cursor: pointer;
  user-select: none;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.multiplier-value-display.active-input {
  color: var(--accent-secondary);
  text-shadow: 0 0 8px rgba(6, 182, 212, 0.3);
}

.multiplier-card {
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.multiplier-card.is-active {
  border-color: var(--accent-secondary);
  background: rgba(6, 182, 212, 0.08); /* Cyan highlight background */
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.15);
}

.arrival-label {
  font-size: 12px;
  color: #a78bfa;
  font-weight: 600;
}

.arrival-amount {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--accent-secondary);
  text-shadow: 0 0 10px rgba(6, 182, 212, 0.2);
}

.custom-keypad-section {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  background: rgba(13, 14, 21, 0.85); /* Semi-opaque glassmorphic background to prevent overlap legibility issues */
  border-top: 1px solid var(--border-glass);
  border-left: none;
  border-right: none;
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  padding: 10px 14px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 6px));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 1000;
  box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.5);
  box-sizing: border-box;
}

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.key-btn {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  padding: 8px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 38px;
}

.key-btn:active {
  transform: scale(0.94);
  background: rgba(124, 58, 237, 0.2);
  border-color: var(--border-active);
}

.span-two {
  grid-column: span 2;
}

.clear-key {
  background: rgba(245, 158, 11, 0.05);
  color: #fbbf24;
}

.clear-key:active {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(245, 158, 11, 0.3);
}

.delete-key {
  background: rgba(239, 68, 68, 0.05);
  color: #f87171;
}

.delete-key:active {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.3);
}

/* Active Card & Virtual Typing Styles */
.currency-card.is-base {
  border-color: var(--accent-secondary);
  background: rgba(6, 182, 212, 0.08); /* Cyan highlight background */
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.15);
}

.converted-amount.active-input {
  color: var(--accent-secondary);
  text-shadow: 0 0 8px rgba(6, 182, 212, 0.3);
}

.blink-cursor {
  font-family: monospace;
  font-weight: 300;
  margin-left: 2px;
  color: var(--accent-secondary);
  animation: cursor-blink 1s step-end infinite;
}

@keyframes cursor-blink {
  from, to { opacity: 0 }
  50% { opacity: 1 }
}

/* Dedicated Multiplier Card Styling */
.multiplier-section {
  margin-bottom: 14px;
}

.multiplier-card {
  padding: 12px 14px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.multiplier-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--accent-primary-gradient);
}



