:root {
  color-scheme: light;
  --paper: #f7f3e9;
  --white: #ffffff;
  --ink: #1c2333;
  --muted: #5f6880;
  --line: #e2dccd;
  --cobalt: #2340c7;
  --cobalt-soft: #e8ecff;
  --coral: #ec7653;
  --green: #1c8a5a;
  --amber: #b7791f;
  --amber-soft: #fff4db;
  --red: #c53030;
  --red-soft: #fdecec;
  --radius: 14px;
  --shadow: 0 8px 24px rgb(28 35 51 / 10%);
  --shadow-soft: 0 3px 12px rgb(28 35 51 / 8%);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  font-family: system-ui, "Segoe UI", Roboto, "Noto Sans Devanagari", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
  color: var(--ink);
  background: var(--paper);
  accent-color: var(--cobalt);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select {
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: .52;
}

img {
  max-width: 100%;
}

a {
  color: var(--cobalt);
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--cobalt);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--cobalt-soft);
}

::selection {
  color: var(--ink);
  background: #cfd7ff;
}

/* Shared controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--white);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: normal;
  transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.btn:not(:disabled):hover {
  border-color: #bfc6df;
  background: #fafbff;
}

.btn:not(:disabled):active {
  transform: translateY(1px);
}

.btn--icon {
  width: 44px;
  min-width: 44px;
  padding: 0;
}

/* The label stays available as aria-label; only the icon is shown. */
.btn--icon > span {
  display: none;
}

.btn--icon svg,
.menu__item svg,
.map-node__status svg,
.editor__photo-empty svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.btn--ghost {
  background: transparent;
}

.btn--primary {
  border-color: var(--cobalt);
  color: #fff;
  background: var(--cobalt);
}

.btn--primary:not(:disabled):hover {
  border-color: #1c35aa;
  background: #1c35aa;
}

.btn--danger {
  border-color: var(--red);
  color: #fff;
  background: var(--red);
}

.btn--danger:not(:disabled):hover {
  border-color: #a72828;
  background: #a72828;
}

.btn--wide {
  width: 100%;
}

.status {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.status--ok {
  color: var(--green);
}

.status--pending {
  color: var(--amber);
}

.status--error {
  color: var(--red);
}

.notice {
  margin: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: #fffdf8;
  font-size: 14px;
}

.notice--warn {
  border-color: #efd598;
  color: #73510f;
  background: var(--amber-soft);
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field__label {
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
}

.field__error {
  min-height: 1.3em;
  margin: 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cfc7b7;
  border-radius: 10px;
  color: var(--ink);
  background: var(--white);
  padding: 9px 11px;
}

input::placeholder {
  color: #788096;
  opacity: 1;
}

input[type="color"] {
  padding: 4px;
  cursor: pointer;
}

input[type="file"] {
  min-height: auto;
}

select {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  color: var(--ink);
  line-height: 1.22;
}

h1,
h2 {
  margin: 0;
}

h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

small {
  font-size: 13px;
}

/* Authentication */
.auth {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  overflow: auto;
  padding: max(24px, var(--safe-top)) max(18px, var(--safe-right)) max(24px, var(--safe-bottom)) max(18px, var(--safe-left));
  background:
    radial-gradient(circle at 1px 1px, rgb(97 104 128 / 9%) 1px, transparent 1.1px) 0 0 / 20px 20px,
    var(--paper);
}

.auth__card {
  width: min(100%, 430px);
  padding: clamp(24px, 5vw, 40px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

.auth__card h1 {
  margin-bottom: 22px;
  font-size: clamp(25px, 4vw, 32px);
}

.auth__card form,
.auth__card > div {
  display: grid;
  gap: 16px;
}

.auth__password {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 6px;
  align-items: center;
}

.auth__password input {
  min-width: 0;
}

/* App shell */
.app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--paper);
}

.topbar {
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(260px, 380px) minmax(max-content, 1fr);
  align-items: center;
  gap: 14px;
  min-height: calc(64px + var(--safe-top));
  padding: calc(10px + var(--safe-top)) max(16px, var(--safe-right)) 10px max(16px, var(--safe-left));
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 96%);
  box-shadow: 0 2px 10px rgb(28 35 51 / 5%);
}

.topbar__brand,
.topbar__group {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

.topbar__brand {
  font-weight: 800;
  white-space: nowrap;
}

.topbar__brand img {
  width: 35px;
  height: 35px;
  object-fit: contain;
}

.topbar__group:nth-child(2) {
  min-width: 0;
}

.topbar__group:last-child {
  justify-content: flex-end;
}

.help-steps {
  display: grid;
  gap: 12px;
  margin: 0;
  padding-left: 24px;
  line-height: 1.45;
}

.publish-note {
  max-width: 190px;
  color: var(--green);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.25;
  text-align: right;
}

.publish-note--pending {
  color: var(--amber);
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f2efe8;
}

.segmented__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 40px;
  padding: 7px 10px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}

.segmented__btn svg {
  width: 16px;
  height: 16px;
}

.segmented__btn.is-selected {
  color: var(--cobalt);
  background: var(--white);
  box-shadow: 0 1px 4px rgb(28 35 51 / 12%);
}

.search {
  position: relative;
  display: flex;
  flex: 1 1 180px;
  min-width: 0;
  max-width: 380px;
  align-items: center;
}

.search > svg {
  position: absolute;
  z-index: 1;
  left: 11px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}

.search input {
  min-width: 0;
  padding-left: 37px;
}

.search__results {
  position: absolute;
  z-index: 50;
  top: calc(100% + 7px);
  right: 0;
  left: 0;
  max-height: 60vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.search__item {
  display: grid;
  width: 100%;
  min-height: 48px;
  gap: 1px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid #f0ece3;
  color: var(--ink);
  background: var(--white);
  text-align: left;
}

.search__item:last-child {
  border-bottom: 0;
}

.search__item[aria-selected="true"],
.search__item:hover {
  background: var(--cobalt-soft);
}

.search__item strong,
.search__item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search__item small {
  color: var(--muted);
}

.menu {
  position: relative;
  flex: 0 0 auto;
}

.menu__panel {
  position: absolute;
  z-index: 55;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  width: min(280px, calc(100vw - 32px));
  max-height: min(60vh, 430px);
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.menu__item {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  font-size: 14px;
  font-weight: 650;
  text-align: left;
  text-decoration: none;
}

.menu__item:hover,
.menu__item:focus-visible {
  background: var(--cobalt-soft);
}

.workspace {
  display: grid;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) 380px;
  overflow: hidden;
}

.workspace > .map,
.workspace > .list {
  min-width: 0;
  min-height: 0;
}

.workspace > .editor {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: var(--white);
}

.workspace > .notice {
  align-self: center;
  justify-self: center;
  width: min(420px, calc(100% - 32px));
  box-shadow: var(--shadow-soft);
}

.bottombar {
  display: none;
}

/* Mind map */
.workspace > .map {
  overflow: hidden;
}

.map {
  min-width: 0;
  min-height: 0;
}

.workspace > .map > .map {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  cursor: grab;
  background:
    radial-gradient(circle at 1px 1px, rgb(95 104 128 / 10%) .8px, transparent 1px) 0 0 / 20px 20px,
    var(--paper);
}

.workspace > .map > .map:active {
  cursor: grabbing;
}

.map__layer {
  position: absolute;
  inset: 0 auto auto 0;
  width: 1px;
  height: 1px;
  transform-origin: 0 0;
}

.map__links {
  position: absolute;
  inset: 0 auto auto 0;
  overflow: visible;
  pointer-events: none;
}

.map__links path {
  opacity: .74;
  vector-effect: non-scaling-stroke;
}

.map__nodes {
  position: absolute;
  inset: 0 auto auto 0;
}

.map__node {
  position: absolute;
  min-width: 0;
  border: 1px solid #d8d5cb;
  border-radius: 11px;
  color: var(--ink);
  background: var(--white);
  box-shadow: var(--shadow-soft);
  transition: opacity 140ms ease, box-shadow 140ms ease, border-color 140ms ease, background-color 140ms ease;
}

.map-node__main {
  display: flex;
  width: 100%;
  height: 100%;
  min-width: 0;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 0;
  border-radius: inherit;
  color: inherit;
  background: transparent;
  text-align: left;
}

.map-node__media {
  display: inline-flex;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  align-items: center;
  justify-content: center;
}

.map-node__labels {
  display: grid;
  min-width: 0;
  line-height: 1.1;
}

.map-node__name,
.map-node__hindi,
.map-node__meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-node__name {
  font-size: 13px;
  font-weight: 700;
}

.map-node__hindi {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.map-node__meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.map-node__statuses {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 3px;
  margin-left: auto;
}

.map-node__status {
  display: inline-flex;
  color: var(--amber);
}

.map-node__status:first-child {
  color: var(--muted);
}

.map-node__status svg {
  width: 16px;
  height: 16px;
}

.thumb {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  object-fit: cover;
  background: var(--paper);
}

.dot {
  width: 16px;
  height: 16px;
  border: 1px solid rgb(28 35 51 / 28%);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 38%);
}

.map__node--root {
  border-color: var(--cobalt);
  border-radius: 999px;
  color: #fff;
  background: var(--cobalt);
  box-shadow: 0 5px 16px rgb(35 64 199 / 28%);
}

.map__node--root .map-node__main {
  padding-inline: 15px;
}

.map__node--root .map-node__name {
  font-size: 14px;
  font-weight: 800;
}

.map__node--root .map-node__hindi,
.map__node--root .map-node__meta,
.map__node--root .map-node__status {
  color: #fff;
}

.map__node--category {
  border-left: 5px solid var(--coral);
}

.map__node--category .map-node__name {
  font-size: 14px;
  font-weight: 800;
}

.map__node--group .map-node__name {
  font-weight: 750;
}

.map__node--product .map-node__main {
  padding-left: 7px;
}

.map__node--option {
  border-radius: 999px;
  box-shadow: 0 2px 7px rgb(28 35 51 / 8%);
}

.map__node--option .map-node__main {
  gap: 6px;
  padding: 4px 10px;
}

.map__node--option .map-node__media {
  width: 16px;
  height: 16px;
  flex-basis: 16px;
}

.map__node--option .map-node__name {
  font-size: 12px;
}

.map__node--option .map-node__hindi {
  display: inline;
  margin: 0 0 0 4px;
  font-size: 12px;
}

.map__node--option .map-node__labels {
  display: block;
}

.map__node--option .map-node__meta {
  display: none;
}

.map__node.is-selected,
.list__row.is-selected {
  z-index: 2;
  border-color: var(--cobalt);
  box-shadow: 0 0 0 3px var(--cobalt), var(--shadow-soft);
}

.map__node.is-hidden,
.list__row.is-hidden {
  border-style: dashed;
}

.map__node.is-hidden .map-node__main,
.list__row.is-hidden .map-node__main {
  opacity: .55;
}

.map__node.is-dimmed,
.list__row.is-dimmed {
  opacity: .6;
}

.map__node.is-target {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.map__node.is-drop-into {
  border-color: var(--green);
  color: #fff;
  background: var(--green);
}

.map__node.is-drop-into .map-node__hindi,
.map__node.is-drop-into .map-node__meta,
.map__node.is-drop-into .map-node__status {
  color: #fff;
}

.map__node.is-dragging {
  opacity: .5;
}

.map__expander {
  position: absolute;
  z-index: 3;
  top: 50%;
  right: -12px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  padding: 0;
  border: 1px solid #d7d2c5;
  border-radius: 50%;
  color: var(--ink);
  background: var(--white);
  box-shadow: 0 2px 5px rgb(28 35 51 / 14%);
  transform: translateY(-50%);
}

.map__expander::before {
  position: absolute;
  inset: -8px;
  content: "";
}

.map__expander svg {
  width: 14px;
  height: 14px;
}

.map-node__count {
  position: absolute;
  top: -8px;
  right: -8px;
  display: grid;
  min-width: 16px;
  height: 16px;
  place-items: center;
  padding: 0 3px;
  border-radius: 99px;
  color: #fff;
  background: var(--cobalt);
  font-size: 10px;
  font-weight: 800;
}

.map__controls {
  position: absolute;
  z-index: 5;
  bottom: 18px;
  left: max(18px, var(--safe-left));
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  box-shadow: var(--shadow-soft);
}

.map__controls .btn {
  border: 0;
  border-radius: 0;
}

.map__controls .btn + .btn {
  border-top: 1px solid var(--line);
}

.map__drop-line {
  stroke: var(--green);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

/* Tree list */
.workspace > .list {
  overflow: auto;
  background: var(--white);
}

.workspace > .list > .list {
  min-height: 100%;
}

.list__row {
  position: relative;
  display: grid;
  min-height: 54px;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: stretch;
  border-bottom: 1px solid #ece8df;
  color: var(--ink);
  background: var(--white);
}

.list__row .map-node__labels {
  line-height: 1.35;
}

.list__row .map-node__main {
  height: auto;
  min-width: 0;
  padding: 8px 12px 8px 0;
  border-radius: 0;
}

.list__row .map-node__name {
  font-size: 14px;
}

.list__row .map-node__meta {
  font-size: 12px;
}

.list__row .map-node__media {
  width: 34px;
  flex-basis: 34px;
}

.list__row .map-node__hindi {
  font-size: 13px;
}

.list__row.is-selected {
  border-color: #cbd4ff;
  background: var(--cobalt-soft);
  box-shadow: none;
}

.list__row.is-selected::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 4px;
  content: "";
  background: var(--cobalt);
}

.list__chevron {
  display: grid;
  width: 36px;
  min-height: 44px;
  place-items: center;
  align-self: center;
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
}

.list__chevron svg {
  width: 17px;
  height: 17px;
  transition: transform 140ms ease;
}

.list__row[aria-expanded="true"] .list__chevron svg {
  transform: rotate(90deg);
}

.list__chevron .map-node__count {
  display: none;
}

/* Editor */
.editor {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 22px 20px 30px;
}

.workspace > .editor > .editor {
  padding: 0;
}

.editor h2 {
  font-size: 22px;
}

.editor__crumbs {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor__crumbs + p {
  margin: -10px 0 0;
  color: var(--cobalt);
  font-size: 13px;
  font-weight: 800;
}

.editor__photo {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf8;
}

.editor__photo .thumb,
.editor__photo-empty {
  grid-row: span 2;
  width: 96px;
  height: 96px;
  border-radius: 10px;
}

.editor__photo .thumb {
  object-fit: contain;
  border: 1px solid #ece6d9;
  background: var(--paper);
}

.editor__photo-empty {
  display: grid;
  place-items: center;
  border: 1px dashed #cfc6b5;
  color: var(--muted);
  background: var(--paper);
}

.editor__photo-empty svg {
  width: 28px;
  height: 28px;
}

.editor__photo .field__error {
  grid-column: 1 / -1;
}

.summary-list {
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf8;
  font-size: 14px;
}

.summary-list > div {
  display: flex;
  gap: 4px;
  justify-content: space-between;
}

.summary-list span {
  color: var(--muted);
}

.editor__actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 2px;
}

.editor__actions > .btn--primary {
  grid-column: 1 / -1;
}

.editor__actions > .btn {
  width: 100%;
  min-height: 48px;
}

.editor__actions > .btn--danger {
  grid-column: 1 / -1;
  margin-top: 16px;
}

.editor__move-row {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: 44px 44px minmax(0, 1fr);
  gap: 8px;
}

.editor__move-row .btn {
  min-width: 0;
}

.editor__move-row .btn:last-child {
  width: 100%;
}

/* Dialogs */
#dialogs {
  position: relative;
  z-index: 80;
}

.dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: min(84dvh, 760px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--white);
  box-shadow: 0 18px 60px rgb(20 24 40 / 30%);
}

.dialog--wide {
  width: min(680px, calc(100vw - 32px));
}

.dialog::backdrop {
  background: rgb(20 24 40 / 45%);
}

.dialog__title {
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 21px;
}

.dialog__body {
  display: grid;
  gap: 16px;
  max-height: calc(min(84dvh, 760px) - 138px);
  overflow: auto;
  padding: 20px 22px;
}

.dialog__body > p {
  margin: 0;
}

.dialog__body section {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdf9;
}

.dialog__body section p {
  margin: 7px 0;
}

.dialog__body ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.dialog__body form {
  display: grid;
  gap: 15px;
}

.dialog__actions {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
  padding: 14px 22px max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--white);
  box-shadow: 0 -4px 12px rgb(28 35 51 / 4%);
}

.choice-list {
  display: grid;
  gap: 7px;
  max-height: 42vh;
  overflow: auto;
}

.choice-list__item {
  display: flex;
  width: 100%;
  min-height: 46px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: var(--white);
  font-weight: 650;
  text-align: left;
}

.choice-list__item:hover,
.choice-list__item.is-selected {
  border-color: #abb9fa;
  background: var(--cobalt-soft);
}

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

.kind-card {
  display: grid;
  min-height: 112px;
  gap: 6px;
  align-content: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: var(--white);
  text-align: left;
}

.kind-card strong {
  font-size: 14px;
}

.kind-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.kind-card:hover,
.kind-card.is-selected {
  border-color: var(--cobalt);
  background: var(--cobalt-soft);
  box-shadow: 0 0 0 2px #cbd4ff;
}

/* Toast */
.toast {
  position: fixed;
  z-index: 120;
  right: 50%;
  bottom: max(20px, calc(var(--safe-bottom) + 20px));
  display: flex;
  width: max-content;
  max-width: min(520px, calc(100vw - 32px));
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid #ccd3ef;
  border-radius: 12px;
  color: #17225b;
  background: #f3f5ff;
  box-shadow: var(--shadow);
  transform: translateX(50%);
}

.toast:empty {
  display: none;
}

.toast--ok {
  border-color: #a7d7c1;
  color: #135c3d;
  background: #effaf4;
}

.toast--error {
  border-color: #f0b7b7;
  color: #872323;
  background: var(--red-soft);
}

.toast .btn {
  flex: 0 0 auto;
}

/* Quiet delete button in the editor; dialogs keep the solid red one. */
.editor__actions > .btn--danger:not(:disabled) {
  border-color: #e9c4c4;
  color: var(--red);
  background: var(--white);
}

.editor__notices {
  display: grid;
  gap: 8px;
}

.editor__notices:empty {
  display: none;
}

.field__error:empty {
  display: none;
}

/* The Back button belongs to the phone sheet only. */
@media (min-width: 821px) {
  .workspace > .editor > .editor > .btn--icon:first-child {
    display: none;
  }
}

/* Responsive desktop */
@media (max-width: 1179px) and (min-width: 821px) {
  .topbar {
    grid-template-columns: auto minmax(220px, 1fr) auto;
  }

  .topbar__brand > span,
  .topbar__group:last-child > .status {
    display: none;
  }
}

@media (min-width: 1180px) {
  .topbar__group:last-child {
    gap: 7px;
  }
}

/* Phone */
@media (max-width: 820px) {
  body {
    overflow: hidden;
  }

  .app {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    grid-template-areas:
      "brand switch actions menu"
      "search search search search"
      "note note note note";
    gap: 8px;
    min-height: 0;
    padding: calc(8px + var(--safe-top)) max(10px, var(--safe-right)) 8px max(10px, var(--safe-left));
  }

  .topbar__brand {
    grid-area: brand;
    gap: 6px;
    font-size: 14px;
  }

  .topbar__brand img {
    width: 31px;
    height: 31px;
  }

  .topbar__group:nth-child(2) {
    display: contents;
  }

  .topbar__group:nth-child(2) .segmented {
    grid-area: switch;
  }

  .topbar__group:nth-child(2) .search {
    grid-area: search;
    width: 100%;
    max-width: none;
  }

  .topbar__group:last-child {
    display: contents;
  }

  .topbar__group:last-child > .btn--icon,
  .topbar__group:last-child > .btn--primary,
  .topbar__group:last-child > .status {
    display: none;
  }

  .topbar__group:last-child > .publish-note {
    grid-area: note;
    max-width: none;
    text-align: left;
  }

  .topbar__group:last-child > .btn--ghost {
    grid-area: actions;
  }

  .topbar__group:last-child > .menu {
    grid-area: actions;
    justify-self: end;
  }

  .topbar__group:last-child > .btn--ghost + .menu {
    grid-area: menu;
    margin: 0;
  }

  .segmented__btn {
    min-height: 44px;
    padding-inline: 8px;
  }

  .search input {
    min-height: 48px;
    font-size: 16px;
  }

  .menu__panel {
    top: calc(100% + 8px);
    right: 0;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-row: 2;
  }

  .workspace > .map,
  .workspace > .list {
    grid-column: 1;
    grid-row: 1;
  }

  .workspace > .editor {
    position: fixed;
    z-index: 70;
    inset: 0;
    display: none;
    overflow: auto;
    border: 0;
    background: var(--white);
  }

  .app--editor-open .workspace > .editor {
    display: block;
  }

  .workspace > .editor > .editor {
    padding: 0 16px calc(28px + var(--safe-bottom));
  }

  .workspace > .editor > .editor > .btn--icon:first-child {
    position: sticky;
    z-index: 2;
    top: 0;
    width: calc(100% + 32px);
    height: calc(56px + var(--safe-top));
    margin: 0 -16px 2px;
    padding: var(--safe-top) 16px 0;
    justify-content: flex-start;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: rgb(255 255 255 / 97%);
    box-shadow: 0 2px 7px rgb(28 35 51 / 5%);
  }

  .workspace > .editor > .editor > .btn--icon:first-child::after {
    content: "Back";
    margin-left: 6px;
    font-weight: 750;
  }

  .bottombar {
    z-index: 30;
    display: grid;
    grid-template-columns: 48px 48px minmax(0, 1fr);
    gap: 8px;
    min-height: calc(64px + var(--safe-bottom));
    padding: 8px max(10px, var(--safe-right)) calc(8px + var(--safe-bottom)) max(10px, var(--safe-left));
    border-top: 1px solid var(--line);
    background: rgb(255 255 255 / 97%);
    box-shadow: 0 -3px 12px rgb(28 35 51 / 7%);
  }

  .bottombar .btn {
    min-height: 48px;
  }

  .bottombar .btn--icon {
    width: 48px;
    min-width: 48px;
  }

  .workspace > .map > .map {
    background-size: 22px 22px;
  }

  .map__controls {
    bottom: 14px;
    left: max(14px, var(--safe-left));
  }

  .map__controls .btn {
    width: 48px;
    min-width: 48px;
    min-height: 48px;
  }

  .list__row {
    min-height: 58px;
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .list__chevron {
    width: 44px;
    min-height: 48px;
  }

  .list__row .map-node__main {
    padding-block: 9px;
  }

  .editor {
    gap: 16px;
  }

  .editor h2 {
    font-size: 21px;
  }

  .editor input,
  .editor select,
  .dialog input,
  .dialog select {
    min-height: 48px;
    font-size: 16px;
  }

  .editor__actions {
    gap: 10px;
  }

  .editor__actions > .btn,
  .editor__move-row .btn {
    min-height: 48px;
  }

  .dialog {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 92dvh;
    margin: 0;
    border-radius: 18px 18px 0 0;
  }

  .dialog--wide {
    width: 100%;
  }

  .dialog__title {
    padding: 18px 18px 13px;
    font-size: 20px;
  }

  .dialog__body {
    max-height: calc(92dvh - 132px);
    padding: 17px 18px;
  }

  .dialog__actions {
    padding: 12px 18px max(12px, var(--safe-bottom));
  }

  .dialog__actions .btn {
    flex: 1 1 auto;
  }

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

  .kind-card {
    min-height: 96px;
  }

  .toast {
    bottom: calc(80px + var(--safe-bottom));
    max-width: calc(100vw - 24px);
  }
}

@media (max-width: 390px) {
  .topbar__brand > span {
    display: none;
  }

  .segmented__btn span {
    display: none;
  }

  .segmented__btn {
    width: 44px;
  }

  .editor__photo {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .editor__photo .thumb,
  .editor__photo-empty {
    width: 78px;
    height: 78px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto;
    transition-duration: .01ms;
    animation-duration: .01ms;
    animation-iteration-count: 1;
  }
}
