:root {
  --canvas: #0a0a0a;
  --surface-soft: #121212;
  --surface-card: #1a1a1a;
  --surface-elevated: #242424;
  --hairline: #2a2a2a;
  --hairline-strong: #3a3a3a;
  --primary: #faff69;
  --primary-active: #e6eb52;
  --on-primary: #0a0a0a;
  --text: #ffffff;
  --body: #cccccc;
  --muted: #888888;
  --muted-soft: #5a5a5a;
  --income: #22c55e;
  --expense: #ef5d83;
  --info: #3b82f6;
  --danger: #ef4444;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--canvas);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  letter-spacing: 0;
}

button,
input {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

input {
  border: 0;
  outline: 0;
}

noscript {
  display: block;
  padding: 24px;
  color: var(--text);
}

#app {
  min-height: 100svh;
}

.app-shell {
  position: relative;
  width: min(100%, 430px);
  min-height: 100svh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--canvas);
}

.screen {
  min-height: 100svh;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 16px calc(116px + var(--safe-bottom));
}

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

.month-title {
  display: grid;
  place-items: center;
  height: 44px;
  font-size: 22px;
  font-weight: 700;
}

.summary-panel,
.calendar-panel,
.day-panel,
.entry-item,
.amount-keypad,
.detail-field,
.category-form-row,
.picker-panel {
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--surface-card);
}

.summary-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
}

.summary-item {
  min-width: 0;
  padding: 14px 12px 13px;
  background: var(--surface-card);
}

.summary-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.summary-value {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.18;
}

.summary-value.income {
  color: var(--income);
}

.summary-value.expense {
  color: var(--expense);
}

.summary-value.balance {
  color: var(--primary);
}

.calendar-panel {
  padding: 12px 8px 10px;
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday {
  height: 24px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.day-cell {
  display: grid;
  place-items: center;
  min-width: 0;
  height: 47px;
  border-radius: 8px;
  background: transparent;
  color: var(--body);
}

.day-cell.is-weekend-sun {
  color: var(--expense);
}

.day-cell.is-weekend-sat {
  color: #6fa3ff;
}

.day-cell.is-outside {
  color: var(--muted-soft);
}

.day-cell.is-today .day-number {
  border-color: var(--hairline-strong);
}

.day-cell.is-selected {
  background: var(--primary);
  color: var(--on-primary);
}

.day-number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
}

.day-panel {
  padding: 0;
  overflow: hidden;
}

.day-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px;
  border-bottom: 1px solid var(--hairline);
}

.day-date {
  flex: 0 0 auto;
  font-size: 15px;
  font-weight: 700;
}

.day-totals {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.day-totals .income {
  color: var(--income);
}

.day-totals .expense {
  color: var(--expense);
}

.entry-list {
  display: flex;
  flex-direction: column;
}

.entry-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto 30px;
  align-items: center;
  gap: 10px;
  min-height: 68px;
  margin: 10px;
  padding: 10px;
  background: var(--surface-soft);
}

.entry-icon,
.category-icon,
.preview-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: white;
}

.entry-icon {
  width: 42px;
  height: 42px;
}

[data-lucide] {
  display: grid;
  place-items: center;
  font-style: normal;
}

.entry-icon svg,
.category-icon svg,
.preview-icon svg,
.control-icon svg,
.entry-icon [data-lucide],
.category-icon [data-lucide],
.preview-icon [data-lucide],
.control-icon [data-lucide] {
  width: 52%;
  height: 52%;
}

.entry-main {
  min-width: 0;
}

.entry-title {
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-subtitle {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-amount {
  justify-self: end;
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}

.entry-amount.income {
  color: var(--income);
}

.entry-amount.expense {
  color: #42c4e5;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
}

.icon-button.muted {
  color: var(--muted);
}

.icon-button [data-lucide] {
  width: 24px;
  height: 24px;
}

.delete-entry {
  width: 30px;
  height: 30px;
  color: var(--muted-soft);
}

.empty-state {
  padding: 34px 18px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.day-balance {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--hairline);
  color: var(--body);
  font-size: 14px;
  font-weight: 600;
}

.day-balance strong {
  color: var(--primary);
  font-size: 18px;
}

.fab {
  position: fixed;
  right: max(18px, calc((100vw - 430px) / 2 + 18px));
  bottom: calc(28px + var(--safe-bottom));
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: none;
}

.fab svg {
  width: 34px;
  height: 34px;
  stroke-width: 2.5;
}

.fab [data-lucide] {
  width: 34px;
  height: 34px;
}

.full-screen {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-bottom: calc(18px + var(--safe-bottom));
  background: var(--canvas);
}

.top-bar {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 72px;
  align-items: center;
  min-height: 48px;
}

.top-title {
  min-width: 0;
  overflow: hidden;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-action {
  justify-self: end;
}

.done-button {
  height: 42px;
  padding: 0 16px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 15px;
  font-weight: 700;
}

.done-button.is-muted {
  background: var(--surface-card);
  color: var(--muted);
}

.amount-date {
  color: var(--muted);
  font-size: 22px;
  font-weight: 500;
}

.amount-screen {
  gap: 20px;
}

.amount-display {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: end;
  gap: 16px;
  min-height: 154px;
}

.currency-mark {
  color: var(--body);
  font-size: 76px;
  font-weight: 700;
  line-height: 1;
}

.amount-number {
  min-width: 0;
  color: #42c4e5;
  font-size: 88px;
  font-weight: 700;
  line-height: 1;
  text-align: right;
  white-space: nowrap;
}

.amount-number.amount-size-md {
  font-size: 68px;
}

.amount-number.amount-size-sm {
  font-size: 50px;
}

.amount-number.amount-size-xs {
  font-size: 40px;
}

.amount-number.amount-size-xxs {
  font-size: 35px;
}

.type-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.type-button {
  height: 70px;
  border-radius: 8px;
  color: white;
  font-size: 23px;
  font-weight: 700;
}

.type-button.income {
  background: linear-gradient(135deg, #18c7bd, #35d976);
}

.type-button.expense {
  background: #f76593;
}

.keypad-spacer {
  flex: 1 1 auto;
  min-height: 8px;
}

.amount-keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  background: #dfe1e3;
  border-color: #dfe1e3;
}

.key-button {
  display: grid;
  place-items: center;
  min-width: 0;
  height: 58px;
  border-radius: 8px;
  background: #fff;
  color: #050505;
  font-size: 26px;
  font-weight: 700;
}

.key-button.is-empty {
  background: transparent;
  pointer-events: none;
}

.key-button svg {
  width: 28px;
  height: 28px;
}

.key-button [data-lucide] {
  width: 28px;
  height: 28px;
}

.detail-screen {
  gap: 18px;
}

.detail-amount {
  color: var(--income);
  font-size: 28px;
  font-weight: 700;
}

.detail-amount.expense {
  color: var(--expense);
}

.detail-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  align-items: center;
  min-height: 56px;
  border-color: var(--hairline-strong);
  background: var(--surface-soft);
}

.detail-input {
  width: 100%;
  min-width: 0;
  padding: 0 14px;
  background: transparent;
  color: var(--text);
  font-size: 24px;
  font-weight: 600;
}

.detail-input::placeholder,
.category-name-input::placeholder {
  color: var(--muted-soft);
}

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

.category-button {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0;
  background: transparent;
  color: var(--body);
}

.category-icon {
  position: relative;
  width: 58px;
  height: 58px;
}

.category-button.is-selected .category-icon {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.category-name {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-button.add-category .category-icon {
  background: var(--surface-elevated);
  color: var(--text);
}

.save-bar {
  margin-top: auto;
}

.save-button {
  width: 100%;
  height: 52px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 17px;
  font-weight: 700;
}

.save-button:disabled,
.type-button:disabled {
  opacity: 0.45;
}

.category-form-screen {
  gap: 24px;
}

.category-preview {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.preview-icon {
  position: relative;
  width: 86px;
  height: 86px;
}

.preview-edit {
  position: absolute;
  right: -24px;
  bottom: 10px;
  font-size: 24px;
}

.category-form-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  align-items: center;
  min-height: 62px;
  padding: 0 14px;
  background: var(--surface-soft);
}

.row-label {
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
}

.category-name-input {
  width: 100%;
  min-width: 0;
  background: transparent;
  color: var(--text);
  font-size: 25px;
  font-weight: 700;
}

.toggle-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 68px;
  align-items: center;
  width: 100%;
  min-height: 56px;
  padding: 0;
  background: transparent;
  color: var(--body);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
}

.switch {
  position: relative;
  width: 58px;
  height: 32px;
  border-radius: 999px;
  background: var(--hairline-strong);
}

.switch::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  content: "";
  transition: transform 160ms ease;
}

.switch.is-on {
  background: #35d976;
}

.switch.is-on::after {
  transform: translateX(26px);
}

.picker-panel {
  padding: 14px;
  background: var(--surface-soft);
}

.picker-title {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.color-row {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.color-dot {
  aspect-ratio: 1;
  min-width: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--dot-color);
}

.color-dot.is-selected {
  border-color: var(--primary);
}

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

.icon-choice {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  border-radius: 8px;
  background: var(--surface-elevated);
  color: var(--text);
}

.icon-choice.is-selected {
  background: var(--primary);
  color: var(--on-primary);
}

.icon-choice svg {
  width: 54%;
  height: 54%;
}

.icon-choice [data-lucide] {
  width: 54%;
  height: 54%;
}

.error-banner {
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.12);
  color: #ff9ba4;
  font-size: 13px;
  font-weight: 600;
}

@media (max-width: 360px) {
  .screen {
    padding-left: 12px;
    padding-right: 12px;
  }

  .category-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .summary-value {
    font-size: 16px;
  }

  .currency-mark {
    font-size: 62px;
  }
}
