.window {
  color: #050505;
}

.app-shell {
  background: #d8d8d8;
}

.wizard-window {
  min-height: 760px;
}

.wizard-layout {
  min-height: calc(760px - 53px);
}

.mobile-poly {
  display: none;
}

.app-brand-strip {
  display: none;
}

.titlebar,
.app-titlebar {
  position: relative;
  height: 53px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid #c9ced2;
  background: linear-gradient(#f7f7f7, #eceff2);
}

.titlebar h1,
.app-titlebar h1 {
  font-size: 29px;
  font-weight: 700;
  color: #4a4a4a;
}

.titlebar::after,
.app-titlebar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, #ff9f00, #ff4b00, #c51d12);
}

.poly-rail {
  background:
    linear-gradient(143deg, transparent 0 18%, rgba(255, 255, 255, 0.1) 18.2% 18.6%, transparent 18.8%),
    linear-gradient(23deg, transparent 0 38%, rgba(255, 255, 255, 0.14) 38.2% 38.6%, transparent 38.8%),
    linear-gradient(165deg, #ffc400 0 8%, #ff7a00 8% 31%, #ff3d00 31% 55%, #d71d12 55% 72%, #821811 72% 100%);
}

.poly-rail::before,
.poly-rail::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(31deg, transparent 0 23%, rgba(255, 255, 255, 0.16) 23.3% 23.7%, transparent 24%),
    linear-gradient(118deg, transparent 0 45%, rgba(255, 255, 255, 0.11) 45.3% 45.7%, transparent 46%),
    linear-gradient(72deg, transparent 0 63%, rgba(30, 0, 0, 0.2) 63.3% 63.7%, transparent 64%);
}

.poly-rail::after {
  clip-path: polygon(0 60%, 100% 57%, 100% 100%, 0 100%);
  background: linear-gradient(145deg, rgba(179, 18, 13, 0.7), rgba(43, 10, 8, 0.6));
}

.brand-mark {
  position: absolute;
  left: 50%;
  top: 445px;
  z-index: 1;
  width: 360px;
  max-width: none;
  transform: translateX(-50%);
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.08));
}

.rail-version {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 28px;
  z-index: 2;
  color: rgba(255, 255, 255, 0.72);
  font-size: 20px;
  text-align: center;
}

.mobile-brand-mark {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: 172px;
  max-width: none;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.12));
}

.mobile-version-note {
  display: none;
}

.soft-panel {
  border: 1px solid #e2e2e2;
  border-radius: 9px;
  background: #f6f6f6;
}

.orange-panel {
  border-color: #f2ad72;
  background: linear-gradient(#fffaf5, #f7f7f7);
}

.soft-panel hr {
  margin: 20px 0;
  border: 0;
  border-top: 1px solid #bcbcbc;
}

.login-content {
  position: relative;
  display: flex;
  flex-direction: column;
}

.login-panel-wrap {
  width: min(925px, 100%);
}

.login-choice-panel {
  padding: 28px 30px;
}

.line-option {
  min-height: 56px;
}

.login-option-list {
  display: grid;
  gap: 14px;
}

.login-option-list .line-option + .line-option {
  border-top: 1px solid #c9c9c9;
  padding-top: 14px;
}

.choice-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-content {
  display: none;
  margin-top: 32px;
  border-top: 1px solid #bcbcbc;
  padding-top: 26px;
  padding-left: 42px;
  font-size: 20px;
}

.choice-content.active {
  display: block;
}

.choice-content p {
  color: #686868;
}

.login-inline-form {
  max-width: 360px;
  margin-top: 12px;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 28px;
}

.option-row strong {
  line-height: 1.18;
}

.option-row p,
.restore-note p {
  font-size: 16px;
  color: #686868;
}

.radio-dot {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid #c7c7c7;
  background: white;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.13);
}

.radio-dot.checked {
  border: 8px solid #ff6a00;
}

.choice-input:checked + .radio-dot {
  border: 8px solid #ff6a00;
}

.desktop-button,
.icon-button {
  min-height: 42px;
  padding: 4px 28px;
  border: 1px solid #c9c9c9;
  border-radius: 10px;
  background: linear-gradient(#ffffff, #f6f6f6);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.13);
  font-size: 28px;
  line-height: 1.1;
  color: #030303;
  text-align: center;
}

.desktop-button:hover,
.icon-button:hover {
  background: #ffffff;
}

.primary-button {
  border-color: #df6f10;
  background: linear-gradient(#ffb347, #ff7b00);
  color: #1d1105;
  font-weight: 700;
}

.primary-button:hover {
  background: linear-gradient(#ffc15f, #ff8a17);
}

.focus-ring {
  outline: 4px solid rgba(255, 122, 0, 0.32);
}

.danger-button {
  color: #951313;
}

.desktop-input {
  min-height: 38px;
  border: 1px solid #aaa;
  background: white;
  padding: 5px 10px;
  font-size: 20px;
  color: #111;
}

.desktop-input:focus {
  border-color: #ff7b00;
  outline: 3px solid rgba(255, 122, 0, 0.18);
}

.desktop-input::placeholder {
  color: #b9b9b9;
}

.option-button {
  margin-left: auto;
  flex: 0 0 auto;
}

.wizard-footer {
  min-height: 124px;
  border-top: 1px solid #bfc4c8;
  background: #eeeeee;
  display: flex;
  align-items: center;
  gap: 30px;
  padding: 0 34px;
}

.menubar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 30px;
  padding: 0 24px;
  border-bottom: 1px solid #c8c8c8;
  background: #f4f4f4;
  font-size: 30px;
}

.tabs {
  display: flex;
  min-height: 55px;
  border-bottom: 1px solid #bfc4c8;
  background: #ececec;
  overflow-x: auto;
}

.tab {
  display: flex;
  align-items: center;
  padding: 0 25px;
  border-right: 1px solid #c7c7c7;
  border-left: 1px solid #dedede;
  font-size: 28px;
  white-space: nowrap;
}

.tab.active {
  background: #fff7ef;
  border-bottom: 3px solid #ff6a00;
  color: #7a2b00;
}

.classic-table {
  border: 1px solid #b9b9b9;
  background: white;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.expense-grid {
  grid-template-columns: 90px minmax(260px, 1fr) 180px 150px 140px;
  min-width: 820px;
}

.budget-grid {
  grid-template-columns: minmax(220px, 1fr) 180px 180px 60px;
  min-width: 640px;
}

.classic-table .grid > div,
.classic-table .grid > form {
  min-height: 40px;
  border-right: 1px solid #d1d1d1;
  padding: 4px 8px;
}

.table-row:hover,
.table-row:nth-child(6n) {
  background: #ff7b00;
  color: white;
}

.delete-link {
  font-size: 26px;
  color: #9b1616;
}

.home-row {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #d1d1d1;
  padding: 6px 10px;
  font-size: 20px;
}

.home-row:last-child {
  border-bottom: 0;
}

.row-link {
  color: inherit;
  text-decoration: none;
}

.row-link:hover {
  text-decoration: underline;
}

.detail-shell {
  display: grid;
  gap: 18px;
  max-width: 920px;
}

.transaction-detail-card {
  background: #fff;
}

.detail-amount {
  color: #7a2b00;
  font-size: 38px;
  font-weight: 800;
}

.detail-list {
  display: grid;
  gap: 10px;
  margin-top: 22px;
  font-size: 22px;
}

.detail-list div {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  border-bottom: 1px solid #d1d1d1;
  padding-bottom: 8px;
}

.detail-list dt {
  color: #666;
}

.detail-list dd {
  min-width: 0;
  font-weight: 700;
}

.transaction-request {
  display: grid;
  gap: 14px;
}

.transaction-token {
  aspect-ratio: 1;
  border: 1px solid #b9b9b9;
  background:
    linear-gradient(90deg, #ff7b00 9px, transparent 9px) 0 0 / 22px 22px,
    linear-gradient(#ffb347 8px, transparent 8px) 0 0 / 22px 22px,
    linear-gradient(45deg, transparent 44%, #9b1712 45% 55%, transparent 56%) 0 0 / 34px 34px,
    #fff7ef;
}

.qr-card {
  display: grid;
  gap: 14px;
}

.fake-qr {
  aspect-ratio: 1;
  border: 6px solid white;
  background:
    linear-gradient(90deg, #000 10px, transparent 10px) 0 0 / 24px 24px,
    linear-gradient(#000 10px, transparent 10px) 0 0 / 24px 24px,
    linear-gradient(45deg, transparent 44%, #000 45% 55%, transparent 56%) 0 0 / 36px 36px,
    #fff;
  box-shadow: inset 0 0 0 10px #fff;
}

.status-tile {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 68px;
  border: 1px solid #b9b9b9;
  background: #f7f7f7;
  padding: 8px 16px;
  font-size: 24px;
}

.status-tile:first-child {
  border-left: 6px solid #ff9f00;
}

.status-tile:nth-child(2) {
  border-left: 6px solid #ff6a00;
}

.status-tile:nth-child(3) {
  border-left: 6px solid #c51d12;
}

.status-tile strong {
  font-size: 30px;
}

.progress {
  width: min(330px, 100%);
  height: 12px;
  margin-top: 4px;
  border: 1px solid #aaa;
  background: #fff;
}

.progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #ffb347, #ff6a00);
}

.statusbar {
  position: sticky;
  bottom: 0;
  min-height: 62px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  border-top: 1px solid #bfc4c8;
  background: #fff7ef;
  padding: 0 8px;
  font-size: 27px;
}

.bottom-nav {
  display: none;
}

.bottom-nav-spacer {
  display: none;
}

.bottom-nav-item {
  min-width: 0;
}

.nav-symbol {
  display: block;
  font-size: 26px;
  line-height: 1;
}

.green-led {
  display: inline-block;
  width: 37px;
  height: 37px;
  margin-left: 12px;
  vertical-align: middle;
  border-radius: 999px;
  background: radial-gradient(circle at 35% 35%, #ffd36c, #ff7b00 60%, #bf3700);
}

.seed-box {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 24px;
  border: 2px solid #333;
  padding: 26px 34px;
}

.coin-icon {
  align-self: center;
  color: #ff7b00;
  font-size: 54px;
}

.coin-icon.danger {
  color: #b00000;
}

.flash {
  border: 1px solid #b8b8b8;
  background: #f8f8f8;
  padding: 8px 12px;
  font-size: 18px;
}

.flash.success {
  border-color: #7aac6e;
}

.flash.error {
  border-color: #ba6a6a;
}

@media (max-width: 1024px) {
  body {
    background: #fff;
  }

  .app-shell {
    background: #fff;
  }

  .wizard-window {
    min-height: 100vh;
    border-left: 0;
    border-right: 0;
  }

  .wizard-layout {
    min-height: calc(100vh - 48px);
  }

  .poly-rail {
    display: none;
  }

  .mobile-poly {
    position: relative;
    display: block;
    height: 142px;
    overflow: hidden;
    border-bottom: 1px solid #c9ced2;
    background:
      linear-gradient(143deg, transparent 0 18%, rgba(255, 255, 255, 0.12) 18.2% 18.6%, transparent 18.8%),
      linear-gradient(28deg, transparent 0 42%, rgba(255, 255, 255, 0.16) 42.2% 42.6%, transparent 42.8%),
      linear-gradient(105deg, #ffc400 0 11%, #ff7a00 11% 40%, #ff3d00 40% 72%, #9b1712 72% 100%);
  }

  .app-brand-strip {
    position: sticky;
    top: 48px;
    z-index: 24;
  }

  .mobile-version-note {
    display: block;
    border-bottom: 1px solid #d7d7d7;
    padding: 12px 22px;
    color: #b8b8b8;
    font-size: 18px;
  }

  .mobile-poly::before,
  .mobile-poly::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
      linear-gradient(31deg, transparent 0 32%, rgba(255, 255, 255, 0.13) 32.2% 32.8%, transparent 33%),
      linear-gradient(122deg, transparent 0 58%, rgba(80, 0, 0, 0.17) 58.2% 58.8%, transparent 59%);
  }

  .mobile-poly::after {
    inset: auto 0 0;
    height: 44%;
    background: linear-gradient(145deg, rgba(205, 27, 14, 0.72), rgba(79, 14, 10, 0.75));
    clip-path: polygon(0 16%, 100% 0, 100% 100%, 0 100%);
  }

  .titlebar,
  .app-titlebar {
    position: sticky;
    top: 0;
    z-index: 25;
    height: 48px;
    padding: 0 14px;
  }

  .titlebar h1,
  .app-titlebar h1 {
    width: 100%;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 20px;
  }

  .wizard-content {
    padding: 24px 22px 18px;
  }

  .login-content {
    padding: 24px 22px 18px;
  }

  .login-panel-wrap {
    width: 100%;
  }

  .login-choice-panel {
    padding: 22px;
  }

  .login-inline-form {
    max-width: none;
  }

  .choice-content {
    padding-left: 42px;
    font-size: 18px;
  }

  .soft-panel {
    padding: 22px !important;
  }

  .option-row {
    align-items: flex-start;
    gap: 12px;
  }

  .option-action {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .option-action .option-button {
    grid-column: 2;
    margin-left: 0;
    justify-self: start;
  }

  .account-form {
    padding-left: 42px !important;
  }

  .wizard-footer {
    min-height: auto;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 22px;
    position: sticky;
    bottom: 0;
    z-index: 5;
  }

  .wizard-footer .flex-1 {
    display: none;
  }

  .wizard-footer .desktop-button,
  .wizard-footer form {
    flex: 1 1 130px;
  }

  .wizard-footer form .desktop-button {
    width: 100%;
  }

  .menubar {
    height: 42px;
    gap: 18px;
    padding: 0 12px;
    overflow-x: auto;
  }

  .tabs {
    display: none;
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    min-height: calc(72px + env(safe-area-inset-bottom));
    padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
    border-top: 1px solid #c7c7c7;
    background: rgba(248, 248, 248, 0.96);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.10);
    backdrop-filter: blur(16px);
  }

  .bottom-nav-item {
    display: flex;
    min-height: 58px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    border: 1px solid transparent;
    border-radius: 14px;
    color: #3e3e3e;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
  }

  .bottom-nav-item.active {
    border-color: #f2ad72;
    background: linear-gradient(#fff6ed, #ffe1bd);
    color: #7a2b00;
    box-shadow: inset 0 0 0 1px rgba(255, 122, 0, 0.18);
  }

  .bottom-nav-item.active .nav-symbol {
    color: #ff6a00;
  }

  .app-content {
    padding: 18px 18px 28px;
  }

  .has-bottom-nav {
    padding-bottom: calc(86px + env(safe-area-inset-bottom));
  }

  .bottom-nav-spacer {
    display: block;
    height: calc(132px + env(safe-area-inset-bottom));
  }

  .statusbar {
    display: none;
  }

  .has-bottom-nav.wizard-window {
    padding-bottom: calc(86px + env(safe-area-inset-bottom));
  }

  .has-bottom-nav .wizard-footer {
    margin-bottom: 12px;
    position: static;
  }

  .search-input {
    height: 42px;
    font-size: 19px !important;
  }

  .classic-table {
    overflow-x: hidden;
  }

  .expense-grid {
    grid-template-columns: 58px minmax(0, 1fr) 124px 104px 92px;
    min-width: 0;
    width: 100%;
  }

  .budget-grid {
    grid-template-columns: minmax(0, 1fr) minmax(88px, 0.58fr) minmax(88px, 0.58fr) 34px;
    min-width: 0;
    width: 100%;
  }

  #history,
  #transactions,
  #summary,
  #budget {
    scroll-margin-top: 58px;
    scroll-margin-bottom: calc(110px + env(safe-area-inset-bottom));
  }

  .icon-button {
    width: 46px;
    min-width: 46px;
    padding: 0;
  }

  .qr-card {
    display: none;
  }

  .status-tile {
    min-height: 56px;
  }

  .status-tile strong {
    font-size: 22px;
  }

  .seed-box {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 20px;
  }

  .coin-icon {
    display: none;
  }

  .desktop-button,
  .option-row,
  .menubar,
  .statusbar {
    font-size: 18px;
  }

  .desktop-input {
    width: 100%;
    font-size: 18px;
  }
}

@media (max-width: 520px) {
  .titlebar h1,
  .app-titlebar h1 {
    font-size: 18px;
  }

  .mobile-poly {
    height: 118px;
  }

  .mobile-brand-mark {
    width: 148px;
  }

  .wizard-content {
    padding: 20px 16px;
  }

  .login-content {
    padding: 20px 16px;
  }

  .login-choice-panel {
    padding: 18px;
  }

  .line-option {
    min-height: 48px;
  }

  .soft-panel {
    padding: 18px !important;
  }

  .option-row {
    font-size: 18px;
  }

  .option-row strong {
    display: block;
    line-height: 1.2;
  }

  .option-row p,
  .restore-note p {
    font-size: 15px;
  }

  .account-form {
    padding-left: 0 !important;
  }

  .login-inline-form {
    padding-left: 0;
  }

  .choice-content {
    padding-left: 0;
  }

  .brand-note {
    font-size: 18px !important;
  }

  .desktop-button {
    min-height: 40px;
    padding: 5px 18px;
    font-size: 18px;
  }

  .wizard-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .wizard-footer .desktop-button,
  .wizard-footer form {
    width: 100%;
    min-width: 0;
  }

  .wizard-footer form {
    grid-column: 2;
  }

  .wizard-footer a.opacity-50 {
    display: none;
  }

  .radio-dot {
    width: 26px;
    height: 26px;
  }

  .radio-dot.checked {
    border-width: 7px;
  }

  .menubar {
    display: none;
  }

  .bottom-nav {
    min-height: calc(68px + env(safe-area-inset-bottom));
    padding-left: 6px;
    padding-right: 6px;
  }

  .bottom-nav-spacer {
    height: calc(140px + env(safe-area-inset-bottom));
  }

  .bottom-nav-item {
    min-height: 54px;
    border-radius: 12px;
    font-size: 11px;
  }

  .nav-symbol {
    font-size: 23px;
  }

  .green-led {
    width: 18px;
    height: 18px;
  }

  #history.classic-table,
  #transactions.classic-table {
    display: grid;
    gap: 8px;
    min-height: auto;
    border: 0;
    background: transparent;
  }

  #history > .expense-grid:not(.table-row),
  #transactions > .expense-grid:not(.table-row) {
    display: none;
  }

  #history .table-row.expense-grid,
  #transactions .table-row.expense-grid {
    grid-template-columns: 42px minmax(0, 1fr) auto;
    grid-template-areas:
      "id title amount"
      "id category date";
    align-items: center;
    min-width: 0;
    border: 1px solid #cfcfcf;
    border-left: 4px solid #ff7b00;
    background: #fff;
    color: #111;
  }

  #history .table-row:hover,
  #history .table-row:nth-child(6n),
  #transactions .table-row:hover,
  #transactions .table-row:nth-child(6n) {
    background: #fff;
    color: #111;
  }

  #history .table-row > div:nth-child(1),
  #transactions .table-row > div:nth-child(1) {
    grid-area: id;
    align-self: stretch;
    display: flex;
    align-items: center;
    border-right: 1px solid #ddd;
    color: #7a2b00;
  }

  #history .table-row > div:nth-child(2),
  #transactions .table-row > div:nth-child(2) {
    grid-area: title;
    font-family: Arial, Helvetica, sans-serif;
    font-weight: 700;
  }

  #history .table-row > div:nth-child(3),
  #transactions .table-row > div:nth-child(3) {
    grid-area: category;
    color: #555;
  }

  #history .table-row > div:nth-child(4),
  #transactions .table-row > div:nth-child(4) {
    grid-area: amount;
    justify-self: end;
    font-weight: 700;
  }

  #history .table-row > div:nth-child(5),
  #transactions .table-row > div:nth-child(5) {
    grid-area: date;
    justify-self: end;
    color: #555;
  }

  #history .table-row > div,
  #history .table-row > form,
  #transactions .table-row > div,
  #transactions .table-row > form {
    min-width: 0;
    border-right: 0;
  }

  .budget-grid {
    grid-template-columns: minmax(0, 1fr) minmax(64px, 0.52fr) minmax(64px, 0.52fr) 26px;
    min-width: 0;
    width: 100%;
  }

  .classic-table .grid {
    font-size: 14px !important;
  }

  .classic-table .grid > div,
  .classic-table .grid > form {
    min-height: 36px;
    padding: 6px 5px;
    overflow: hidden;
  }

  #budget .classic-table {
    width: 100%;
  }

  #budget .progress {
    width: 100%;
  }

  .transaction-side {
    display: grid;
    gap: 14px;
  }

  .transaction-request {
    display: none;
  }

  .detail-shell {
    max-width: none;
  }

  .detail-list {
    font-size: 18px;
  }

  .detail-list div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .detail-amount {
    font-size: 32px;
  }

  .delete-link {
    opacity: 1 !important;
  }
}
