/* Final visual pass: flatter sheets, quieter calendar and native-feeling motion. */

.app,
.tab-bar {
  transition: opacity 160ms ease;
}

body.app-loading .app,
body.app-loading .tab-bar {
  opacity: .62;
}

.app-page.page-entering {
  animation: page-enter 170ms cubic-bezier(.22,.78,.26,1) both;
}

.app-page.page-entering.from-right {
  --page-shift: 7px;
}

.app-page.page-entering.from-left {
  --page-shift: -7px;
}

@keyframes page-enter {
  from {
    opacity: .54;
    transform: translateX(var(--page-shift, 0));
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Calendar income days should read as a hint, not as cards. */
.day.has-income {
  background: rgba(17, 17, 18, .022);
}

@media (prefers-color-scheme: dark) {
  .day.has-income {
    background: rgba(255, 255, 255, .028);
  }
}

/* Bottom sheets: one surface, almost no nested cards. */
.sheet {
  background: var(--surface);
}

.icon-button {
  background: transparent;
  border-radius: 999px;
}

.icon-button:active {
  background: var(--press);
}

.entries {
  gap: 0;
  padding-top: 0;
}

.entry {
  background: transparent;
  border-radius: 0;
  padding: 15px 2px;
  border-bottom: 1px solid var(--line);
}

.entry:last-child {
  border-bottom: 0;
}

.entry:active {
  background: transparent;
  opacity: .56;
  transform: none;
}

.empty-state {
  min-height: 112px;
  background: transparent;
  border-radius: 0;
  padding: 28px 10px;
}

.sheet-footer {
  padding-top: 12px;
}

/* Forms: only the money field gets a divider. */
.form {
  gap: 0;
}

.field {
  padding: 15px 2px 16px;
  background: transparent;
  border-radius: 0;
  border-bottom: 0;
}

.field:has(#amountInput),
.field:has(#paymentAmountInput) {
  padding-top: 8px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.field-label {
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 540;
  color: var(--muted);
}

.amount-input {
  font-size: clamp(38px, 11vw, 46px);
  line-height: 1;
  font-weight: 700;
  letter-spacing: -.055em;
}

.amount-currency {
  font-size: 21px;
  font-weight: 570;
}

.text-input,
.comment-input {
  font-weight: 520;
}

.comment-input {
  min-height: 52px;
  max-height: 128px;
}

.field-error {
  padding-top: 5px;
}

.form-actions {
  padding-top: 12px;
}

/* Debt headers */
#debtSheet .form-header {
  margin-inline: 6px;
}

#debtSheet .debt-detail-header {
  grid-template-columns: 40px minmax(0, 1fr) 40px;
}

#debtSheet .debt-form-header {
  grid-template-columns: 44px minmax(0, 1fr) 60px;
}

#debtSheet .debt-form-header .save-button {
  padding-right: 2px;
}

.debt-edit-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  width: 40px;
  height: 40px;
  padding: 8px;
  display: grid;
  place-items: center;
  justify-self: end;
  border-radius: 999px;
  cursor: pointer;
  opacity: .82;
  transition: opacity 110ms ease, background-color 110ms ease, transform 100ms ease;
}

.debt-edit-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.debt-edit-button:active {
  opacity: .55;
  background: var(--press);
  transform: scale(.94);
}

/* Debt form: explicit hierarchy, compact spacing and a hidden native date picker. */
.debt-form {
  padding: 0 4px 4px;
}

.debt-form .field {
  padding-left: 0;
  padding-right: 0;
}

.debt-form .debt-amount-field {
  padding-top: 8px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.debt-form .debt-name-field {
  padding-top: 16px;
  padding-bottom: 12px;
}

.debt-form .debt-date-field {
  padding-top: 11px;
  padding-bottom: 11px;
}

.debt-form .debt-comment-field {
  padding-top: 12px;
  padding-bottom: 4px;
}

.debt-form .text-input,
.debt-form .comment-input {
  font-size: 17px;
  line-height: 1.35;
}

.debt-date-heading {
  min-height: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.debt-date-heading .field-label {
  margin-bottom: 5px;
}

.debt-date-clear {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 560;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, color 120ms ease;
}

.debt-date-clear.visible {
  opacity: 1;
  pointer-events: auto;
}

.debt-date-clear:active {
  color: var(--text);
}

.debt-date-control {
  position: relative;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
}

.debt-date-value {
  min-width: 0;
  color: var(--text);
  font-size: 17px;
  line-height: 1.25;
  font-weight: 520;
  letter-spacing: -.012em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.debt-date-chevron {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--muted-2);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.debt-date-native {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

/* Debt detail: one divider immediately after the amount, no extra rules below. */
.debt-detail {
  gap: 18px;
}

.debt-hero {
  padding: 8px 0 10px;
}

.debt-detail-grid {
  padding: 12px 0 14px;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.debt-note {
  padding: 4px 0 8px;
}

.payment-person {
  padding: 2px 0 8px;
}

.payment-form .debt-amount-field {
  padding-top: 8px;
}

.debt-toggle {
  min-height: 58px;
  padding: 14px 54px 14px 2px;
  border-radius: 0;
  background: transparent;
  border-bottom: 0;
}

.toggle-ui {
  right: 2px;
}

.payment-note {
  padding: 10px 2px 0;
}

/* Keep only the single intended divider before the debt list. */
.debts-list {
  padding-top: 12px;
}

@media (max-width: 360px) {
  #debtSheet .form-header {
    margin-inline: 3px;
  }

  .debt-form {
    padding-inline: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-page.page-entering {
    animation: none;
  }
}
