*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: auto;
  overflow: auto;
  font-family: sans-serif;
  font-size: 14px;
  background: #fff;
  color: #111;
}

#root {
  width: 100%;
  height: auto;
  position: relative;
  display: flex;
  flex-direction: column;
}

.open-in-app-banner {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 50;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  font-size: 16px;
  font-weight: 600;
  background: #9b27af;
  color: #fff;
  text-decoration: none;
}

.panel {
  display: none;
  flex-direction: column;
  width: 100%;
  height: auto;
  overflow: visible;
}

.panel[active="true"] {
  display: flex;
}

.panel-content {
  flex: 1;
  overflow-y: visible;
  padding: 8px;
  padding-bottom: 38px; /* KaiOS: room for 30px softkey bar */
}

.hint {
  font-size: 12px;
  color: #666;
  margin: 8px 4px;
  line-height: 1.4;
}

.welcome-heading {
  font-size: 15px;
  font-weight: 600;
  color: #6a0080;
  margin: 0 4px 12px;
  text-align: center;
}

.hint-link {
  display: block;
  background: none;
  border: none;
  padding: 2px 4px;
  margin: 4px 4px 0;
  font-size: 12px;
  color: #9b27af;
  text-decoration: underline;
  cursor: pointer;
  text-align: left;
}

.hint-link[nav-selected="true"] {
  background: #9b27af;
  color: #fff;
  text-decoration: none;
  border-radius: 3px;
}

body.dark .welcome-heading {
  color: #c77ddb;
}

body.dark .hint-link {
  color: #c77ddb;
}

body.dark .hint-link[nav-selected="true"] {
  background: #9b27af;
  color: #fff;
}

.status-toast {
  position: fixed;
  bottom: 34px; /* KaiOS: above softkey bar */
  left: 0;
  right: 0;
  padding: 4px 8px;
  font-size: 12px;
  text-align: center;
  z-index: 10;
  display: none;
  pointer-events: none;
}

.status-toast[visible="true"] {
  display: block;
}

.status-toast.info {
  background: rgba(106, 0, 128, 0.85);
  color: #fff;
}

.status-toast.error {
  background: rgba(180, 0, 0, 0.85);
  color: #fff;
}

/* === All screens above KaiOS (241px+) ========================= */
@media (min-width: 241px) {
  html, body {
    height: 100%;
    overflow: hidden;
  }

  #root {
    height: 100%;
  }

  .panel {
    height: 100%;
    overflow: hidden;
  }

  .panel-content {
    overflow-y: auto;
    padding-bottom: 8px;
  }

  .status-toast {
    bottom: 8px;
  }

  /* List panels: edge-to-edge, no outer gutter */
  #panel-lists .panel-content,
  #panel-list .panel-content,
  #panel-options .panel-content {
    padding: 0;
  }

  /* Input panels: generous breathing room */
  #panel-email .panel-content,
  #panel-otp .panel-content,
  #panel-new-list .panel-content,
  #panel-new-item .panel-content {
    padding: 20px 16px;
  }

  /* Header side padding matches list item inset */
  .header {
    padding: 6px 16px;
  }
}

/* === Desktop polish (≥768px) — roomier chrome, contained content === */
@media (min-width: 768px) {
  .header {
    padding: 10px 24px;
    min-height: 52px;
  }

  .header h1 {
    font-size: 18px;
  }

  #panel-lists .panel-content,
  #panel-list .panel-content,
  #panel-options .panel-content {
    padding: 0 24px;
  }

  #panel-email .panel-content,
  #panel-otp .panel-content,
  #panel-new-list .panel-content,
  #panel-new-item .panel-content {
    padding: 32px 24px;
  }

  /* Split view: lists sidebar on the left, list contents on the right */
  body.authenticated #root {
    flex-direction: row;
  }

  body.authenticated #panel-lists {
    display: flex !important;
    width: 320px;
    flex-shrink: 0;
    border-right: 1px solid #eee;
  }

  body.authenticated #panel-list {
    display: flex !important;
    flex: 1;
  }

  body.dark.authenticated #panel-lists {
    border-right-color: #2e2e30;
  }

  /* Detail pane placeholder shown until a list is opened */
  body.authenticated #panel-list[active="false"] > .panel-content {
    display: none;
  }

  body.authenticated #panel-list[active="false"] #list-pane-placeholder {
    display: flex;
  }

  body.authenticated #panel-list[active="false"] #list-title,
  body.authenticated #panel-list[active="false"] #btn-list-back,
  body.authenticated #panel-list[active="false"] #btn-list-share,
  body.authenticated #panel-list[active="false"] #btn-list-add {
    display: none;
  }

  /* Overlay panels (new list/item, options) stack on top of the split view */
  body.authenticated #panel-new-list,
  body.authenticated #panel-new-item,
  body.authenticated #panel-options {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 5;
    background: #fff;
  }

  body.dark.authenticated #panel-new-list,
  body.dark.authenticated #panel-new-item,
  body.dark.authenticated #panel-options {
    background: #1c1c1e;
  }
}

#list-pane-placeholder {
  display: none;
  flex: 1;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

/* === Text selection disabled on touch screens only (241px – 767px) === */
@media (min-width: 241px) and (max-width: 767px) {
  * {
    -webkit-user-select: none;
    user-select: none;
  }

  input, textarea {
    -webkit-user-select: text;
    user-select: text;
  }
}

/* === Dark mode === */
body.dark {
  background: #1c1c1e;
  color: #e5e7eb;
}

body.dark #softkey {
  background: #252528;
  border-top-color: #3a3a40;
}

body.dark #sk-left,
body.dark #sk-right {
  color: #c77ddb;
}

body.dark #sk-center {
  color: #e5e7eb;
}

body.dark .list-row {
  border-bottom-color: #2e2e30;
}

body.dark .list-row.crossed {
  color: #5a5a62;
}

body.dark .new-list-row,
body.dark .sweep-row {
  border-top-color: #2e2e30;
  color: #c77ddb;
}

body.dark .options-row {
  border-bottom-color: #2e2e30;
}

body.dark .options-value {
  color: #8b8b93;
}

body.dark .hint {
  color: #8b8b93;
}

body.dark .input-wrap input {
  color: #e5e7eb;
  border-bottom-color: #4a4a52;
}

body.dark .input-wrap label {
  color: #8b8b93;
}

#ad-container {
  width: 100%;
  overflow: hidden;
  flex-shrink: 0;
}

.nav-selectable-ad {
  width: 240px;
  max-width: 240px;
  min-width: 240px;
  height: 60px;
  max-height: 60px;
  min-height: 60px;
  overflow: hidden;
  border: 3px solid transparent;
}

.nav-selectable-ad[nav-selected="true"] {
  border-color: #9b27af;
}
