/* Bidadari Task demo: Mac, iPad and iPhone layouts.
   Uses the Bidadari tokens from main.css, so light and dark follow the site theme. */

.demo-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 920px;
  margin: 0 auto 14px;
}

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.seg button {
  min-height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.seg button[hidden] {
  display: none;
}

.seg button:hover {
  color: var(--text);
}

.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgb(29 24 48 / 12%);
}

.reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
}

.reset-btn:hover {
  color: var(--text);
  background: var(--accent-soft);
}

.reset-btn .icon {
  width: 18px;
  height: 18px;
}

.demo-note,
.demo-foot,
.demo-noscript {
  max-width: 920px;
  margin: 0 auto 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.demo-foot {
  margin: 16px auto 0;
  text-align: center;
}

.d-stage {
  display: flex;
  justify-content: center;
  min-height: 200px;
}

/* Frame ---------------------------------------------------------------- */

.d-frame {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.4;
  box-shadow: var(--shadow);
}

:where(.d-frame) :where(button, input, select, textarea) {
  font: inherit;
  color: inherit;
}

.d-frame [hidden] {
  display: none !important;
}

.d-icon {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.is-mac {
  max-width: 920px;
  height: 580px;
  border-radius: 12px;
}

.is-ipad {
  max-width: 880px;
  height: 600px;
  border-radius: 26px;
  border: 8px solid var(--text);
  font-size: 0.95rem;
}

.is-phone {
  max-width: 372px;
  height: 700px;
  border-radius: 44px;
  border: 8px solid var(--text);
  font-size: 1rem;
}

.is-phone::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 50%;
  z-index: 3;
  width: 92px;
  height: 26px;
  border-radius: 14px;
  background: var(--text);
  translate: -50% 0;
}

:root[data-theme="dark"] .is-ipad,
:root[data-theme="dark"] .is-phone {
  border-color: #3a3355;
}

:root[data-theme="dark"] .is-phone::before {
  background: #000;
}

.d-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding-inline: 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.d-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.d-dot.is-r { background: #ff5f57; }
.d-dot.is-y { background: #febc2e; }
.d-dot.is-g { background: #28c840; }

.d-wtitle {
  margin-left: auto;
  margin-right: auto;
  padding-right: 52px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.d-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  height: 44px;
  padding: 6px 26px 0;
  font-size: 0.82rem;
  font-weight: 650;
}

.is-ipad .d-status {
  height: 30px;
  padding-top: 0;
}

.d-statusicons {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.d-statusicons i {
  display: block;
  width: 16px;
  height: 9px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.85;
}

.d-statusicons .d-battery {
  width: 24px;
  height: 11px;
  border-radius: 4px;
}

.d-body {
  flex: 1;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  min-height: 0;
}

.is-ipad .d-body {
  grid-template-columns: 230px minmax(0, 1fr);
}

/* Sidebar ----------------------------------------------------------------- */

.d-sidebar {
  overflow-y: auto;
  padding: 10px 8px;
  background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface));
  border-right: 1px solid var(--border);
}

.d-navgroup {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 12px;
}

.d-navhead {
  margin: 6px 10px 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.d-navitem {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
  cursor: pointer;
}

.is-ipad .d-navitem {
  min-height: 44px;
  border-radius: 12px;
}

.d-navitem .d-icon {
  color: var(--accent);
}

.d-navitem:hover {
  background: color-mix(in srgb, var(--accent) 9%, transparent);
}

.d-navitem.is-active {
  background: var(--accent);
  color: var(--accent-contrast);
}

.d-navitem.is-active .d-icon,
.d-navitem.is-active .d-count {
  color: var(--accent-contrast);
}

.d-navlabel {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.d-count {
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.d-navnew {
  color: var(--muted);
}

.d-navnew .d-icon {
  color: var(--muted);
}

/* Main column ----------------------------------------------------------------- */

.d-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.d-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.is-ipad .d-toolbar {
  padding: 14px 20px 8px;
  border-bottom: 0;
}

.d-toolbartitle {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.d-heading {
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.is-ipad .d-heading {
  font-size: 1.7rem;
}

.d-sub {
  color: var(--muted);
  font-size: 0.8rem;
}

.d-searchwrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 180px;
}

.d-searchwrap .d-icon {
  position: absolute;
  left: 9px;
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
}

.d-search {
  width: 100%;
  min-height: 32px;
  padding: 4px 10px 4px 30px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.d-search::placeholder,
.d-form input::placeholder,
.d-form textarea::placeholder,
.d-addinput::placeholder {
  color: var(--muted);
  opacity: 1;
}

.d-searchrow {
  flex: none;
  padding: 0 20px 10px;
}

.d-searchrow .d-searchwrap {
  width: 100%;
}

.d-searchrow .d-search {
  min-height: 40px;
  border-radius: 12px;
}

.d-iconbtn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--accent);
  cursor: pointer;
}

.d-iconbtn:hover {
  background: var(--accent-soft);
}

.d-addbtn.is-on {
  background: var(--accent);
  color: var(--accent-contrast);
}

/* Add row ------------------------------------------------------------------------ */

.d-addrow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  margin: 8px 12px 0;
  padding: 6px 8px 6px 12px;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 12px;
}

.d-addicon {
  display: inline-grid;
  color: var(--accent);
}

.d-addinput {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  padding: 0;
  border: 0;
  background: none;
}

.d-addinput:focus-visible {
  outline: none;
}

.d-addrow:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Task list ------------------------------------------------------------------------ */

.d-tasks {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 8px 16px;
}

.d-tasks:focus {
  outline: none;
}

.d-group + .d-group,
.d-group + .d-fold {
  margin-top: 8px;
}

.d-grouptitle {
  padding: 8px 8px 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.d-grouptitle.is-overdue {
  color: var(--red);
}

.d-rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.d-row {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  padding: 4px 6px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

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

.d-check {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin: 8px 8px 0 4px;
  padding: 0;
  border: 1.6px solid var(--muted);
  border-radius: 50%;
  background: none;
  cursor: pointer;
}

.d-check::after {
  content: "";
  position: absolute;
  inset: -9px;
}

.d-check .d-icon {
  width: 14px;
  height: 14px;
  stroke: var(--accent-contrast);
  stroke-width: 2.4;
  opacity: 0;
}

.d-check:hover {
  border-color: var(--accent);
}

.d-check.is-done {
  background: var(--accent);
  border-color: var(--accent);
}

.d-check.is-done .d-icon {
  opacity: 1;
}

.d-rowmain {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 6px 4px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
  cursor: pointer;
}

.d-rowmain:hover {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

.d-title {
  overflow-wrap: anywhere;
}

.d-row.is-done .d-title {
  color: var(--muted);
  text-decoration: line-through;
}

.d-metas {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 12px;
}

.d-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.d-meta .d-icon {
  width: 13px;
  height: 13px;
}

.d-due.is-overdue {
  color: var(--red);
}

.d-due.is-soon {
  color: var(--orange);
}

.d-textbtn {
  flex: none;
  min-height: 36px;
  margin-top: 2px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.d-textbtn:hover {
  background: var(--accent-soft);
}

.d-fold summary {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

.d-fold summary::-webkit-details-marker {
  display: none;
}

.d-fold summary .d-icon {
  width: 14px;
  height: 14px;
  transition: rotate 0.15s;
  rotate: -90deg;
}

.d-fold[open] summary .d-icon {
  rotate: 0deg;
}

.d-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 56px 24px;
  color: var(--muted);
  text-align: center;
}

.d-empty-icon {
  width: 34px;
  height: 34px;
  margin-bottom: 6px;
  color: var(--accent);
  opacity: 0.8;
}

.d-empty-title {
  color: var(--text);
  font-weight: 650;
}

.d-empty-text {
  max-width: 28ch;
  font-size: 0.88rem;
}

/* Buttons and forms --------------------------------------------------------------------- */

.d-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
}

.d-btn:hover {
  border-color: var(--accent);
}

.d-btn-primary {
  background: var(--accent-grad);
  border-color: transparent;
  color: var(--accent-contrast);
}

.d-btn-primary:hover {
  background: var(--accent-hover);
  border-color: transparent;
}

.d-btn-danger {
  color: var(--red);
}

.d-btn-danger:hover {
  border-color: var(--red);
}

.d-btn .d-icon {
  width: 16px;
  height: 16px;
}

.d-scrim {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgb(20 16 40 / 42%);
}

.d-sheet {
  width: min(420px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.d-sheethead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.d-sheettitle {
  font-size: 1.1rem;
}

.d-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.d-field {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.d-field label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.d-field input,
.d-field select,
.d-field textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.d-field textarea {
  resize: vertical;
}

.d-field input:disabled {
  opacity: 0.5;
}

.d-fieldrow {
  display: flex;
  gap: 10px;
}

.d-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: -4px;
}

.d-chip {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.82rem;
  cursor: pointer;
}

.d-chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.d-checkrow {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
}

.d-checkrow input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.d-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

.d-actions-right {
  display: flex;
  gap: 8px;
}

.d-error {
  min-height: 0;
  color: var(--red);
  font-size: 0.85rem;
}

.d-error:empty {
  display: none;
}

.d-hint {
  color: var(--muted);
  font-size: 0.85rem;
}

.d-toast {
  position: absolute;
  bottom: 16px;
  left: 50%;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 24px);
  padding: 8px 8px 8px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.88rem;
  box-shadow: var(--shadow);
  translate: -50% 0;
}

.d-toastbtn {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

.is-phone .d-toast {
  bottom: 92px;
}

/* iPhone ----------------------------------------------------------------------------------- */

.is-phone .d-main {
  flex: 1;
  overflow-y: auto;
}

.is-phone .d-toolbar {
  min-height: 48px;
  padding: 4px 10px 0;
  border-bottom: 0;
}

.d-toolspacer {
  flex: 1;
}

.d-backbtn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  padding: 0 8px 0 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 1rem;
  cursor: pointer;
}

.d-backbtn .d-icon {
  width: 22px;
  height: 22px;
}

.is-phone .d-iconbtn {
  width: 44px;
  height: 44px;
}

.d-largehead {
  display: flex;
  flex-direction: column;
  padding: 0 20px 8px;
}

.is-phone .d-heading {
  font-size: 2rem;
  letter-spacing: -0.02em;
}

.is-phone .d-searchrow {
  padding: 0 16px 8px;
}

.is-phone .d-addrow {
  margin: 4px 12px 4px;
}

.is-phone .d-tasks {
  flex: none;
  overflow: visible;
  padding-bottom: 96px;
}

.is-phone .d-row {
  padding: 4px 8px;
}

.is-phone .d-check {
  width: 26px;
  height: 26px;
  margin-top: 9px;
}

.is-phone .d-check::after {
  inset: -9px;
}

.is-phone .d-rowmain {
  padding: 8px 4px;
}

.is-phone .d-meta {
  font-size: 0.82rem;
}

.d-fab {
  position: absolute;
  right: 18px;
  bottom: 86px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent-grad);
  color: var(--accent-contrast);
  box-shadow: 0 6px 18px rgb(109 79 216 / 38%);
  cursor: pointer;
}

.d-fab .d-icon {
  width: 24px;
  height: 24px;
}

.d-fab.is-on {
  background: var(--accent-hover);
}

.d-tabbar {
  display: grid;
  flex: none;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 4px 18px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.d-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 48px;
  padding: 4px 0;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.d-tab.is-active {
  color: var(--accent);
}

.d-tabicon {
  position: relative;
  display: inline-grid;
}

.d-tabicon .d-icon {
  width: 24px;
  height: 24px;
}

.d-badge {
  position: absolute;
  top: -4px;
  left: 60%;
  min-width: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.66rem;
  line-height: 16px;
  text-align: center;
}

.d-listsindex {
  padding: 4px 12px 96px;
}

.d-indexlist {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.d-indexlist li + li {
  border-top: 1px solid var(--border);
}

.d-indexrow {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 8px 14px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.d-indexrow > .d-icon:first-child {
  color: var(--accent);
}

.d-chev {
  width: 14px;
  height: 14px;
  color: var(--muted);
  rotate: 180deg;
}

.d-newlist {
  min-height: 48px;
}

/* Inputs at 16px on touch layouts: avoids the iOS zoom-on-focus. */
.is-phone input,
.is-phone select,
.is-phone textarea,
.is-ipad input,
.is-ipad select,
.is-ipad textarea {
  font-size: 1rem;
}

.is-phone .d-scrim {
  align-items: flex-end;
  padding: 0;
}

.is-phone .d-sheet {
  width: 100%;
  border-radius: 20px 20px 0 0;
  border-bottom: 0;
  padding-bottom: 28px;
}

.is-phone .d-btn,
.is-phone .d-chip {
  min-height: 44px;
}

/* Smaller screens --------------------------------------------------------------------------- */

@media (max-width: 47.5rem) {
  .demo-controls {
    justify-content: center;
  }

  /* On a real phone the demo fills the width instead of drawing a phone inside a phone. */
  .is-phone {
    max-width: 420px;
    height: min(700px, calc(100svh - 120px));
    min-height: 520px;
    border-width: 4px;
    border-radius: 32px;
  }

  .is-phone::before {
    display: none;
  }

  .is-phone .d-status {
    height: 28px;
    padding-top: 0;
  }
}

@media (max-width: 24rem) {
  .d-fieldrow {
    flex-direction: column;
  }

  .d-actions {
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .d-fold summary .d-icon {
    transition: none;
  }
}
