:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --text: #0f1f4d;
  --muted: #5d6b8c;
  --line: #dce4f2;
  --line-strong: #c7d2e7;
  --primary: #1769dd;
  --primary-strong: #0e52b7;
  --focus-ring: #075fc9;
  --shadow: 0 10px 28px rgba(35, 48, 86, 0.1);
  --small-shadow: 0 5px 14px rgba(35, 48, 86, 0.08);
  --tile-gap: 2px;
  --tile-empty: #edf3fb;
  --tile-empty-dark: #1d293d;
  --ok: #137a36;
  --danger: #c52727;
  --warning: #8b5700;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(242, 247, 255, 0.88)),
    var(--bg);
}

body.dark {
  color-scheme: dark;
  --bg: #111827;
  --panel: rgba(20, 30, 48, 0.93);
  --panel-strong: #172033;
  --text: #eef4ff;
  --muted: #a6b2c7;
  --line: #28354d;
  --line-strong: #3d4d68;
  --primary: #78b7ff;
  --primary-strong: #2867b2;
  --focus-ring: #a8d2ff;
  --ok: #6edb91;
  --danger: #ff8585;
  --warning: #ffc35c;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.26);
  --small-shadow: 0 10px 26px rgba(0, 0, 0, 0.2);
  --tile-empty: #1e293b;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.92), rgba(17, 24, 39, 0.96)),
    var(--bg);
}

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

button {
  border: 0;
  border-radius: 7px;
  color: #ffffff;
  background: var(--primary-strong);
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  transition: background-color 80ms ease, border-color 80ms ease, color 80ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(47, 125, 246, 0.24);
}

button:disabled,
button[aria-disabled="true"],
input:disabled,
textarea:disabled,
select:disabled {
  opacity: 0.56;
  cursor: not-allowed;
}

button:disabled:hover,
button[aria-disabled="true"]:hover {
  transform: none;
  box-shadow: none;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.toggle-row input:focus-visible + span + i {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

button.secondary,
.secondary {
  color: var(--text);
  background: #eef4ff;
  border: 1px solid var(--line);
}

body.dark button.secondary,
body.dark .secondary {
  background: #22314a;
}

.ghost-button {
  min-height: 26px;
  padding: 0 8px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  color: var(--text);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.icon-button.large {
  width: 32px;
  height: 32px;
}

.icon-button.tiny {
  width: 24px;
  min-width: 24px;
  height: 24px;
  min-height: 24px;
  font-size: 12px;
}

.icon-button.micro {
  width: 20px;
  min-width: 20px;
  height: 22px;
  min-height: 22px;
  border-radius: 5px;
  font-size: 10px;
}

.icon-button[aria-pressed="true"] {
  color: #ffffff;
  background: var(--primary-strong);
  border-color: var(--primary-strong);
}

.danger,
.ghost-button.danger {
  color: var(--danger);
}

input,
textarea,
select {
  width: 100%;
  color: var(--text);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 12px;
}

textarea {
  resize: vertical;
  min-height: 56px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(190px, 240px) minmax(490px, 1fr) minmax(230px, 270px);
  gap: 8px;
  width: min(1720px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 8px;
}

.side-panel,
.main-panel {
  background: var(--panel);
  border: 1px solid rgba(199, 210, 231, 0.72);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  padding: 9px;
}

.main-panel {
  min-width: 0;
  padding: 10px;
}

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

.brand h1 {
  margin: 0;
  color: #082565;
  font-size: 24px;
  line-height: 1;
  letter-spacing: 0;
}

body.dark .brand h1 {
  color: #dbeafe;
}

.brand p {
  margin: 2px 0 0;
  color: var(--primary);
  font-size: 11px;
  font-weight: 650;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 13px);
  gap: 3px;
  flex: 0 0 auto;
}

.brand-mark i {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.14);
}

.brand-mark i:nth-child(1) { background: #f24d86; }
.brand-mark i:nth-child(2) { background: #ff8a1f; }
.brand-mark i:nth-child(3) { background: #38a3ff; }
.brand-mark i:nth-child(4) { background: #68c44a; }

.panel-section {
  padding: 8px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--line);
  border-radius: 8px;
}

body.dark .panel-section {
  background: rgba(15, 23, 42, 0.52);
}

.sync-section,
.period-nav,
.quick-row,
.share-actions,
.copy-row,
.auth-actions,
.brush-toolbar,
.editor-head {
  display: flex;
  align-items: center;
  gap: 5px;
}

.sync-section {
  justify-content: space-between;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  color: var(--muted);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.status-synced { color: var(--ok); }
.status-syncing { color: var(--primary); }
.status-error { color: var(--danger); }
.status-offline { color: var(--warning); }

.eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--primary);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
}

.section-title-row .eyebrow {
  margin-bottom: 0;
}

.collapsible-body {
  margin-top: 4px;
}

.collapsible-body[hidden],
#tileEditor[hidden] {
  display: none;
}

.period-section strong {
  display: block;
  margin-bottom: 6px;
  font-size: 16px;
  line-height: 1.2;
}

.period-nav {
  display: grid;
  grid-template-columns: 30px 1fr 30px;
}

#weekPicker {
  display: none;
}

.quick-row {
  flex-wrap: wrap;
  margin-top: 5px;
}

.quick-row button,
.share-actions button,
.auth-actions button {
  flex: 1 1 auto;
}

.toggle-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 36px;
  align-items: center;
  gap: 6px;
  min-height: 27px;
  color: var(--text);
  cursor: pointer;
}

.toggle-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.toggle-row span {
  font-size: 12px;
  font-weight: 650;
}

.toggle-row i {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: #d9e3f2;
  border: 1px solid var(--line-strong);
}

.toggle-row i::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 31, 77, 0.18);
  transition: transform 140ms ease;
}

.toggle-row input:checked + span + i {
  background: var(--primary);
}

.toggle-row input:checked + span + i::after {
  transform: translateX(16px);
}

.range-row,
.select-row {
  display: grid;
  grid-template-columns: 68px 1fr auto;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 700;
}

.select-row {
  grid-template-columns: 1fr 78px;
}

.range-row input {
  padding: 0;
}

.range-row b {
  color: var(--muted);
  font-size: 10px;
}

.import-section textarea {
  font-size: 11px;
}

.profile-card {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 6px;
}

.profile-card p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: #fff;
  background: var(--primary);
  font-weight: 900;
}

.auth-form {
  display: grid;
  gap: 5px;
}

.copy-row {
  margin-top: 5px;
}

.copy-row input {
  min-width: 0;
  font-size: 10px;
}

.compact-copy {
  margin: 0;
  font-size: 10px;
}

.api-endpoint-row {
  margin-top: 0;
}

.api-token-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(88px, 0.8fr);
  gap: 4px;
  margin-top: 6px;
}

.api-token-form input {
  grid-column: 1 / -1;
}

.api-token-form button {
  grid-column: 1 / -1;
}

.api-token-reveal {
  margin-bottom: 6px;
  padding: 6px;
  border: 1px solid color-mix(in srgb, var(--ok) 45%, var(--line));
  border-radius: 7px;
  background: color-mix(in srgb, var(--ok) 8%, var(--panel-strong));
}

.api-token-reveal p,
.api-token-row p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.api-token-list {
  display: grid;
  gap: 3px;
  margin-top: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.api-token-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
  border-top: 1px solid var(--line);
}

.api-token-row strong,
.api-token-row code {
  overflow-wrap: anywhere;
}

.api-doc-link {
  display: inline-block;
  margin-top: 6px;
  color: var(--primary);
  font-size: 10px;
  font-weight: 750;
}

.view-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  width: min(520px, 100%);
  margin: 0 auto 9px;
  padding: 3px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--small-shadow);
}

.view-tabs button {
  min-height: 32px;
  padding: 0 8px;
  color: var(--text);
  background: transparent;
  border-radius: 999px;
}

.view-tabs button.active,
.view-tabs button[aria-selected="true"],
.view-tabs button[aria-pressed="true"] {
  color: #ffffff;
  background: var(--primary-strong);
}

.main-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.main-header h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.1;
  letter-spacing: 0;
}

.main-header p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.time-note,
.date-chip {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-strong);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.brush-meta {
  gap: 5px;
  max-width: min(320px, 48%);
  color: var(--muted);
}

.brush-meta.has-brush {
  color: var(--text);
  border-color: color-mix(in srgb, var(--primary) 50%, var(--line));
}

.brush-meta strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brush-meta-swatch,
.brush-meta-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 900;
}

.brush-meta-icon {
  color: var(--text);
  background: var(--panel);
}

.brush-meta-clear {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 19px;
  min-width: 19px;
  height: 19px;
  min-height: 19px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border-radius: 50%;
  font-size: 15px;
}

.brush-meta-clear:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 9%, transparent);
  box-shadow: none;
  transform: none;
}

.view-root {
  min-height: 0;
}

.board-wrap {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}

.grid-with-rail {
  --tile-display-size: calc(var(--tile-size) + 4px);
  display: grid;
  grid-template-columns: 34px repeat(12, minmax(0, var(--tile-display-size)));
  gap: var(--tile-gap);
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: none;
  min-width: 0;
  container-name: tile-grid;
  container-type: inline-size;
  touch-action: pan-y;
  user-select: none;
}

.view-root.painting-enabled .tile {
  cursor: crosshair;
}

.week-grid-wrap {
  grid-template-columns: 34px repeat(12, minmax(0, var(--tile-display-size)));
  gap: var(--tile-gap);
}

.rail-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  text-align: right;
  line-height: 1;
}

.rail-label.morning-boundary {
  color: var(--primary);
}

.tile.morning-boundary {
  border-top-color: var(--primary);
  box-shadow: inset 0 2px 0 var(--primary), inset 0 -2px 4px rgba(15, 31, 77, 0.07);
}

.tile {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  max-width: var(--tile-display-size);
  height: auto;
  aspect-ratio: 1;
  min-width: 0;
  min-height: 0;
  padding: 1px;
  overflow: hidden;
  color: var(--tile-foreground, var(--text));
  background: var(--tile-empty);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: inset 0 -2px 4px rgba(15, 31, 77, 0.07);
  transition: none;
}

.tile:hover {
  transform: none;
  outline: 2px solid color-mix(in srgb, var(--primary) 72%, transparent);
  outline-offset: -2px;
  box-shadow: inset 0 -2px 4px rgba(15, 31, 77, 0.07);
}

.tile.filled {
  background: var(--tile-color);
  border-color: color-mix(in srgb, var(--tile-color) 78%, #ffffff);
  color: var(--tile-foreground, #0f1f4d);
}

.tile.connected {
  border-radius: var(--tile-radius);
}

.tile.no-empty-border:not(.filled) {
  border-color: transparent;
}

.tile.past {
  opacity: 0.48;
}

.tile.current,
.tile[aria-current="time"] {
  z-index: 2;
  border-color: #0f1f4d;
  outline: 2px dashed var(--primary);
  outline-offset: 0;
}

body.dark .tile.current,
body.dark .tile[aria-current="time"] {
  border-color: #ffffff;
}

.tile.selected,
.tile[aria-selected="true"] {
  z-index: 3;
  outline: 2px solid var(--text);
  outline-offset: 1px;
  box-shadow: 0 0 0 1px var(--panel-strong), inset 0 -2px 4px rgba(15, 31, 77, 0.07);
}

body.dark .tile.selected,
body.dark .tile[aria-selected="true"] {
  outline-color: #bfdbfe;
}

.tile:focus-visible {
  z-index: 4;
  outline-width: 2px;
  outline-offset: 1px;
}

.tile.locked::after {
  content: "⌁";
  position: absolute;
  right: 3px;
  bottom: 0;
  color: rgba(15, 31, 77, 0.75);
  font-size: 10px;
  font-weight: 900;
}

.tile-time,
.tile-name,
.tile-icon {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1;
}

.tile-time {
  font-size: 8px;
  font-weight: 800;
}

.tile-icon {
  font-size: 14px;
}

.tile-name {
  font-size: 8px;
  font-weight: 850;
}

@container tile-grid (max-width: 600px) {
  .tile-time,
  .tile-name {
    display: none;
  }
}

.comment-dot {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(15, 31, 77, 0.68);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  margin-top: 8px;
}

.summary-strip > .muted {
  grid-column: 1 / -1;
  margin: 0;
}

.summary-item,
.metric-card,
.analytics-panel {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--small-shadow);
}

.summary-item {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 7px;
  min-height: 0;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: none;
}

.summary-item:hover {
  transform: none;
  background: color-mix(in srgb, var(--primary) 6%, var(--panel-strong));
  border-color: var(--primary);
  box-shadow: var(--small-shadow);
}

.summary-item.active,
.summary-item[aria-pressed="true"] {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 18%, transparent);
}

.summary-swatch {
  width: 26px;
  height: 26px;
  border-radius: 6px;
}

.summary-item strong,
.summary-item span,
.summary-item b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-item span:not(.summary-swatch) {
  color: var(--muted);
  font-size: 10px;
}

.summary-bar {
  grid-column: 1 / -1;
  height: 5px;
  overflow: hidden;
  background: #e8eef7;
  border-radius: 999px;
}

body.dark .summary-bar {
  background: #25334b;
}

.summary-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.week-board {
  display: grid;
  gap: 0;
}

.week-day {
  min-width: 0;
  padding: 6px 0 8px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}

.week-day + .week-day {
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.week-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 900;
}

.week-day-header .ghost-button {
  display: none;
}

.tile-editor-panel {
  display: grid;
  gap: 6px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.compact-tile-editor-slot {
  position: relative;
  display: none;
  width: 100%;
}

.compact-editor-activity {
  display: none;
}

body.dark .tile-editor-panel {
  background: rgba(15, 23, 42, 0.58);
}

.editor-head {
  justify-content: space-between;
}

.editor-head-actions,
.editor-actions,
.entity-actions,
.group-head-row,
.archived-row {
  display: flex;
  align-items: center;
  gap: 3px;
}

.editor-head-actions {
  flex: 0 0 auto;
}

.editor-actions {
  justify-content: flex-end;
  padding-top: 1px;
}

.editor-actions button {
  flex: 1 1 0;
  min-width: 0;
}

.editor-head h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.tile-editor-panel label {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
}

.check-row {
  grid-template-columns: 15px 1fr;
  align-items: center;
  color: var(--text) !important;
  font-size: 11px !important;
}

.check-row input {
  width: 15px;
}

.empty-editor {
  padding: 9px;
  background: var(--panel-strong);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
}

.empty-editor h3 {
  margin: 0 0 3px;
  font-size: 16px;
}

.empty-editor p,
.muted {
  color: var(--muted);
}

.empty-editor p,
.analytics-panel > .muted {
  margin: 0;
}

.activity-group {
  margin-top: 4px;
}

.group-head-row {
  align-items: stretch;
}

.group-head-row .group-header {
  flex: 1 1 auto;
  min-width: 0;
}

.entity-actions {
  flex: 0 0 auto;
  align-self: center;
}

.group-header {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 5px;
  width: 100%;
  min-height: 26px;
  padding: 0 6px;
  font-size: 11px;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
}

.group-header.static {
  padding: 0 6px;
  min-height: 26px;
}

.group-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}

.activity-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px;
  margin-top: 2px;
}

.brush-tooltip {
  position: absolute;
  top: 50%;
  right: calc(100% + 8px);
  z-index: 60;
  display: grid;
  gap: 2px;
  width: max-content;
  max-width: 220px;
  padding: 7px 9px;
  color: #ffffff;
  background: #172033;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  box-shadow: 0 9px 25px rgba(15, 31, 77, 0.26);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.35;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-50%);
}

.brush-button:hover ~ .brush-tooltip,
.brush-button:focus-visible ~ .brush-tooltip {
  opacity: 1;
  visibility: visible;
}

.brush-toolbar {
  position: sticky;
  top: 4px;
  z-index: 6;
  padding: 3px;
  background: color-mix(in srgb, var(--panel-strong) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--small-shadow);
}

.brush-toolbar .brush-button {
  flex: 1 1 0;
  min-width: 0;
}

.brush-button {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 5px;
  width: 100%;
  min-height: 28px;
  padding: 2px 5px;
  font-size: 11px;
  color: var(--text);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  text-align: left;
  transition: none;
}

.brush-button:hover {
  transform: none;
  background: color-mix(in srgb, var(--primary) 7%, var(--panel-strong));
  border-color: var(--primary);
  box-shadow: none;
}

.brush-button.active,
.brush-button[aria-pressed="true"] {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 9%, var(--panel-strong));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 20%, transparent);
}

.brush-button.eraser {
  grid-template-columns: 22px 1fr;
}

.brush-button.copy-brush {
  grid-template-columns: 22px 1fr;
}

.activity-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
}

.compact-form {
  display: grid;
  grid-template-columns: 1fr 76px 30px 62px;
  gap: 3px;
  margin-top: 5px;
}

.compact-form.two {
  grid-template-columns: 1fr 30px 62px;
}

.compact-form input,
.compact-form select {
  min-width: 0;
  padding: 4px 5px;
  font-size: 11px;
}

.compact-form input[type="color"] {
  padding: 2px;
}

.compact-form button {
  min-height: 28px;
  padding: 0 5px;
  font-size: 10px;
}

.palette {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
  margin-top: 5px;
}

.palette span,
.palette button {
  width: 100%;
  height: 16px;
  min-height: 16px;
  padding: 0;
  background: var(--palette-color);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.56);
}

.palette button[aria-pressed="true"],
.palette button.active {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.palette button:hover {
  transform: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--palette-color) 45%, var(--panel-strong));
}

.dialog-field-label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.color-presets {
  display: grid;
  grid-template-columns: repeat(13, minmax(0, 1fr));
  gap: 2px;
}

.color-presets button {
  width: 100%;
  min-width: 0;
  height: 21px;
  min-height: 21px;
  padding: 0;
  background: var(--preset-color);
  border: 1px solid color-mix(in srgb, var(--preset-color) 65%, var(--line-strong));
  border-radius: 3px;
}

.color-presets button:hover {
  transform: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72), 0 0 0 1px var(--text);
}

.color-presets button.active,
.color-presets button[aria-pressed="true"] {
  border: 3px solid var(--focus-ring);
  box-shadow: inset 0 0 0 1px var(--panel-strong);
  outline: 0;
}

.symbol-presets {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 3px;
  margin-top: 4px;
}

.symbol-presets button {
  min-width: 0;
  min-height: 28px;
  padding: 0 3px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
}

.symbol-presets button:hover {
  transform: none;
  border-color: var(--primary);
  box-shadow: none;
}

.symbol-presets button.active,
.symbol-presets button[aria-pressed="true"] {
  color: #ffffff;
  background: var(--primary-strong);
  border-color: var(--primary-strong);
}

.group-header[aria-expanded="true"] {
  background: color-mix(in srgb, var(--primary) 7%, transparent);
}

.group-header[aria-expanded="false"] {
  color: var(--muted);
}

.activity-archive {
  margin-top: 5px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.activity-archive summary {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}

.archived-row {
  justify-content: space-between;
  min-width: 0;
  padding: 2px 0;
}

.archived-row span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archived-row .ghost-button {
  flex: 0 0 auto;
  min-height: 23px;
  font-size: 10px;
}

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

.metric-card {
  padding: 9px;
}

.metric-card span {
  color: var(--muted);
  font-weight: 800;
}

.metric-card strong {
  display: block;
  margin: 3px 0;
  font-size: 21px;
  letter-spacing: 0;
}

.metric-card p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.analytics-panel {
  padding: 9px;
  min-width: 0;
}

.analytics-panel.wide {
  grid-column: span 2;
}

.analytics-panel h3 {
  margin: 0 0 7px;
  font-size: 15px;
  letter-spacing: 0;
}

.pie-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px;
  align-items: center;
}

.pie {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 6px solid var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
}

.legend-list,
.bar-list,
.weekly-stack,
.goal-list {
  display: grid;
  gap: 5px;
}

.legend-item {
  display: grid;
  grid-template-columns: 9px 1fr auto;
  gap: 5px;
  align-items: center;
  min-width: 0;
}

.legend-item span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.legend-item b,
.legend-item em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-item em {
  color: var(--muted);
  font-style: normal;
  font-size: 10px;
}

.bar-line,
.stack-row,
.goal-row {
  display: grid;
  grid-template-columns: 86px 1fr 56px;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.bar-line span,
.stack-row span,
.goal-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 750;
}

.bar-line div,
.stack-row div,
.goal-row div {
  display: flex;
  height: 8px;
  overflow: hidden;
  background: #e8eef7;
  border-radius: 999px;
}

body.dark .bar-line div,
body.dark .stack-row div,
body.dark .goal-row div {
  background: #25334b;
}

.bar-line i,
.stack-row i,
.goal-row i {
  display: block;
  height: 100%;
}

.bar-line b,
.stack-row b,
.goal-row b {
  color: var(--muted);
  text-align: right;
  font-size: 10px;
}

.goal-row i {
  background: var(--primary);
  border-radius: inherit;
}

.goal-row b.ok {
  color: var(--ok);
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(7, minmax(32px, 1fr));
  gap: 3px;
}

.heat-cell {
  min-height: 27px;
  padding: 0;
  color: var(--text);
  background: color-mix(in srgb, #2f7df6 var(--heat), #edf3fb);
  border: 1px solid var(--line);
}

body.dark .heat-cell {
  background: color-mix(in srgb, #60a5fa var(--heat), #1e293b);
}

.command-dialog {
  width: min(420px, calc(100vw - 16px));
  padding: 0;
  color: var(--text);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.command-dialog::backdrop {
  background: rgba(15, 23, 42, 0.34);
}

.command-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}

.command-list {
  display: grid;
  gap: 3px;
  padding: 7px;
}

.command-list button {
  justify-content: start;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  text-align: left;
}

.form-dialog form {
  margin: 0;
}

.form-dialog .dialog-body {
  display: grid;
  gap: 6px;
  padding: 8px;
}

.form-dialog .dialog-body label {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.form-dialog footer {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 8px;
  border-top: 1px solid var(--line);
}

.dialog-spacer {
  flex: 1 1 auto;
}

.inline-message {
  margin: 0;
  padding: 5px 7px;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.inline-message[hidden] {
  display: none;
}

.toast-stack {
  position: fixed;
  right: 10px;
  bottom: 10px;
  z-index: 30;
  display: grid;
  gap: 5px;
}

.toast {
  max-width: min(360px, calc(100vw - 32px));
  padding: 8px 10px;
  color: #ffffff;
  background: #0f1f4d;
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-weight: 750;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.hide {
  opacity: 0;
  transform: translateY(8px);
}

.share-page-root {
  background: #ffffff;
}

body.share-page {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --text: #0f1f4d;
  --muted: #5d6b8c;
  --line: #dce4f2;
  --line-strong: #c7d2e7;
  --tile-empty: #edf3fb;
  background: #ffffff;
}

.share-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 8px;
}

.share-main {
  min-width: 0;
}

.share-main-header {
  align-items: baseline;
  margin-bottom: 6px;
}

.share-main-header h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 750;
  line-height: 1.2;
}

.share-page .time-note {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 9px;
  font-weight: 650;
}

.share-board {
  display: grid;
  gap: 8px;
}

.mobile-toolbar,
.mobile-panel-toggle,
.mobile-drawer-close {
  display: none;
}

@media (min-width: 961px) {
  .side-panel {
    position: sticky;
    top: 8px;
    align-self: start;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  .right-panel .brush-tooltip {
    top: 50%;
    right: 0;
    left: auto;
    width: max-content;
    max-width: calc(100% - 8px);
    transform: translateY(-50%);
  }
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .right-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 260px 1fr;
    align-items: start;
  }

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

@media (min-width: 961px) and (max-width: 1200px) {
  .board-wrap,
  .week-day {
    padding-right: 0;
    padding-left: 0;
  }

  .grid-with-rail,
  .week-grid-wrap {
    grid-template-columns: 30px repeat(12, minmax(0, var(--tile-display-size)));
    gap: var(--tile-gap);
  }

  .rail-label {
    font-size: 9px;
  }

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

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

  .period-nav input {
    grid-column: 1 / -1;
    grid-row: 1;
    min-width: 0;
    width: 100%;
  }

  .period-nav button {
    width: 100%;
  }

  .compact-form,
  .compact-form.two {
    grid-template-columns: minmax(0, 1fr) 30px;
  }

  .compact-form input[name="name"] {
    grid-column: 1;
    grid-row: 1;
  }

  .compact-form input[type="color"] {
    grid-column: 2;
    grid-row: 1;
  }

  .compact-form select {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .compact-form button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    min-height: 100vh;
    padding: 6px 6px calc(48px + env(safe-area-inset-bottom));
  }

  .main-panel {
    order: 0;
    backdrop-filter: none;
  }

  .left-panel,
  .right-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .brand,
  .sync-section {
    grid-column: 1 / -1;
  }

  .right-panel {
    grid-template-columns: 1fr;
  }

  .mobile-toolbar {
    position: fixed;
    right: 6px;
    bottom: max(6px, env(safe-area-inset-bottom));
    left: 6px;
    z-index: 50;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 3px;
    padding: 3px;
    background: color-mix(in srgb, var(--panel-strong) 96%, transparent);
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    box-shadow: 0 7px 22px rgba(15, 31, 77, 0.2);
    backdrop-filter: blur(16px);
  }

  .mobile-toolbar.is-inline-for-editor {
    position: relative;
    inset: auto;
    z-index: auto;
    margin-top: 10px;
  }

  .mobile-panel-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 0;
    min-height: 34px;
    padding: 0 7px;
    overflow: hidden;
    color: var(--text);
    background: transparent;
    border: 1px solid transparent;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #mobileBrushLabel {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-panel-toggle.active,
  .mobile-panel-toggle[aria-pressed="true"],
  .mobile-panel-toggle[aria-expanded="true"] {
    color: #ffffff;
    background: var(--primary-strong);
    border-color: transparent;
    box-shadow: none;
  }

  .mobile-drawer {
    position: fixed;
    right: 6px;
    bottom: calc(48px + env(safe-area-inset-bottom));
    left: 6px;
    z-index: 40;
    display: flex;
    width: auto;
    max-height: 72vh;
    max-height: 72dvh;
    min-height: 0;
    padding: 8px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: color-mix(in srgb, var(--panel-strong) 97%, transparent);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    box-shadow: 0 12px 38px rgba(15, 31, 77, 0.28);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(calc(100% + 58px));
    transition: opacity 160ms ease, transform 180ms ease, visibility 0s linear 180ms;
  }

  .mobile-drawer.is-open,
  .mobile-drawer[data-open="true"],
  .mobile-drawer[aria-hidden="false"],
  body.mobile-left-open .mobile-drawer-left,
  body.mobile-right-open .mobile-drawer-right {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
    transition-delay: 0s;
  }

  .mobile-drawer[hidden] {
    display: none;
  }

  body:has(.mobile-drawer.is-open)::before,
  body:has(.mobile-drawer[data-open="true"])::before,
  body:has(.mobile-drawer[aria-hidden="false"])::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(15, 23, 42, 0.2);
    pointer-events: none;
  }

  .mobile-drawer-close {
    position: sticky;
    top: 0;
    z-index: 8;
    display: inline-grid;
    place-items: center;
    align-self: flex-end;
    flex: 0 0 auto;
    width: 26px;
    min-width: 26px;
    height: 26px;
    min-height: 26px;
    margin: -3px -3px 0 auto;
    padding: 0;
    color: var(--text);
    background: var(--panel-strong);
    border: 1px solid var(--line);
    border-radius: 50%;
  }

  .mobile-drawer-right .brush-toolbar {
    top: 0;
  }

  .mobile-drawer-right .activity-row:has(.brush-button.active),
  .mobile-drawer-right .activity-row:has(.brush-button[aria-pressed="true"]) {
    position: sticky;
    top: 35px;
    z-index: 5;
    padding: 2px 0;
    background: var(--panel-strong);
  }

  .mobile-drawer-right .brush-tooltip {
    top: calc(100% + 4px);
    right: auto;
    left: 0;
    transform: none;
  }

  .board-wrap {
    min-height: 0;
    padding: 0;
  }

  .grid-with-rail {
    grid-template-columns: 30px repeat(12, minmax(0, var(--tile-display-size)));
    gap: var(--tile-gap);
  }

  .week-day {
    padding: 5px 0 7px;
  }

  .summary-strip {
    display: none;
  }

  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .analytics-panel.wide {
    grid-column: auto;
  }
}

@media (max-width: 900px) and (orientation: portrait) {
  .compact-tile-editor-slot.is-measuring,
  .compact-tile-editor-slot.is-visible {
    display: block;
    width: min(560px, 100%);
    margin-right: auto;
    margin-left: auto;
  }

  .compact-tile-editor-slot.is-measuring {
    height: 0;
    margin-top: 0;
    visibility: hidden;
    pointer-events: none;
  }

  .compact-tile-editor-slot.is-measuring > #tileEditor {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
  }

  .compact-tile-editor-slot.is-visible {
    margin-top: 10px;
  }

  .compact-tile-editor-slot .tile-editor-panel {
    gap: 5px;
    padding: 8px 10px;
    background: color-mix(in srgb, var(--panel-strong) 94%, transparent);
    border-color: var(--line-strong);
    border-radius: 10px;
    box-shadow: var(--small-shadow);
  }

  .compact-tile-editor-slot .editor-head {
    align-items: center;
  }

  .compact-tile-editor-slot .editor-head .eyebrow,
  .compact-tile-editor-slot .date-chip,
  .compact-tile-editor-slot .editor-activity-field,
  .compact-tile-editor-slot .editor-lock-field {
    display: none;
  }

  .compact-tile-editor-slot .editor-head h3 {
    font-size: 16px;
    line-height: 1.05;
  }

  .compact-tile-editor-slot .compact-editor-activity {
    display: block;
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
  }

  .compact-tile-editor-slot .editor-comment-field {
    gap: 2px;
  }

  .compact-tile-editor-slot textarea {
    height: 46px;
    min-height: 46px;
    max-height: 46px;
    resize: none;
  }

  .compact-tile-editor-slot .editor-actions button {
    min-height: 30px;
  }
}

@media (max-width: 620px) {
  .left-panel,
  .right-panel {
    grid-template-columns: 1fr;
  }

  .main-panel,
  .side-panel {
    padding: 7px;
  }

  .brand h1 {
    font-size: 21px;
  }

  .view-tabs {
    position: sticky;
    top: 4px;
    z-index: 10;
    margin-bottom: 6px;
  }

  .main-header {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
  }

  .time-note {
    margin-top: 0;
  }

  .rail-label {
    font-size: 9px;
  }

  .tile-name,
  .tile-time,
  .tile-icon {
    display: none;
  }

  .compact-form,
  .compact-form.two {
    grid-template-columns: 1fr 30px;
  }

  .compact-form select,
  .compact-form button {
    grid-column: 1 / -1;
  }

  .pie-row,
  .bar-line,
  .stack-row,
  .goal-row {
    grid-template-columns: 1fr;
  }

  .bar-line b,
  .stack-row b,
  .goal-row b {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
