/* ── CSS Variables ── */
:root {
  --deep: #061020;
  --ocean: #0a1628;
  --foam: #e8f4f8;
  --tide: #4fc3f7;
  --kelp: #26a69a;
  --coral: #ff7043;
  --sand: #ffd54f;
  --mist: #b0bec5;
  --glass: rgba(255, 255, 255, 0.05);
  --gb: rgba(255, 255, 255, 0.09);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

/* ── Reset ── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--gb) transparent;
}

*::-webkit-scrollbar {
  width: 3px;
  height: 3px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--gb);
  border-radius: 3px;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--tide);
}

html,
body {
  height: 100%;
}

body {
  background: var(--deep);
  color: var(--foam);
  font-family: 'Bricolage Grotesque', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(ellipse at 15% 60%, rgba(79, 195, 247, .07) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 15%, rgba(38, 166, 154, .05) 0%, transparent 50%),
    radial-gradient(ellipse at 55% 85%, rgba(26, 58, 92, .35) 0%, transparent 55%);
}

/* ── App layout ── */
.app {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: calc(1.5rem + var(--safe-top)) 1.5rem calc(4rem + var(--safe-bot));
}

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2.2rem;
  padding-bottom: 1.3rem;
  border-bottom: 1px solid var(--gb);
}

.logo {
  font-family: 'Instrument Serif', serif;
  font-size: 2.2rem;
  color: var(--tide);
  letter-spacing: -1px;
  line-height: 1;
}

.logo em {
  color: var(--foam);
  font-style: italic;
}

/* ── Card ── */
.card {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--gb);
  border-radius: 16px;
  padding: 1.4rem;
  margin-bottom: 1.2rem;
  backdrop-filter: blur(10px);
}

.card-title {
  font-family: 'DM Mono', monospace;
  font-size: .68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .13em;
  color: var(--mist);
  margin-bottom: .9rem;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .58rem 1.1rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: .84rem;
  font-weight: 600;
  transition: all .15s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--tide), var(--kelp));
  color: var(--deep);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(79, 195, 247, .28);
}

.btn-ghost {
  background: var(--glass);
  border: 1px solid var(--gb);
  color: var(--foam);
}

.btn-ghost:hover {
  border-color: var(--tide);
  background: rgba(79, 195, 247, .07);
}

.btn-sand {
  background: rgba(255, 213, 79, .11);
  border: 1px solid rgba(255, 213, 79, .24);
  color: var(--sand);
}

.btn-sand:hover {
  background: rgba(255, 213, 79, .2);
}

.btn-coral {
  background: rgba(255, 112, 67, .13);
  border: 1px solid rgba(255, 112, 67, .28);
  color: var(--coral);
}

.btn-coral:hover {
  background: rgba(255, 112, 67, .22);
}

.btn-danger {
  background: rgba(255, 82, 82, .12);
  border: 1px solid rgba(255, 82, 82, .3);
  color: #ff5252;
}

.btn-danger:hover {
  background: rgba(255, 82, 82, .22);
}

.act-row {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
}

/* ── Modal shell ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 16, 32, .9);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

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

.modal {
  background: #0d1e34;
  border: 1px solid var(--gb);
  border-radius: 20px 20px 0 0;
  padding: 1.9rem 1.9rem calc(1.9rem + var(--safe-bot));
  width: 100%;
  max-width: 560px;
  transform: translateY(60px);
  transition: transform .25s cubic-bezier(.34, 1.2, .64, 1);
  max-height: 92vh;
  overflow-y: auto;
}

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

@media (min-width: 600px) {
  .overlay {
    align-items: center;
  }

  .modal {
    border-radius: 20px;
    padding: 1.9rem;
    max-height: 88vh;
  }
}


.modal-title {
  font-family: 'Instrument Serif', serif;
  font-size: 1.5rem;
  color: var(--foam);
  margin-bottom: .3rem;
}

.modal-sub {
  font-size: .77rem;
  color: var(--mist);
  margin-bottom: 1.35rem;
  font-style: italic;
}

/* ── Shared form elements ── */
.fg {
  margin-bottom: .85rem;
}

.fl {
  display: block;
  font-family: 'DM Mono', monospace;
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--mist);
  margin-bottom: .32rem;
}

.fi,
.fs {
  width: 100%;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--gb);
  border-radius: 8px;
  padding: .58rem .82rem;
  color: var(--foam);
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: .88rem;
  outline: none;
  transition: border-color .15s;
}

.fi:focus,
.fs:focus {
  border-color: var(--tide);
}

.fs option {
  background: var(--ocean);
}

.frow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .68rem;
}

.frow3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: .68rem;
}

.m-actions {
  display: flex;
  gap: .68rem;
  margin-top: 1.35rem;
  flex-wrap: wrap;
}

.m-actions .btn {
  flex: 1;
  justify-content: center;
  min-width: 120px;
}

.section-divider {
  height: 1px;
  background: var(--gb);
  margin: 1.4rem 0;
}

.section-head {
  font-family: 'DM Mono', monospace;
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--mist);
  margin-bottom: .9rem;
}

/* ── Autocomplete ── */
.inp-wrap {
  position: relative;
}

.sug-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #0d1e34;
  border: 1px solid var(--tide);
  border-radius: 8px;
  z-index: 200;
  max-height: 165px;
  overflow-y: auto;
  margin-top: 2px;
}

.sug-item {
  padding: .48rem .82rem;
  font-size: .83rem;
  cursor: pointer;
  color: var(--foam);
  border-bottom: 1px solid var(--gb);
}

.sug-item:last-child {
  border-bottom: none;
}

.sug-item:hover,
.sug-item:active {
  background: rgba(79, 195, 247, .09);
  color: var(--tide);
}

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 2rem;
  color: var(--mist);
}

.empty .ei {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  margin: 0 auto .45rem;
  display: block;
}

.empty p {
  font-size: .82rem;
  font-style: italic;
}

/* ── Toast notification ── */
.notif {
  position: fixed;
  bottom: calc(1.5rem + var(--safe-bot));
  right: 1.5rem;
  background: var(--ocean);
  border: 1px solid var(--tide);
  border-radius: 10px;
  padding: .68rem 1.05rem;
  font-size: .79rem;
  color: var(--foam);
  z-index: 300;
  transform: translateY(120px);
  opacity: 0;
  transition: all .3s;
  max-width: 300px;
}

.notif.show {
  transform: translateY(0);
  opacity: 1;
}

.notif.ok {
  border-color: var(--kelp);
}

.notif.err {
  border-color: var(--coral);
  color: var(--coral);
}

/* ── Install / update banners ── */
.install-banner {
  position: fixed;
  top: calc(1rem + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  background: var(--ocean);
  border: 1px solid rgba(79, 195, 247, .3);
  border-radius: 12px;
  padding: .65rem 1.1rem;
  font-size: .78rem;
  color: var(--foam);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: .75rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .4);
  white-space: nowrap;
}

.install-banner button {
  background: var(--tide);
  color: var(--deep);
  border: none;
  border-radius: 7px;
  padding: .3rem .75rem;
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.install-banner .ib-close {
  background: none;
  border: none;
  color: var(--mist);
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
  line-height: 1;
}

/* ── App loading screen ── */
#app-loading {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  transition: opacity .35s ease;
}

#app {
  opacity: 0;
  transition: opacity .4s ease;
}

#setup {
  opacity: 0;
  transition: opacity .4s ease;
}

#app-loading img {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  animation: loading-bob 2s ease-in-out infinite;
}

@keyframes loading-bob {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

/* ── Responsive ── */
@media (max-width: 580px) {
  .frow3 {
    grid-template-columns: 1fr 1fr;
  }
}
