/* Mobile form, upload feedback, and slip preview improvements for v0.2. */
html {
  min-height: 100%;
  scroll-behavior: smooth;
}

.voice-entry-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .85rem 1rem;
  margin: 0 0 1.25rem;
  padding: 1rem;
  border: 1px solid #b9ddd5;
  border-radius: 18px;
  background: linear-gradient(135deg, #edf9f5, #f8fcfa);
}

.voice-entry-heading {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.voice-entry-heading strong,
.voice-entry-heading small {
  display: block;
}

.voice-entry-heading small {
  margin-top: .2rem;
  color: #52645f;
}

.voice-mic-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 14px;
  background: #d9f2eb;
  font-size: 1.25rem;
}

.voice-start-button {
  min-width: 164px;
  align-self: center;
}

.voice-entry-card.is-listening .voice-start-button {
  background: #c93636;
  box-shadow: 0 0 0 6px rgba(201, 54, 54, .14);
}

.voice-entry-card.is-starting .voice-start-button {
  background: #607a73;
  cursor: wait;
}

.voice-entry-card.is-listening .voice-mic-mark {
  animation: voice-pulse 1s ease-in-out infinite;
}

@keyframes voice-pulse {
  50% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(13, 126, 111, .12); }
}

.voice-transcript-label {
  grid-column: 1 / -1;
}

.voice-transcript-label textarea {
  min-height: 76px;
  resize: vertical;
}

.voice-apply-button {
  justify-self: start;
}

.voice-status {
  align-self: center;
  margin: 0;
  color: #52645f;
}

.voice-status[data-tone="success"] { color: #08764c; }
.voice-status[data-tone="warning"] { color: #986000; }
.voice-status[data-tone="error"] { color: #b32424; }
.voice-status[data-tone="listening"] { color: #0d6f63; font-weight: 700; }

.voice-examples {
  grid-column: 1 / -1;
  color: #52645f;
}

.voice-examples summary {
  cursor: pointer;
  color: #0d6f63;
  font-weight: 700;
}

.voice-examples ul {
  margin: .55rem 0 0;
  padding-left: 1.25rem;
}

.voice-examples li + li { margin-top: .35rem; }

@media (max-width: 720px) {
  .voice-entry-card {
    grid-template-columns: 1fr;
  }

  .voice-start-button,
  .voice-apply-button {
    width: 100%;
  }

  .voice-status,
  .voice-examples,
  .voice-transcript-label {
    grid-column: 1;
  }
}

body {
  min-height: 100%;
  overflow-x: hidden;
}

.slip-preview {
  height: 150px;
  overflow: hidden;
}

.slip-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #eef4f1;
}

.selected-slip {
  width: min(260px, 100%);
  display: grid;
  gap: .4rem;
  color: var(--muted);
  font-size: .78rem;
  overflow-wrap: anywhere;
}

.selected-slip[hidden] {
  display: none;
}

.selected-slip img {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--line);
}

button:disabled {
  opacity: .65;
  cursor: wait;
}

.upload-success {
  display: flex;
  align-items: center;
  gap: .7rem;
  flex-wrap: wrap;
  border-radius: 14px;
  padding: 1rem 1.1rem;
  margin: 0 0 1rem;
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
}

.upload-success span {
  color: #34724d;
  font-size: .88rem;
}

.ocr-result {
  display: grid;
  gap: .3rem;
  padding: .9rem 1rem;
  margin-bottom: .8rem;
  border-radius: 12px;
  background: #e7f6ef;
  border: 1px solid #a7dcc2;
  color: #166534;
}

.ocr-result span {
  font-size: .84rem;
}

.danger-notice {
  background: #fff0f0;
  border-color: #fecaca;
  color: #991b1b;
}

.ocr-retry {
  margin: .7rem 0;
}

.local-ocr {
  display: grid;
  gap: .65rem;
  padding: .9rem 0;
}

.ocr-actions {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-wrap: wrap;
}

.privacy-chip {
  border-radius: 999px;
  padding: .35rem .65rem;
  background: #e7f6ef;
  color: #166534;
  font-size: .78rem;
  font-weight: 700;
}

.ocr-progress {
  display: grid;
  gap: .4rem;
}

.ocr-progress[hidden],
.ocr-result[hidden],
.ocr-raw[hidden] {
  display: none;
}

.ocr-progress progress {
  width: 100%;
  height: .75rem;
  accent-color: #147d70;
}

.ocr-raw {
  font-size: .82rem;
}

.ocr-raw pre {
  max-height: 190px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: .7rem;
  border-radius: 10px;
  background: #f5f8f6;
}

.shared-expense-card {
  display: grid;
  gap: .9rem;
  padding: 1rem;
  border: 1px solid #b9d8cf;
  border-radius: 16px;
  background: #f1faf7;
}

.shared-expense-card[hidden],
.shared-detail-grid[hidden],
.shared-calculation[hidden],
[data-mixed-amount-wrap][hidden] {
  display: none;
}

.shared-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .9rem;
}

.shared-calculation {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .55rem;
}

.shared-calculation span,
.member-payment-grid article {
  display: grid;
  gap: .2rem;
  padding: .7rem;
  border-radius: 11px;
  background: #fff;
  color: var(--muted);
  font-size: .78rem;
}

.shared-calculation strong,
.member-payment-grid strong {
  color: var(--ink);
  font-size: .95rem;
}

.shared-label {
  color: var(--brand);
  font-weight: 700;
}

.shared-month-head,
.shared-month-head .month-filter,
.settlement-result,
.member-payment-grid {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.month-filter label {
  min-width: 175px;
}

.settlement-result {
  align-items: center;
  padding: 1.1rem;
  border-radius: 16px;
  background: #fff4d6;
  color: #714d08;
  font-size: 1.05rem;
}

.settlement-result > strong {
  font-size: 1.5rem;
}

.settlement-result.settled {
  background: #dcfce7;
  color: #166534;
}

.member-payment-grid {
  align-items: stretch;
  justify-content: stretch;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 1rem;
}

.member-payment-grid article {
  border: 1px solid var(--line);
}

.mobile-row-actions {
  display: none;
}

.compact-button {
  padding: .48rem .7rem;
  border-radius: 9px;
  font-size: .78rem;
}

.delete-transaction-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.2rem;
  padding: 1rem;
  border: 1px solid #fecaca;
  border-radius: 14px;
  background: #fff7f7;
}

.delete-transaction-zone small {
  margin-top: .25rem;
}

.sub-editor {
  margin: .7rem 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .2rem .8rem .8rem;
  background: #fbfdfc;
}

.sub-editor > summary {
  display: flex;
  justify-content: space-between;
  gap: .8rem;
  cursor: pointer;
  padding: .75rem 0;
}

.record-history {
  margin: 1rem 0;
}

.record-history h2,
.record-history h3,
.debt-card h3 {
  margin: 1rem 0 .4rem;
}

.finance-controls {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
}

.finance-controls .month-filter {
  display: flex;
  align-items: end;
  gap: .6rem;
}

.finance-controls p {
  margin: 0;
}

.finance-equation {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .7rem;
  margin: 1rem 0;
}

.finance-equation span {
  display: grid;
  gap: .25rem;
  padding: .9rem;
  border-radius: 12px;
  background: #edf5f1;
  color: var(--muted);
  font-size: .82rem;
}

.finance-equation strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.debt-plan-list {
  display: grid;
}

.debt-plan-list article {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: .8rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}

.debt-plan-list article > div {
  min-width: 0;
}

.priority-number {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.finance-disclaimer {
  margin-top: 1.2rem;
  font-size: .8rem;
}

.period-filter {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.period-filter > div {
  display: grid;
  gap: .28rem;
}

.date-range-form {
  display: flex;
  align-items: end;
  gap: .6rem;
  flex-wrap: wrap;
}

.date-range-form label {
  min-width: 155px;
}

.entry-switch {
  display: flex;
  align-items: center;
  gap: .55rem;
  flex-wrap: wrap;
  margin: 0 0 1rem;
}

.entry-switch a {
  padding: .72rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

.entry-switch a.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.narrow-panel {
  max-width: 820px;
}

.workspace-switcher label {
  display: flex;
  align-items: center;
  gap: .55rem;
}

.workspace-switcher label > span {
  color: var(--muted);
  font-size: .75rem;
  white-space: nowrap;
}

@media (max-width: 760px) {
  input,
  select,
  textarea {
    font-size: 16px;
  }

  .app-shell {
    min-height: 100dvh;
  }

  .main {
    min-height: 100dvh;
    padding-bottom: calc(42vh + env(safe-area-inset-bottom));
  }

  .auth-shell {
    min-height: 100dvh;
    place-items: start center;
    padding-bottom: calc(38vh + env(safe-area-inset-bottom));
  }

  .main label,
  .main input,
  .main select,
  .main textarea {
    scroll-margin-top: 18vh;
    scroll-margin-bottom: 45vh;
  }

  .form-actions {
    position: sticky;
    bottom: env(safe-area-inset-bottom);
    background: rgba(245, 248, 246, .96);
    padding: .7rem 0;
    z-index: 4;
  }

  .review-grid {
    grid-template-columns: 1fr;
  }

  .shared-detail-grid,
  .shared-calculation {
    grid-template-columns: 1fr;
  }

  .shared-month-head,
  .shared-month-head .month-filter,
  .settlement-result {
    align-items: stretch;
    flex-direction: column;
  }

  .month-filter label {
    min-width: 0;
  }

  .slip-viewer {
    min-height: 260px;
  }

  .mobile-row-actions {
    display: flex;
    align-items: center;
    gap: .55rem;
    margin-top: .7rem;
  }

  .mobile-row-actions form {
    margin: 0;
  }

  .row-actions {
    display: none;
  }

  .delete-transaction-zone {
    align-items: stretch;
    flex-direction: column;
  }

  .delete-transaction-zone button {
    width: 100%;
  }

  .finance-controls,
  .finance-controls .month-filter {
    align-items: stretch;
    flex-direction: column;
  }

  .finance-equation {
    grid-template-columns: 1fr;
  }

  .period-filter,
  .date-range-form {
    align-items: stretch;
    flex-direction: column;
  }

  .date-range-form label {
    min-width: 0;
  }

  .entry-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .entry-switch a {
    text-align: center;
  }

  .entry-switch a:last-child {
    grid-column: 1 / -1;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 1rem 0;
  }

  .top-actions {
    display: flex;
    align-items: stretch;
    width: 100%;
  }

  .workspace-switcher {
    flex: 1;
  }

  .workspace-switcher label {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace-switcher select {
    width: 100%;
  }

  .debt-plan-list article {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .debt-plan-list article > strong {
    grid-column: 2;
  }
}
