:root {
  --bg-1: #fff4ec;
  --bg-2: #e6f0fb;
  --bg-3: #fef9e7;
  --ink: #19222d;
  --muted: #52657a;
  --line: rgba(25, 34, 45, 0.12);
  --accent: #ff5e3a;
  --accent-2: #1c6ff5;
  --accent-3: #ffb703;
  --ok: #1b8a4a;
}

* {
  box-sizing: border-box;
  min-width: 0;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1100px 700px at 8% 6%, rgba(255, 94, 58, 0.28), transparent 55%),
    radial-gradient(900px 700px at 92% 14%, rgba(255, 183, 3, 0.22), transparent 52%),
    radial-gradient(1000px 800px at 85% 92%, rgba(28, 111, 245, 0.28), transparent 58%),
    radial-gradient(700px 600px at 10% 95%, rgba(27, 138, 74, 0.14), transparent 55%),
    linear-gradient(135deg, var(--bg-1), var(--bg-3) 45%, var(--bg-2));
  background-attachment: fixed;
}

/* Mobile-first base: the app fills the whole viewport, edge to edge. */
.app-shell {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.card {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(700px 500px at -5% -5%, rgba(255, 94, 58, 0.4), transparent 50%),
    radial-gradient(650px 500px at 105% 8%, rgba(255, 183, 3, 0.32), transparent 50%),
    radial-gradient(800px 600px at 100% 105%, rgba(28, 111, 245, 0.38), transparent 55%),
    radial-gradient(600px 500px at -5% 100%, rgba(27, 138, 74, 0.22), transparent 55%),
    linear-gradient(160deg, var(--bg-1), var(--bg-3) 45%, var(--bg-2));
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  animation: rise 420ms ease-out;
}

.card-header h1 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.4em;
  font: 800 clamp(1.4rem, 6.5vw, 2.8rem) / 1.15 "Syne", "Trebuchet MS", sans-serif;
  letter-spacing: -0.02em;
  overflow-wrap: break-word;
  hyphens: auto;
}

.title-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 1.3em;
  height: 1.3em;
  border-radius: 0.4em;
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  color: #fff;
  font-size: 0.55em;
  box-shadow: 0 4px 12px rgba(255, 94, 58, 0.35);
}

.install-btn {
  margin-top: 12px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.install-btn:hover {
  filter: brightness(0.97);
}

.subtitle {
  color: var(--muted);
  margin: 10px 0 0;
  overflow-wrap: break-word;
}

.field {
  display: grid;
  gap: 8px;
}

.field select,
.field input {
  width: 100%;
}

.field span {
  font-size: 0.9rem;
  color: var(--muted);
}

input,
select,
button {
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 48px;
  padding: 0 14px;
  font: 500 1rem "Space Grotesk", "Segoe UI", sans-serif;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid rgba(28, 111, 245, 0.25);
  border-color: var(--accent-2);
}

.add-currency-bar {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  flex: 0 0 auto;
}

.add-currency-bar .field {
  flex: 1;
}

.add-btn {
  cursor: pointer;
  background: linear-gradient(120deg, var(--accent), #ff8a3d);
  color: #fff;
  border: 0;
  font-weight: 700;
  padding: 0 18px;
  transition: transform 120ms ease, filter 160ms ease;
}

.add-btn:hover {
  filter: brightness(1.03);
}

.add-btn:active {
  transform: translateY(1px) scale(0.99);
}

.add-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.currency-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.currency-row {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  flex: 0 0 auto;
}

.currency-row.drag-over .row-content {
  box-shadow: 0 0 0 2px var(--accent-2) inset;
}

.swipe-delete-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  background: linear-gradient(120deg, #d0201c, #ef4136);
  color: #fff;
  border-radius: inherit;
}

.swipe-delete-icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  margin-right: 14px;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  line-height: 1;
}

.row-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
  border-radius: 16px;
  padding: 8px;
  touch-action: pan-y;
  box-shadow: 0 1px 2px rgba(20, 32, 45, 0.05);
  transition: box-shadow 160ms ease, transform 160ms ease;
}

.row-handle {
  cursor: grab;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  padding: 12px 8px;
  margin: -12px -8px;
  flex: 0 0 auto;
  text-align: center;
}

.currency-row.dragging .row-content {
  box-shadow: 0 10px 24px rgba(20, 32, 45, 0.2);
  background: #fff;
}

.row-info {
  flex: 0 0 auto;
  overflow: hidden;
}

.row-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.row-flag {
  width: 1.5em;
  height: 1em;
  border-radius: 2px;
  flex: 0 0 auto;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.row-code {
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.row-name {
  display: none;
  font-size: 0.76rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-amount-wrap {
  position: relative;
  flex: 1;
  overflow: hidden;
}

.row-amount {
  width: 100%;
  padding-right: 30px;
  text-align: right;
  font: 700 1.05rem "Space Grotesk", "Segoe UI", sans-serif;
}

.clear-amount-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  cursor: pointer;
}

.clear-amount-btn:hover {
  background: rgba(20, 32, 45, 0.08);
}

.row-amount:placeholder-shown + .clear-amount-btn {
  display: none;
}

.row-actions {
  display: flex;
  gap: 2px;
  flex: 0 0 auto;
}

.icon-btn {
  min-height: 34px;
  min-width: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  flex: 0 0 auto;
}

.icon-btn:hover {
  filter: brightness(0.97);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.remove-btn {
  color: #b11f1f;
}

.meta {
  margin: 16px 0 0;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  flex: 0 0 auto;
}

#statusText.ok {
  color: var(--ok);
}

#statusText.warn {
  color: #b7791f;
}

#statusText.error {
  color: #b11f1f;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* From here up: enough room to show the decorative floating card
   instead of the full-bleed mobile layout. */
@media (min-width: 640px) {
  body {
    display: grid;
    place-items: center;
    padding: 24px;
  }

  .app-shell {
    width: min(780px, 100%);
    min-height: 0;
  }

  .card {
    min-height: 0;
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: clamp(18px, 3vw, 30px);
    backdrop-filter: blur(12px);
    box-shadow: 0 20px 50px rgba(20, 32, 45, 0.15);
  }

  .card-header h1 {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
  }

  .add-currency-bar {
    flex-direction: row;
    align-items: end;
  }

  .currency-list {
    max-height: min(56vh, 480px);
    gap: 10px;
    margin-top: 22px;
  }

  .row-content {
    gap: 12px;
    padding: 10px 12px;
  }

  .row-name {
    display: block;
    max-width: 22vw;
  }

  .row-amount {
    font-size: 1.15rem;
  }

  .icon-btn {
    min-height: 36px;
    min-width: 36px;
  }
}
