:root {
  --page: #ffffff;
  --panel: #ffffff;
  --surface: #ffffff;
  --ink: #050505;
  --muted: #7c7c7c;
  --line: #0a0a0a;
  --veil: rgba(255, 255, 255, 0.9);
  --theme-color: #ffffff;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--page);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  display: grid;
  place-items: center;
  padding: 0;
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  font: inherit;
}

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

.shell {
  width: min(100vw, 390px);
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--panel);
}

.screen {
  position: relative;
  display: grid;
  grid-template-rows: 108px minmax(0, 1fr) 132px;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--panel);
  border-radius: 0;
}

.screen[hidden] {
  display: none;
}

.topbar {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  padding: 0;
  color: var(--muted);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

.logo-button {
  align-self: start;
  grid-column: 2;
  display: grid;
  place-items: center;
  width: 90px;
  height: 90px;
  padding: 12px 0 0;
  background: var(--ink);
  -webkit-mask: url("/favicon.svg") center / 78px 78px no-repeat;
  mask: url("/favicon.svg") center / 78px 78px no-repeat;
}

.logo-button img {
  display: block;
  width: 78px;
  height: 78px;
  border-radius: 18px;
  opacity: 0;
}

.search-clear {
  grid-column: 3;
  justify-self: end;
  align-self: start;
  display: grid;
  place-items: center;
  width: 72px;
  height: 64px;
  margin-top: 13px;
  padding: 0 14px 0 0;
  color: var(--ink);
  font-size: 52px;
  font-weight: 500;
  line-height: 1;
}

.search-clear[hidden] {
  display: none;
}

.list-frame {
  position: relative;
  min-height: 0;
  margin: 0 4px;
  overflow: hidden;
}

.onboarding {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 24px;
  color: var(--muted);
  font-size: 21px;
  font-weight: 400;
  line-height: 1.85;
  text-align: center;
  opacity: 0.7;
  pointer-events: none;
}

.onboarding[hidden] {
  display: none;
}

.onboarding-line {
  display: block;
  white-space: nowrap;
}

.onboarding-mark {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  top: -0.08em;
  margin: 0 0.14em;
}

.onboarding-plus {
  width: 1.24em;
  height: 1.24em;
  border: 0.09em solid currentColor;
  border-radius: 50%;
}

.onboarding-plus::before,
.onboarding-plus::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  background: currentColor;
  border-radius: 0.05em;
  transform: translate(-50%, -50%);
}

.onboarding-plus::before {
  width: 0.6em;
  height: 0.14em;
}

.onboarding-plus::after {
  width: 0.14em;
  height: 0.6em;
}

.onboarding-logo {
  width: 1.9em;
  height: 1.48em;
  background-color: currentColor;
  -webkit-mask: url("/favicon.svg") center / contain no-repeat;
  mask: url("/favicon.svg") center / contain no-repeat;
}

.counter-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  overflow-y: auto;
  padding: 0 0 28px;
  overscroll-behavior: contain;
  scrollbar-width: none;
  touch-action: pan-y;
}

.counter-list::-webkit-scrollbar {
  display: none;
}

.counter-card {
  display: block;
  width: 100%;
  height: auto;
  min-height: 79px;
  padding: 10px 22px;
  border: 4px solid var(--line);
  border-radius: 40px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 24px;
  font-weight: 800;
  text-align: left;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.counter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 51px;
}

.counter-name {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  padding-block: 8px;
  overflow: hidden;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.42;
}

.days-value {
  min-width: 72px;
  text-align: right;
}

.ymd-value {
  display: grid;
  grid-template-columns: repeat(3, 28px);
  grid-template-rows: auto auto;
  justify-items: center;
  align-items: center;
  column-gap: 4px;
  font-size: 23px;
  line-height: 1.05;
  text-align: center;
}

.ymd-value .unit {
  font-size: 22px;
}

.bottom-action {
  display: grid;
  place-items: end center;
  padding-bottom: 42px;
}

.round-plus {
  position: relative;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border: 4px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  /* The "+" is drawn as two geometric bars (below) rather than a font glyph,
     so it sits at the exact center of the circle on every browser, screen and
     system font — text-glyph metrics vary by platform and drift vertically. */
  font-size: 0;
}

.round-plus::before,
.round-plus::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 38px;
  height: 9px;
  border-radius: 2px;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.round-plus::after {
  width: 9px;
  height: 38px;
}

.add-screen {
  transform: translateX(0);
  touch-action: pan-x;
}

.add-screen .topbar {
  grid-template-columns: 1fr 1fr;
}

.delete-button {
  justify-self: start;
  min-width: 156px;
  min-height: 72px;
  padding: 20px 0 0 16px;
  color: var(--ink);
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  text-align: left;
}

.editor {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto 124px minmax(0, 1fr) 132px;
  justify-items: center;
  min-height: 0;
  grid-row: 2 / 4;
}

.what-field,
.when-field,
.date-field {
  width: min(316px, 90%);
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--muted);
  font-size: 46px;
  font-weight: 800;
  text-align: center;
}

.what-field {
  grid-row: 2;
  align-self: end;
  justify-self: center;
  min-height: 72px;
  max-height: 216px;
  padding: 10px 0;
  font-size: 32px;
  line-height: 38px;
  overflow-y: auto;
  resize: none;
  scrollbar-width: none;
}

.what-field::-webkit-scrollbar {
  display: none;
}

.what-field::placeholder {
  color: var(--muted);
  opacity: 1;
}

.what-field:not(:placeholder-shown),
.what-field:focus,
.when-field.has-date {
  color: var(--ink);
}

.date-field {
  position: relative;
  grid-row: 3;
  align-self: start;
  justify-self: center;
  height: 72px;
  margin-top: 38px;
  line-height: 72px;
}

.when-field {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  text-align: center;
  line-height: 72px;
  cursor: pointer;
  pointer-events: none;
  font-size: 32px;
  white-space: nowrap;
}

.date-native {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  appearance: none;
  -webkit-appearance: none;
}

.date-native::-webkit-date-and-time-value {
  color: transparent;
}

.date-native::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.save-button {
  grid-row: 5;
  align-self: end;
  margin-bottom: 42px;
}

.archive-action {
  grid-column: 2;
  justify-self: end;
  align-self: start;
  min-height: 72px;
  padding: 20px 16px 0 0;
  color: var(--ink);
  font-size: 32px;
  font-weight: 800;
}

.add-screen .delete-button,
.add-screen .archive-action,
.archive-detail-topbar .delete-button,
.archive-detail-topbar .reactivate-action {
  display: flex;
  align-items: center;
  height: 72px;
  padding-top: 0;
  line-height: 1;
}

.add-screen .delete-button,
.archive-detail-topbar .delete-button {
  justify-content: flex-start;
}

.add-screen .archive-action,
.archive-detail-topbar .reactivate-action {
  justify-content: flex-end;
}

.add-screen .delete-button[hidden],
.add-screen .archive-action[hidden],
.archive-detail-topbar .delete-button[hidden],
.archive-detail-topbar .reactivate-action[hidden] {
  display: none;
}

.archive-screen {
  display: block;
}

.archive-detail-topbar {
  position: absolute;
  inset: 0 0 auto;
  z-index: 1;
  height: 108px;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.archive-editor {
  display: grid;
  grid-template-rows: 108px minmax(0, 1fr) 132px;
  justify-items: center;
  width: 100%;
  height: 100%;
}

.archive-fields {
  grid-row: 2;
  align-self: center;
  display: grid;
  grid-template-rows: auto 24px auto 44px auto;
  justify-items: center;
  width: 100%;
}

.archive-item-title {
  grid-row: 1;
  width: min(316px, 90%);
  min-height: 58px;
  max-height: 156px;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 32px;
  font-weight: 800;
  line-height: 1.13;
  text-align: center;
  overflow-wrap: anywhere;
  resize: none;
  scrollbar-width: none;
}

.archive-item-title::-webkit-scrollbar {
  display: none;
}

.archive-date-field {
  position: relative;
  width: min(340px, 92%);
  height: 72px;
  color: var(--ink);
  font-size: 32px;
  font-weight: 800;
  line-height: 72px;
  text-align: center;
  white-space: nowrap;
}

.archive-date-field:first-of-type {
  grid-row: 3;
}

.archive-date-field:nth-of-type(2) {
  grid-row: 5;
}

.archive-date-field span {
  display: block;
}

.archive-date-separator {
  grid-row: 4;
  align-self: center;
  color: var(--ink);
  font-size: 38px;
  font-weight: 800;
}

.archive-confirm,
.reactivate-action {
  color: var(--ink);
  font-size: 32px;
  font-weight: 800;
}

.archive-confirm {
  grid-row: 3;
  align-self: end;
  margin-bottom: 42px;
}

.reactivate-action {
  grid-column: 2;
  justify-self: end;
  align-self: start;
  min-height: 72px;
  padding: 20px 16px 0 0;
  font-size: 32px;
}

.reactivate-action[hidden] {
  display: none;
}

.archived-screen {
  grid-template-rows: 108px minmax(0, 1fr);
}

.archived-topbar {
  position: relative;
  display: grid;
  place-items: center;
}

.archived-topbar h2 {
  margin: 0;
  color: var(--ink);
  font-size: 32px;
  font-weight: 800;
}

.archived-close {
  position: absolute;
  top: 50%;
  right: 0;
  display: grid;
  place-items: center;
  width: 72px;
  height: 64px;
  padding-right: 14px;
  color: var(--ink);
  font-size: 52px;
  line-height: 1;
  transform: translateY(-50%);
}

.archived-list-frame {
  margin-bottom: 24px;
}

.archived-card .counter-row {
  grid-template-rows: auto auto;
  align-items: center;
  min-height: 55px;
}

.archived-card {
  padding-top: 12px;
  padding-bottom: 17px;
}

.archived-card .counter-name {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-block: 5px;
}

.archive-range {
  grid-column: 1 / -1;
  grid-row: 2;
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  text-align: left;
  white-space: nowrap;
}

.wd-value {
  display: grid;
  grid-template-columns: repeat(2, 28px);
  grid-template-rows: auto auto;
  justify-items: center;
  align-items: center;
  column-gap: 4px;
  font-size: 23px;
  line-height: 1.05;
}

.wd-value .unit {
  font-size: 22px;
}

.save-button.is-editing {
  width: auto;
  min-width: 118px;
  height: 64px;
  border: 0;
  border-radius: 0;
  font-size: 32px;
  line-height: 1;
}

.save-button.is-editing::before,
.save-button.is-editing::after {
  content: none;
}

.confirm-layer,
.data-layer,
.search-layer,
.theme-layer,
.export-layer,
.passphrase-layer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--veil);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.confirm-layer[hidden],
.data-layer[hidden],
.search-layer[hidden],
.theme-layer[hidden],
.export-layer[hidden],
.passphrase-layer[hidden] {
  display: none;
}

.passphrase-title {
  margin: 0 0 4px;
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
}

.passphrase-form {
  display: grid;
  gap: 12px;
}

.passphrase-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  align-items: center;
  gap: 6px;
  min-height: 76px;
  padding: 12px 14px 12px 22px;
  border: 4px solid var(--line);
  border-radius: 38px;
  background: var(--surface);
}

.passphrase-input {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 25px;
  font-weight: 800;
  line-height: 1.2;
  -webkit-appearance: none;
  appearance: none;
}

.passphrase-input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.passphrase-eye {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  color: var(--ink);
}

.passphrase-eye svg {
  display: block;
  width: 32px;
  height: auto;
}

.passphrase-note {
  margin: 0;
  padding: 0 8px;
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.3;
}

.passphrase-note[hidden] {
  display: none;
}

.confirm-box,
.data-box {
  display: grid;
  gap: 28px;
  width: min(100%, 298px);
  padding: 34px 24px 26px;
  border: 4px solid var(--line);
  border-radius: 32px;
  background: var(--panel);
  color: var(--ink);
  text-align: center;
}

.data-box {
  gap: 12px;
  padding: 24px;
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  scrollbar-width: none;
}

.data-box::-webkit-scrollbar {
  display: none;
}

.confirm-box h2 {
  margin: 0;
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
}

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

.confirm-choice {
  min-height: 60px;
  border: 4px solid var(--line);
  border-radius: 30px;
  background: var(--surface);
  color: var(--ink);
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

.data-choice {
  display: grid;
  place-items: center;
  min-height: 62px;
  padding: 12px 18px;
  border: 4px solid var(--line);
  border-radius: 31px;
  background: var(--surface);
  color: var(--ink);
  font-size: 30px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

.export-box .data-choice {
  min-height: 76px;
  padding-inline: 22px;
}

.color-choice {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 12px;
  align-items: center;
  min-height: 72px;
  padding: 10px 14px 10px 22px;
  border: 4px solid var(--line);
  border-radius: 36px;
  color: var(--ink);
  font-size: 25px;
  font-weight: 800;
  text-align: left;
}

.color-choice input[type="color"] {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 3px solid var(--line);
  border-radius: 50%;
  overflow: hidden;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.color-choice input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-choice input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 50%;
}

.color-choice input[type="color"]::-moz-color-swatch {
  border: 0;
  border-radius: 50%;
}

.search-field {
  width: 100%;
  min-height: 76px;
  padding: 12px 18px;
  border: 4px solid var(--line);
  border-radius: 38px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
  font-size: 30px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  -webkit-appearance: none;
  appearance: none;
}

.flower-link {
  display: grid;
  place-items: center;
  min-height: 62px;
  margin-top: 4px;
  color: var(--ink);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.flower-link svg {
  display: block;
  width: 54px;
  height: 54px;
  overflow: visible;
  fill: currentColor;
}

.footer-update {
  min-height: 44px;
  margin-top: 4px;
  padding: 12px 18px 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

.footer-update.is-ready {
  color: var(--ink);
}

.footer-update:disabled {
  cursor: wait;
  opacity: 0.6;
}

.update-notice {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100% - 32px);
  padding: 10px 10px 10px 20px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--page);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
}

.update-notice[hidden] {
  display: none;
}

.update-copy {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  font-size: 19px;
  font-weight: 800;
}

.update-mark {
  display: inline-flex;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
}

.update-mark svg {
  display: block;
  width: 30px;
  height: 30px;
  overflow: visible;
  fill: currentColor;
}

.update-action {
  flex: none;
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--page);
  color: var(--ink);
  font-size: 19px;
  font-weight: 800;
  white-space: nowrap;
}

.update-action:disabled {
  cursor: wait;
  opacity: 0.7;
}

@media (prefers-reduced-motion: no-preference) {
  .update-notice {
    animation: update-rise 220ms ease-out;
  }

  @keyframes update-rise {
    from {
      transform: translate(-50%, 12px);
      opacity: 0;
    }
  }
}

.search-field::placeholder {
  color: var(--muted);
  opacity: 1;
}

.search-field::-webkit-search-cancel-button {
  display: none;
}

:focus-visible {
  outline: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-height: 640px) {
  .counter-card {
    min-height: 72px;
  }

  .counter-list {
    gap: 8px;
  }

  .editor {
    grid-template-rows: minmax(0, 1fr) auto 104px minmax(0, 1fr) 112px;
  }

  .save-button,
  .archive-confirm {
    margin-bottom: 28px;
  }
}

@media (min-width: 700px) {
  .shell {
    width: min(100vw, 390px);
  }
}
