:root {
  --bg: #f6f8fc;
  --bg-soft: #eef4ff;
  --card: rgba(255, 255, 255, 0.94);
  --card-strong: #ffffff;
  --accent: #4d7cff;
  --accent-soft: #edf3ff;
  --accent-strong: #3b63db;
  --text: #172033;
  --subtext: #73809a;
  --line: #e8edf5;
  --line-strong: #dbe4f0;
  --positive: #14a46d;
  --positive-soft: #e8fbf3;
  --negative: #ea5b6f;
  --negative-soft: #fff0f3;
  --shadow: 0 12px 32px rgba(83, 100, 146, 0.10);
  --shadow-soft: 0 8px 20px rgba(83, 100, 146, 0.07);
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
  --viewport-height: 100vh;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(130, 175, 255, 0.18), transparent 34%),
    radial-gradient(circle at top right, rgba(121, 223, 212, 0.14), transparent 28%),
    linear-gradient(180deg, #f8fbff 0%, #f3f7fd 100%);
  color: var(--text);
}

body {
  overscroll-behavior-y: none;
}

body.modal-open {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  background: none;
  color: inherit;
}

#app {
  min-height: 100vh;
}

.shell {
  min-height: 100vh;
  padding: calc(14px + var(--safe-top)) 18px calc(110px + var(--safe-bottom));
}

.shell-has-tabbar {
  padding-bottom: calc(110px + var(--safe-bottom));
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hero-header {
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 10px 0 6px;
}

.brand-mark {
  width: 112px;
  height: 112px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 26px;
  overflow: hidden;
  box-shadow: 0 18px 32px rgba(77, 124, 255, 0.12);
}

.brand-mark-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

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

.header-action-btn {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(232, 237, 245, 0.92);
  color: var(--subtext);
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}

.header-text-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.header-text-btn {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
  white-space: nowrap;
}

.title {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  color: var(--subtext);
  font-size: 15px;
  line-height: 1.4;
}

.card {
  background: var(--card);
  border-radius: 24px;
  padding: 18px;
  border: 1px solid rgba(232, 237, 245, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.screen-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
}

.section-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.link-btn {
  color: var(--accent);
  font-weight: 700;
  padding: 0;
}

.hero-value {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.hero-label {
  color: var(--subtext);
  font-size: 13px;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: flex-start;
}

.overview-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.overview-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.overview-chart-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  align-items: center;
}

.donut-card {
  display: flex;
  justify-content: center;
}

.donut-chart {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  position: relative;
  flex: 0 0 auto;
}

.donut-chart::after {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  background: #fff;
}

.overview-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.overview-legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 14px;
}

.summary-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: right;
}

.muted {
  color: var(--subtext);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  flex: 0 0 auto;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.72);
}

.spacer {
  flex: 1;
}

.caption {
  font-size: 13px;
  color: var(--subtext);
}

.expense-row {
  width: 100%;
  text-align: left;
  background: rgba(245, 248, 255, 0.95);
  border: 1px solid rgba(232, 237, 245, 0.96);
  border-radius: 18px;
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  box-shadow: 0 4px 12px rgba(101, 118, 167, 0.05);
}

.expense-row + .expense-row {
  margin-top: 10px;
}

.expense-row-compact {
  padding: 12px 14px;
  gap: 10px;
}

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

.expense-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
  color: var(--subtext);
  font-size: 12px;
}

.expense-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.expense-row-compact .expense-meta {
  margin-bottom: 3px;
  font-size: 12px;
}

.expense-row-compact .expense-title {
  margin-bottom: 0;
  font-size: 15px;
}

.expense-row-compact .amount {
  font-size: 15px;
}

.expense-subtitle {
  color: var(--subtext);
  font-size: 13px;
}

.expense-side {
  text-align: right;
  flex: 0 0 auto;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
}

.pill-positive {
  background: rgba(77, 124, 255, 0.10);
  color: #4d7cff;
}

.pill-negative {
  background: rgba(115, 128, 154, 0.12);
  color: #73809a;
}

.chips {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.trip-create-card,
.trip-card {
  display: flex;
  align-items: center;
  gap: 14px;
}

.trip-create-card {
  cursor: pointer;
}

.trip-create-icon {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(77, 124, 255, 0.10);
  color: var(--accent);
  font-size: 28px;
  font-weight: 700;
  flex: 0 0 auto;
}

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

.trip-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

.trip-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.trip-meta {
  color: var(--subtext);
  font-size: 13px;
  margin-bottom: 4px;
}

.trip-visibility-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.trip-visibility-badge-public {
  background: rgba(77, 124, 255, 0.10);
  color: #4d7cff;
}

.trip-visibility-badge-private {
  background: rgba(115, 128, 154, 0.12);
  color: #73809a;
}

.trip-stats {
  font-size: 14px;
  font-weight: 700;
}

.trip-enter-btn {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 16px;
  flex: 0 0 auto;
}

.identity-screen {
  padding-top: 30px;
}

.lobby-helper {
  margin-bottom: 12px;
}

.identity-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.identity-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  padding: 16px 12px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  text-align: center;
  font-size: 16px;
  font-weight: 800;
  box-shadow: var(--shadow-soft);
}

.identity-card-active {
  border-color: rgba(77, 124, 255, 0.48);
  background: rgba(237, 243, 255, 0.92);
  color: var(--accent);
}

.identity-skip-row {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

.identity-skip-btn {
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--subtext);
}

.chip {
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  padding: 10px 14px;
  color: var(--subtext);
  font-size: 13px;
  font-weight: 700;
}

.chip-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.section-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.member-main {
  flex: 1;
}

.member-name {
  font-weight: 700;
  margin-bottom: 3px;
}

.settlement-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.empty {
  padding: 16px 0 8px;
  color: var(--subtext);
  font-size: 15px;
}

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  height: calc(66px + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 -10px 24px rgba(92, 110, 157, 0.08);
  display: grid;
  grid-template-columns: 1fr 64px 1fr;
  align-items: center;
  padding: 4px 18px calc(4px + var(--safe-bottom));
  border-top: 1px solid rgba(232, 237, 245, 0.95);
  backdrop-filter: blur(18px);
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 48px;
  border-radius: 12px;
  padding: 0 10px;
  color: var(--subtext);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.tab-btn.active {
  color: var(--accent);
  background: rgba(77, 124, 255, 0.08);
}

.tab-btn-add {
  color: var(--accent);
  gap: 0;
}

.tab-add-icon {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4d7cff 0%, #69b8ff 100%);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  box-shadow: 0 10px 20px rgba(77, 124, 255, 0.28);
}

.tab-label {
  font-size: 11px;
}

.tab-icon {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1.8px solid currentColor;
  opacity: 0.9;
}

.tab-icon-overview {
  position: relative;
}

.tab-icon-overview::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 4px;
  height: 4px;
  border-radius: 999px;
  background: currentColor;
}

.tab-icon-bills {
  border: 0;
  width: 18px;
  height: 18px;
  position: relative;
}

.tab-icon-bills::before,
.tab-icon-bills::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.tab-icon-bills::before {
  top: 5px;
  box-shadow: 0 5px 0 currentColor, 0 10px 0 currentColor;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22, 30, 48, 0.28);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  overscroll-behavior: contain;
  padding-top: calc(18px + var(--safe-top));
}

.sheet {
  width: 100%;
  margin-top: auto;
  height: calc(var(--viewport-height) - (18px + var(--safe-top)));
  max-height: calc(var(--viewport-height) - (18px + var(--safe-top)));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: rgba(248, 251, 255, 0.96);
  border-radius: 28px 28px 0 0;
  padding: 18px 18px 0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  box-shadow: 0 -20px 40px rgba(87, 103, 143, 0.14);
  border-top: 1px solid rgba(232, 237, 245, 0.9);
}

.sheet-editor {
  gap: 0;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 0;
  flex: 0 0 auto;
}

.sheet-scroll {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 12px 0 calc(40px + var(--safe-bottom));
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  overflow-anchor: none;
}

.sheet-scroll::after {
  content: "";
  display: block;
  height: 2px;
  flex: 0 0 auto;
}

.sheet-scroll::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.sheet-title {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
}

.ghost-btn,
.primary-btn,
.danger-btn {
  min-height: 50px;
  border-radius: 18px;
  padding: 0 16px;
  font-weight: 700;
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.9);
  color: var(--subtext);
  border: 1px solid var(--line);
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent) 0%, #69b8ff 100%);
  color: #fff;
  box-shadow: 0 10px 18px rgba(77, 124, 255, 0.22);
}

.primary-btn:disabled {
  background: #d8e0ec;
  color: #8a96a9;
  box-shadow: none;
}

.danger-btn {
  background: var(--negative-soft);
  color: var(--negative);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.field-group-date {
  overflow: hidden;
}

.field-label {
  font-size: 13px;
  color: var(--subtext);
  font-weight: 700;
}

.input,
.select,
.textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 48px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  padding: 12px 14px;
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: rgba(77, 124, 255, 0.5);
  box-shadow: 0 0 0 4px rgba(77, 124, 255, 0.12);
}

.input[type="date"] {
  display: block;
  appearance: none;
  -webkit-appearance: none;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 10px;
}

.input-date::-webkit-date-and-time-value {
  text-align: left;
}

.input-date::-webkit-calendar-picker-indicator {
  margin: 0;
  opacity: 0.9;
}

.textarea {
  min-height: 88px;
  resize: none;
}

.textarea-compact {
  min-height: 74px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.compact-grid {
  gap: 10px;
}

.compact-stack {
  margin-top: 12px;
}

.currency-option-grid {
  margin-top: 10px;
}

.more-currency-btn {
  margin-top: 10px;
  align-self: flex-start;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.option-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.select-card {
  min-height: 48px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  padding: 12px;
  text-align: center;
  font-weight: 700;
  color: var(--text);
}

.compact-card {
  padding: 14px;
}

.compact-select-card {
  min-height: 42px;
  padding: 10px 8px;
  font-size: 13px;
}

.select-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.currency-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  text-align: left;
}

.currency-card-locked {
  opacity: 1;
  cursor: default;
}

.currency-code {
  color: var(--subtext);
  font-size: 12px;
  font-weight: 700;
}

.select-card.active .currency-code {
  color: var(--accent);
}

.creator-card {
  border-color: rgba(77, 124, 255, 0.18);
}

.member-edit-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.member-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.member-remove-btn {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  color: var(--subtext);
  font-size: 13px;
  font-weight: 700;
  flex: 0 0 auto;
}

.member-remove-btn:disabled {
  opacity: 0.45;
}

.preview-card {
  overflow: hidden;
}

.member-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.member-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(77, 124, 255, 0.08);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
}

.inline-actions {
  display: flex;
  gap: 10px;
}

.inline-actions-wrap {
  flex-wrap: wrap;
}

.inline-actions > * {
  flex: 1;
}

.inline-btn {
  min-width: 0;
}

.compact-helper-list {
  gap: 8px;
}

.notice {
  margin-top: 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.notice-inline {
  margin-top: 14px;
}

.helper {
  color: var(--subtext);
  font-size: 13px;
  line-height: 1.5;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.error-text {
  color: var(--negative);
}

.hint-card {
  background: linear-gradient(135deg, rgba(247, 250, 255, 0.96) 0%, rgba(236, 244, 255, 0.96) 100%);
}

.small {
  font-size: 12px;
}

.switch-chip {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  color: var(--subtext);
  font-size: 12px;
  font-weight: 700;
}

.filter-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.switch-chip-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.bills-title-row {
  align-items: flex-start;
}

.detail-row {
  margin-top: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 90;
  max-width: min(88vw, 320px);
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(27, 35, 55, 0.92);
  color: #fff;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  box-shadow: 0 14px 28px rgba(18, 24, 39, 0.24);
  backdrop-filter: blur(12px);
}

@media (min-width: 780px) {
  body {
    display: flex;
    justify-content: center;
    background:
      radial-gradient(circle at top left, rgba(130, 175, 255, 0.2), transparent 28%),
      radial-gradient(circle at top right, rgba(121, 223, 212, 0.16), transparent 26%),
      linear-gradient(180deg, #f8fbff 0%, #eef3fb 100%);
  }

  #app {
    width: 430px;
    min-height: 100vh;
    background: var(--bg);
    box-shadow: 0 0 0 1px rgba(216, 225, 239, 0.75), 0 26px 50px rgba(82, 100, 145, 0.16);
  }
}
