:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  background: #f6f4ef;
  color: #1f2520;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  background: #f6f4ef;
}

body.is-viewer-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.app {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-form {
  width: min(100%, 380px);
  display: grid;
  gap: 12px;
}

.login-form label {
  color: #596058;
  font-weight: 700;
}

.login-form button {
  width: 100%;
}

.login-error {
  min-height: 1.25rem;
  margin: 0;
  color: #8a2d1f;
}

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

h1 {
  margin: 0;
  font-size: 2.2rem;
  line-height: 1;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status {
  flex: 0 0 auto;
  min-height: 32px;
  margin-top: 4px;
  padding: 6px 10px;
  border: 1px solid #d2d0c7;
  border-radius: 999px;
  background: #fffdf8;
  color: #596058;
  font-size: 0.82rem;
  font-weight: 700;
}

.logout-button {
  min-height: 32px;
  margin-top: 4px;
  border: 1px solid #d2d0c7;
  padding: 0 10px;
  background: #fffdf8;
  color: #596058;
  font-size: 0.82rem;
  font-weight: 700;
}

.status.is-online {
  border-color: #a9c8a8;
  color: #255d2c;
}

.status.is-offline {
  border-color: #d6ada2;
  color: #8a2d1f;
}

.add-form {
  display: grid;
  grid-template-columns: 1fr auto 52px;
  gap: 10px;
  margin-bottom: 18px;
}

input {
  min-width: 0;
  height: 48px;
  border: 1px solid #c9c5ba;
  border-radius: 8px;
  padding: 0 14px;
  background: #fffdf8;
  color: #1f2520;
}

input:focus {
  border-color: #56835b;
  outline: 3px solid rgba(86, 131, 91, 0.2);
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: #2f6f3b;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

#add-button {
  width: 52px;
  padding: 0;
  font-size: 1.8rem;
  line-height: 1;
}

.image-select-button {
  width: 64px;
  border: 1px solid #b9cbbb;
  padding: 0 10px;
  background: #fffdf8;
  color: #255d2c;
  font-size: 0.95rem;
}

.image-select-button.has-image {
  border-color: #8fb48f;
  background: #dcebdc;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.items {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.items li {
  min-height: 48px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 48px;
  align-items: stretch;
  border: 1px solid #dfdbcf;
  border-radius: 8px;
  background: #fffdf8;
  overflow: hidden;
}

.items li.has-image {
  grid-template-columns: 42px minmax(0, 1fr) 58px 48px;
}

.items.is-reordering li {
  transition: border-color 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

.items li.is-dragging {
  border-color: #8fb48f;
  box-shadow: 0 8px 22px rgba(31, 37, 32, 0.16);
  opacity: 0.78;
}

.drag-handle {
  position: relative;
  width: 42px;
  min-height: 48px;
  border-right: 1px solid #dfdbcf;
  border-radius: 0;
  padding: 0;
  background: transparent;
  cursor: grab;
  touch-action: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 14px;
  transform: translate(-50%, -50%);
  background: repeating-linear-gradient(
    to bottom,
    #596058 0,
    #596058 2px,
    transparent 2px,
    transparent 6px
  );
}

.item-edit {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  background: transparent;
  color: #1f2520;
}

.item-edit:focus {
  outline: 3px solid rgba(86, 131, 91, 0.2);
}

.item-image-button,
.remove-button {
  min-height: 48px;
  border-left: 1px solid #dfdbcf;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

.item-image-button {
  width: 58px;
  color: #255d2c;
  font-size: 0.9rem;
}

.remove-button {
  width: 48px;
  color: #8a2d1f;
  font-size: 1.7rem;
}

.empty {
  margin: 30px 0;
  color: #696f67;
  text-align: center;
}

.reset-button {
  width: 100%;
  margin-top: 26px;
  border: 1px solid #cfc9bb;
  background: transparent;
  color: #744036;
}

.install-button {
  width: 100%;
  margin-top: 10px;
  border: 1px solid #b9cbbb;
  background: #fffdf8;
  color: #255d2c;
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(31, 37, 32, 0.94);
}

.image-viewer-close {
  justify-self: end;
  min-height: 44px;
  border: 1px solid rgba(255, 253, 248, 0.55);
  background: #fffdf8;
  color: #1f2520;
}

.image-viewer img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

.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-width: 420px) {
  .app {
    padding-top: 18px;
  }

  .top {
    align-items: flex-start;
    gap: 10px;
  }

  .top-actions {
    align-items: flex-end;
    flex-direction: column;
  }

  h1 {
    font-size: 1.9rem;
  }

  .status {
    font-size: 0.75rem;
  }
}
