:root {
  color-scheme: light dark;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
}

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

body {
  max-width: 680px;
  margin: 2rem auto;
  padding: 0 1rem;
  line-height: 1.5;
}

a { color: inherit; }

h1 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

h1 a { text-decoration: none; }

p { margin: 0.5rem 0; }

/* ── Topbar ── */

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}


.topbar-left {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.back-link {
  font-size: 0.85rem;
  opacity: 0.55;
  text-decoration: none;
}

.back-link:hover { opacity: 1; }

.list-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.who {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.who > span {
  opacity: 0.55;
}

.who code {
  font-size: 0.8em;
  word-break: break-all;
}

.who > button:not(.icon-button) {
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
}

/* ── Forms ── */

form {
  display: flex;
  gap: 0.5rem;
  margin: 0.75rem 0;
  align-items: baseline;
}

input:not([type="checkbox"]) {
  flex: 1;
  padding: 0.4rem 0.5rem;
  font: inherit;
  min-width: 0;
  border: 1px solid light-dark(#ccc, #444);
  border-radius: 4px;
  background: light-dark(#fff, #1c1c1e);
  color: inherit;
  transition: border-color 0.15s;
}

input:not([type="checkbox"]):focus {
  outline: 2px solid rgba(from blue r g b / 0.4);
  outline-offset: 1px;
}

button {
  padding: 0.4rem 0.75rem;
  font: inherit;
  cursor: pointer;
  border: 1px solid light-dark(#ccc, #444);
  border-radius: 4px;
  background: light-dark(#fff, #2c2c2e);
  color: inherit;
  transition: background 0.15s;
}

button:hover   { background: light-dark(#f5f5f5, #3a3a3c); }
button:active  { background: light-dark(#eee, #444); }
button:disabled { opacity: 0.4; cursor: default; }

button.x {
  padding: 0 0.5rem;
  background: none;
  border: none;
  font-size: 1.2em;
  opacity: 0.4;
  cursor: pointer;
}

button.x:hover { opacity: 1; }

/* ── States ── */

pre {
  white-space: pre-wrap;
  word-break: break-word;
}

.error  { color: #c00; }
.empty  { opacity: 0.5; font-style: italic; }

/* ── Lists view ── */

ul.lists,
ul.items,
ul.editors {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}

ul.lists li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid color-mix(in srgb, currentColor 15%, transparent);
}

ul.lists a {
  flex: 1;
  text-decoration: none;
  font-weight: 500;
}

ul.lists a:hover { text-decoration: underline; }

.badge {
  font-size: 0.7em;
  padding: 0.1em 0.5em;
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 12%, transparent);
  opacity: 0.7;
}


/* ── Todo items ── */

ul.items li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid color-mix(in srgb, currentColor 10%, transparent);
  position: relative;
}

ul.items .grip {
  cursor: grab;
  opacity: 0.25;
  user-select: none;
  font-size: 0.9em;
  line-height: 1;
}

ul.items li:hover .grip { opacity: 0.6; }
ul.items li.dragging    { opacity: 0.4; }

ul.items li.drop-before::before,
ul.items li.drop-after::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: #4285f4;
}

ul.items li.drop-before::before { top:    -1px; }
ul.items li.drop-after::after   { bottom: -1px; }

ul.items .text {
  flex: 1;
  cursor: text;
  padding: 0.2rem 0;
}

ul.items input.edit {
  flex: 1;
  padding: 0.2rem;
}

ul.items .item.done .text {
  text-decoration: line-through;
  opacity: 0.5;
}

/* ── Editors list ── */

ul.editors li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid color-mix(in srgb, currentColor 10%, transparent);
}

ul.editors code {
  flex: 1;
  font-size: 0.85em;
  word-break: break-all;
}

/* ── Modal ── */

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: grid;
  place-items: center;
  z-index: 100;
}

.modal {
  background: Canvas;
  color: CanvasText;
  border-radius: 8px;
  padding: 1.5rem;
  max-width: min(500px, 90vw);
  width: 100%;
  max-height: 80vh;
  overflow: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal h3    { margin-top: 0; }
.modal .close { margin-top: 1rem; }

/* ── Icon button ── */

.icon-button {
  all: unset;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  border-radius: 4px;
  color: #888;
  vertical-align: middle;
}

.icon-button:hover {
  color: #333;
  background: color-mix(in srgb, currentColor 10%, transparent);
}

/* ── Devtools panel ── */

.devtools-fixed-wrapper {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  z-index: 1000;
}

.devtools-resize-handle {
  height: 6px;
  cursor: ns-resize;
  flex-shrink: 0;
  background: transparent;
}

.devtools-resize-handle:hover {
  background: color-mix(in srgb, currentColor 8%, transparent);
}

.devtools-panel {
  display: flex;
  flex-direction: column;
  border-top: 1px solid #ddd;
  background: #fff;
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas,
    "DejaVu Sans Mono", monospace;
  font-size: 12px;
}

.devtools-header {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #f5f5f5;
  border-bottom: 1px solid #e0e0e0;
  height: 32px;
  padding: 0 6px;
  flex-shrink: 0;
}

.devtools-tabs {
  display: flex;
  height: 100%;
  margin-right: 4px;
}

.devtools-tabs button {
  all: unset;
  padding: 0 10px;
  font-size: 11px;
  font-family: system-ui, sans-serif;
  cursor: pointer;
  color: #666;
  border-bottom: 2px solid transparent;
  height: 100%;
}

.devtools-tabs button:hover {
  color: #333;
  background: rgba(0, 0, 0, 0.05);
}

.devtools-tabs button.active {
  color: #1a73e8;
  border-bottom-color: #1a73e8;
}

.devtools-action {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-family: system-ui, sans-serif;
  padding: 3px 6px !important;
  color: #888;
}

.devtools-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.devtools-tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.devtools-subtabs {
  display: flex;
  flex-shrink: 0;
  border-bottom: 1px solid #e8e8e8;
  padding: 0 4px;
  overflow-x: auto;
}

.devtools-subtabs button {
  all: unset;
  padding: 5px 10px;
  font-size: 11px;
  font-family: system-ui, sans-serif;
  cursor: pointer;
  color: #888;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.devtools-subtabs button:hover { color: #333; }

.devtools-subtabs button.active {
  color: #1a73e8;
  border-bottom-color: #1a73e8;
}

.devtools-body-inner {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

.devtools-body-inner:not(.has-detail) { overflow-y: auto; }

.devtools-body-inner.has-detail > .devtools-timeline {
  width: 340px;
  flex-shrink: 0;
  border-right: 1px solid #e8e8e8;
  overflow-y: auto;
}

.devtools-empty {
  color: #999;
  text-align: center;
  padding: 24px;
  font-family: system-ui, sans-serif;
}

.devtools-timeline {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.devtools-entry {
  border: 1px solid #eee;
  border-radius: 5px;
  padding: 7px 9px;
  background: #fafafa;
  cursor: pointer;
}

.devtools-entry:hover  { background: #f0f4ff; border-color: #c8d8ff; }
.devtools-entry.active { background: #e8f0fe; border-color: #4285f4; }

.devtools-entry-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
}

.devtools-entry-index {
  font-size: 10px;
  font-weight: 700;
  color: #bbb;
  min-width: 14px;
}

.devtools-entry-author {
  font-weight: 600;
  font-size: 11px;
  font-family: system-ui, sans-serif;
}

.devtools-entry-time {
  font-size: 10px;
  color: #aaa;
  margin-left: auto;
}

.devtools-entry-uri {
  font-size: 10px;
  color: #1a73e8;
  margin-bottom: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.devtools-entry-json {
  font-size: 10px;
  color: #555;
  margin: 0;
  white-space: pre;
  line-height: 1.5;
  overflow: hidden;
  max-height: 60px;
}

.devtools-detail {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  min-width: 0;
}

.devtools-detail-meta {
  font-size: 11px;
  color: #888;
  margin-bottom: 10px;
  font-family: system-ui, sans-serif;
}

.devtools-doc-json {
  font-size: 12px;
  color: #333;
  margin: 0;
  white-space: pre;
  line-height: 1.5;
}
