:root {
  --green: #22C55E;
  --greenDark: #16A34A;
  --bg: #ffffff;
  --text: #0b0f14;
  --muted: #6b7280;
  --divider: #eceef1;
  --chip: #f3f4f6;
  --shadow: 0 10px 30px rgba(0, 0, 0, .10);
  --shadow2: 0 3px 10px rgba(0, 0, 0, .08);
  --radius: 16px;
  --touch: 56px;
}

* {
  box-sizing: border-box
}

html,
body {
  height: 100%
}

body {
  margin: 0;
  background: #0f0f12;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

/* App Bar */
.appbar {
  height: 56px;
  background: linear-gradient(135deg, rgba(34, 197, 94, 1), rgba(22, 163, 74, 1));
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 10px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: inherit;
  display: grid;
  place-items: center;
  border-radius: 999px;
  cursor: pointer;
}

.icon-btn:active {
  background: rgba(255, 255, 255, .14)
}

.icon-btn svg {
  width: 22px;
  height: 22px
}

.appbar-title {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
}

.title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Logo button (replaces kebab) */
.logo-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  border-radius: 14px;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .10);
}

.logo-btn:active {
  transform: translateY(1px)
}

.logo-mark {
  font-weight: 900;
  font-size: 12px;
  letter-spacing: .3px;
  text-transform: uppercase;
  position: relative;
}

.logo-mark::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .95);
  margin-right: 8px;
  vertical-align: -2px;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19 3c-6 1-10 5-11 11 6-1 10-5 11-11ZM5 21c1-6 5-10 11-11-1 6-5 10-11 11Z'/%3E%3C/svg%3E") center/contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19 3c-6 1-10 5-11 11 6-1 10-5 11-11ZM5 21c1-6 5-10 11-11-1 6-5 10-11 11Z'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* Search bar */
.search-wrap {
  background: linear-gradient(135deg, var(--green), var(--greenDark));
  padding: 10px 12px 12px;
  position: sticky;
  top: 56px;
  z-index: 5;
}

/* When scrolled, search bar floats to top */
.search-wrap.floating {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, 100%);
  border-bottom: 1px solid var(--divider);
  z-index: 10;
  padding-top: 8px;
  padding-bottom: 8px;
}

.search {
  background: #fff;
  border-radius: 12px;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  box-shadow: var(--shadow2);
}

.search-ico {
  color: #64748b;
  display: grid;
  place-items: center;
}

.search-ico svg {
  width: 20px;
  height: 20px
}

.search input {
  border: none;
  outline: none;
  font-size: 18px;
  flex: 1;
}

.clear-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  font-size: 22px;
  color: #64748b;
  border-radius: 999px;
  cursor: pointer;
}

.clear-btn:active {
  background: rgba(0, 0, 0, .06)
}

/* Screens */
.screen {
  padding-bottom: 84px;
  /* bottom nav */
}

.hidden {
  display: none !important
}

/* List rows */
.row-item {
  height: var(--touch);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid var(--divider);
}

.row-item:active {
  background: #f7f8fa
}

.left-ico {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  flex: 0 0 auto;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .06);
}

.left-ico svg {
  width: 22px;
  height: 22px
}

.row-main {
  flex: 1;
  min-width: 0;
}

.row-title {
  font-size: 21px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.row-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.qty {
  color: var(--muted);
  font-size: 18px;
  min-width: 68px;
  text-align: right;
}

.circle {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 2px solid #cfd6de;
  display: grid;
  place-items: center;
  color: #fff;
}

.circle.checked {
  background: var(--green);
  border-color: var(--green);
}

.circle svg {
  width: 18px;
  height: 18px
}

/* Section (recent) */
.section {
  padding: 10px 0 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px 6px;
}

.section-title {
  color: #77808f;
  font-size: 14px;
  letter-spacing: 1px;
  font-weight: 800;
}

.section-icons {
  color: var(--greenDark);
  display: flex;
  gap: 12px;
}

.section-icons svg {
  width: 22px;
  height: 22px
}

/* plus button at right on recent rows */
.plus-pill {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: #ecfdf5;
  color: var(--greenDark);
  display: grid;
  place-items: center;
  font-size: 26px;
  line-height: 0;
  border: 1px solid #d1fae5;
}

/* FAB */
.fab {
  position: fixed;
  right: calc(50% - 260px + 16px);
  bottom: 92px;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 18px;
  background: var(--greenDark);
  color: #fff;
  font-size: 34px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.fab:active {
  transform: translateY(1px)
}

@media (max-width: 520px) {
  .fab {
    right: 16px;
  }
}

/* Bottom nav */
.bottomnav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(520px, 100%);
  height: 64px;
  border-top: 1px solid var(--divider);
  background: #fff;
  display: flex;
}

.navbtn {
  flex: 1;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  color: #64748b;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.navbtn .navico {
  display: grid;
  place-items: center
}

.navbtn svg {
  width: 22px;
  height: 22px
}

.navbtn.is-active {
  color: var(--greenDark)
}

.navbtn:active {
  background: #f3f4f6
}

/* Disabled nav buttons for non-pro features */
.navbtn.disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}

/* Overlay (search results) */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .22);
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.overlay-sheet {
  width: min(520px, 100%);
  margin-top: 110px;
  background: #fff;
  border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow);
  max-height: calc(100vh - 110px);
  overflow: auto;
  padding-bottom: 10px;
}

.overlay-head {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.overlay-title {
  font-size: 18px;
  font-weight: 900
}

.overlay-hint {
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px
}

.overlay-section {
  padding: 10px 0 0
}

.overlay-section-title {
  padding: 8px 14px 6px;
  color: #77808f;
  font-size: 12px;
  letter-spacing: 1px;
  font-weight: 900;
}

.overlay-actions {
  padding: 0 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.chip {
  background: var(--chip);
  border: 1px solid var(--divider);
  padding: 10px 12px;
  border-radius: 999px;
  font-weight: 800;
  cursor: pointer;
}

.chip.primary {
  background: #ecfdf5;
  border-color: #d1fae5;
  color: var(--greenDark);
}

.chip:active {
  transform: translateY(1px)
}

.overlay-footer {
  padding: 10px 14px 14px;
  display: flex;
  justify-content: flex-end
}

/* Cards */
.subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
}

.subhead-title {
  font-size: 22px;
  font-weight: 900;
}

.card {
  margin: 0 14px 14px;
  background: #fff;
  border: 1px solid var(--divider);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .05);
}

.divider {
  height: 10px;
  background: #f7f8fa;
  border-top: 1px solid var(--divider);
  border-bottom: 1px solid var(--divider)
}

.btn {
  border: none;
  background: var(--greenDark);
  color: #fff;
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 900;
  cursor: pointer;
}

.btn:active {
  transform: translateY(1px)
}

.btn.ghost {
  background: transparent;
  color: var(--greenDark);
}

.btn.full {
  width: 100%
}

.input {
  width: 100%;
  border: 1px solid var(--divider);
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;
  outline: none;
}

.input:focus {
  border-color: rgba(34, 197, 94, .55);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .12)
}

.input.small {
  max-width: 150px
}

.form-row {
  display: flex;
  gap: 10px;
  padding: 12px;
  align-items: center;
}

.mini-hint {
  padding: 0 12px 10px;
  color: var(--muted);
  font-size: 13px
}

.profile-head {
  padding: 16px 14px 10px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  background: var(--greenDark);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 900;
  box-shadow: var(--shadow2);
}

.profile-name {
  font-size: 22px;
  font-weight: 900
}

.profile-sub {
  color: var(--muted);
  margin-top: 2px
}

.field {
  display: block;
  padding: 12px;
  border-top: 1px solid var(--divider)
}

.field:first-child {
  border-top: none
}

.field span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 800
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px
}

/* Drawer & sheets */
.drawer-backdrop,
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .22);
  z-index: 30;
}

.drawer {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: 0;
  width: min(520px, 100%);
  height: 100vh;
  background: #fff;
  z-index: 31;
  box-shadow: var(--shadow);
}

.drawer-head {
  height: 56px;
  background: linear-gradient(135deg, var(--green), var(--greenDark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 14px;
}

.drawer-title {
  font-size: 18px;
  font-weight: 900
}

.drawer-body {
  padding: 10px 14px
}

.drawer-item {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
}

.drawer-item:active {
  background: #f7f8fa
}

.drawer-item .name {
  font-size: 18px;
  font-weight: 900
}

.drawer-item .meta {
  color: var(--muted)
}

.drawer-item.is-active .name {
  color: var(--greenDark)
}

/* Generic sheet */
.sheet {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(520px, 100%);
  background: #fff;
  border-radius: 18px 18px 0 0;
  z-index: 31;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sheet-item {
  width: 100%;
  text-align: left;
  border: none;
  background: #fff;
  padding: 16px 14px;
  font-size: 16px;
  cursor: pointer;
  border-top: 1px solid var(--divider);
  font-weight: 800;
}

.sheet-item:first-child {
  border-top: none
}

.sheet-item:active {
  background: #f7f8fa
}

.sheet-item.danger {
  color: #dc2626
}

.sheet-sep {
  height: 10px;
  background: #f7f8fa;
  border-top: 1px solid var(--divider);
  border-bottom: 1px solid var(--divider)
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 10px 14px;
  border-bottom: 1px solid var(--divider);
}

.sheet-title {
  font-size: 16px;
  font-weight: 900;
  color: var(--text)
}

.sheet-form .field {
  border-top: none;
  padding: 12px 14px
}

.sheet-form .row {
  padding: 12px 14px
}

/* Prompt dialog */
.dialog {
  border: none;
  border-radius: 18px;
  padding: 0;
  width: min(420px, calc(100vw - 28px));
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(0, 0, 0, .35)
}

.dialog-inner {
  padding: 14px
}

.dialog-title {
  font-weight: 900;
  font-size: 16px
}

.dialog-input {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--divider);
  font-size: 16px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px
}

/* Safe area (iOS) */
.safe-area {
  height: env(safe-area-inset-bottom);
}

/* Additional classes for new features */
.card-content {
  padding: 14px
}

.integration-buttons {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.integration-btn {
  flex: 1;
  border: 1px solid var(--divider);
  background: #f9fafb;
  color: var(--muted);
  padding: 10px;
  border-radius: 12px;
  text-align: center;
  font-weight: 700;
  cursor: default;
}

.integration-btn:active {
  transform: translateY(1px)
}

/* Pro Plan UI */
.plan-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.plan-card {
  border: 2px solid var(--divider);
  background: #f9fafb;
  border-radius: 16px;
  padding: 14px;
  cursor: pointer;
  position: relative;
  transition: all .2s ease;
  overflow: hidden;
}

.plan-card:active {
  transform: scale(0.98)
}

.plan-card.selected {
  background: #fff;
  border-color: var(--text);
  box-shadow: var(--shadow2);
}

.plan-card#cardPro.selected {
  background: #ecfdf5;
  border-color: var(--greenDark);
  color: var(--greenDark);
}

.plan-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 12px;
}

.plan-name {
  font-size: 18px;
  font-weight: 900
}

.plan-price {
  font-size: 14px;
  color: var(--muted);
  font-weight: 600
}

#cardPro .plan-price {
  color: inherit
}

.plan-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.plan-features li {
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.p-icon {
  font-size: 14px
}

.plan-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--greenDark);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 4px 8px;
  border-bottom-left-radius: 12px;
  text-transform: uppercase;
  display: none;
  /* hidden by default, shown if highlighted/Pro */
}

#cardPro .plan-badge {
  display: block
}

.plan-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center
}

.plan-hint {
  font-size: 12px;
  color: var(--muted)
}

/* Card list (for inspiration and history) */
.card-list {
  margin: 0 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.inspire-card {
  padding: 14px;
  background: #fff;
  border: 1px solid var(--divider);
  border-radius: 18px;
  box-shadow: var(--shadow2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inspire-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.inspire-title {
  font-size: 20px;
  font-weight: 700;
  flex: 1;
  margin-right: 8px;
}

.heart-btn {
  border: none;
  background: transparent;
  color: var(--greenDark);
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.heart-btn svg {
  width: 20px;
  height: 20px
}

.add-btn {
  border: none;
  background: var(--greenDark);
  color: #fff;
  padding: 8px 12px;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
}

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

/* History items - adjust date display */
.history-item .row-sub {
  font-size: 12px;
  color: var(--muted)
}

/* Hide hearts and pro features if not subscribed (visual only) */
.is-pro .abo-option.pro {
  border-color: var(--greenDark);
  background: #d1fae5;
  color: var(--greenDark)
}

.is-pro .abo-option.free {
  color: var(--muted);
  opacity: .6
}

.is-pro #proStatus {
  color: var(--greenDark)
}

/* Integration List */
.integration-list {
  display: flex;
  flex-direction: column;
}

.integration-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
}

.integration-row:last-child {
  border-bottom: none
}

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

.int-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #f3f4f6;
  display: grid;
  place-items: center;
  color: #64748b;
}

.int-name {
  font-weight: 700;
  font-size: 16px
}

.int-btn {
  background: var(--chip);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  border: none;
  cursor: pointer;
}

.int-btn.connected {
  background: #e0f2fe;
  color: #0284c7
}

/* Profile Footer */
.profile-footer {
  text-align: center;
  padding: 20px 14px 40px;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.btn-link-danger {
  background: transparent;
  border: none;
  color: #dc2626;
  opacity: 0.8;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px;
}

.btn-link-danger:active {
  opacity: 1
}

/* Settings Row Style */
.settings-group {
  display: flex;
  flex-direction: column
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 14px;
  border-bottom: 1px solid var(--divider);
  min-height: 50px;
}

.settings-row:last-of-type {
  border-bottom: none
}

.settings-label {
  font-weight: 700;
  font-size: 15px;
  flex: 0 0 auto
}

.settings-input {
  border: none;
  background: transparent;
  text-align: right;
  font-size: 16px;
  color: var(--muted);
  width: 60%;
  outline: none;
  padding: 0;
}

.settings-input:focus {
  color: var(--text)
}

.form-actions {
  padding: 14px
}