:root {
  color-scheme: light dark;
  --bg: #f1f3f4;
  --layer-shell: #ffffff;
  --layer-sidebar: #f8f9fa;
  --layer-toolbar: #ffffff;
  --layer-canvas: #ffffff;
  --layer-grid-head: #f8f9fa;
  --layer-builder-base: #edf1f7;
  --layer-builder-card: #ffffff;
  --layer-builder-inset: #f8f9fa;
  --event-radius: 4px;
  --time-rail-width: 52px;
  --hour-height: 92px;
  --visible-hours: 8;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --text: #202124;
  --muted: #5f6368;
  --border: #dadce0;
  --border-soft: #eceff1;
  --primary: #1a73e8;
  --primary-hover: #1557b0;
  --success: #188038;
  --danger: #d93025;
  --segment-fill: rgba(255, 255, 255, 0.62);
  --segment-border: rgba(95, 99, 104, 0.35);
  --shadow: 0 1px 2px rgba(60, 64, 67, 0.25), 0 1px 3px rgba(60, 64, 67, 0.15);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #202124;
    --layer-shell: #1f1f1f;
    --layer-sidebar: #171717;
    --layer-toolbar: #1f1f1f;
    --layer-canvas: #111316;
    --layer-grid-head: #1b1d21;
    --layer-builder-base: #181b20;
    --layer-builder-card: #22262b;
    --layer-builder-inset: #1a1d22;
    --surface: #202124;
    --surface-2: #2b2d31;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --border: #3c4043;
    --border-soft: #2a2d31;
    --primary: #8ab4f8;
    --primary-hover: #a8c7fa;
    --success: #81c995;
    --danger: #f28b82;
    --segment-fill: rgba(0, 0, 0, 0.28);
    --segment-border: rgba(255, 255, 255, 0.16);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Google Sans", "Segoe UI", "Helvetica Neue", sans-serif;
  line-height: 1.45;
  overflow: hidden;
}

.layout {
  width: 100%;
  height: 100vh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hero {
  padding: 16px 20px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--layer-shell);
}

.hero h1 {
  margin: 0 0 6px;
  font-size: clamp(1.35rem, 2.4vw, 1.9rem);
}

.hero p {
  margin: 0 0 10px;
  color: var(--muted);
}

.notice {
  min-height: 32px;
  border-radius: var(--event-radius);
  padding: 7px 12px;
  font-weight: 600;
}

.notice.ok {
  background: rgba(24, 128, 56, 0.16);
  color: var(--success);
}

.notice.error {
  background: rgba(217, 48, 37, 0.16);
  color: var(--danger);
}

.tabs {
  display: flex;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--layer-shell);
}

.tab {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--event-radius);
  padding: 9px 15px;
  font: inherit;
  cursor: pointer;
}

.tab.is-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.tab-panel {
  display: none;
  min-height: 0;
}

.tab-panel.is-active {
  display: block;
  flex: 1;
  min-height: 0;
}

#schedule-tab {
  padding: 0;
}

#builder-tab,
#telegram-tab {
  padding: 20px;
  overflow: auto;
}

#builder-tab {
  align-items: center;
  background: var(--layer-builder-base);
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.08);
}

#builder-tab .grid {
  width: min(980px, 100%);
}

#builder-tab.tab-panel.is-active {
  display: flex;
  flex-direction: column;
}

#builder-tab .panel {
  background: var(--layer-builder-card);
  border-color: var(--border);
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.2), 0 2px 6px rgba(60, 64, 67, 0.12);
}

#builder-tab .panel-head {
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 10px;
  margin-bottom: 12px;
}

#builder-tab .template-item {
  background: var(--layer-builder-inset);
}

#builder-tab .routine-dropzone {
  background: var(--layer-builder-inset);
  border-color: var(--border);
  box-shadow: inset 0 1px 2px rgba(60, 64, 67, 0.08);
}

#builder-tab .routine-dropzone.drag-hover {
  box-shadow: inset 0 1px 2px rgba(26, 115, 232, 0.18);
}

.schedule-layout {
  height: 100%;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 0;
}

.schedule-sidebar {
  height: 100%;
  overflow: auto;
  padding: 20px;
  background: var(--layer-sidebar);
  border-right: 1px solid var(--border);
}

.schedule-sidebar h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.schedule-sidebar h3 {
  margin: 18px 0 10px;
  font-size: 0.92rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.schedule-main {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.week-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--layer-toolbar);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
}

.week-label {
  font-size: 1.08rem;
  font-weight: 600;
}

.calendar-panel {
  min-height: 0;
  background: var(--layer-canvas);
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.14);
  display: flex;
  flex-direction: column;
}

.week-calendar {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.week-scroll {
  min-width: 0;
}

.week-head,
.week-body {
  display: grid;
  grid-template-columns: var(--time-rail-width) repeat(7, minmax(0, 1fr));
}

.week-head {
  position: sticky;
  top: 0;
  z-index: 8;
  background: var(--layer-grid-head);
}

.time-head,
.day-head {
  position: relative;
  z-index: 1;
  background: var(--layer-grid-head);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 10px 8px;
  font-size: 0.95rem;
}

.day-head.is-past {
  color: var(--muted);
  opacity: 0.68;
}

.day-head.is-today {
  font-weight: 700;
}

.time-head {
  z-index: 2;
  padding-left: 4px;
  padding-right: 4px;
}

.week-body {
  position: relative;
}

.time-rail {
  position: sticky;
  left: 0;
  background: var(--layer-grid-head);
  border-right: 1px solid var(--border);
  z-index: 2;
}

.time-label {
  position: absolute;
  right: 4px;
  transform: translateY(-50%);
  font-size: 1.02rem;
  font-weight: 400;
  color: var(--muted);
  white-space: nowrap;
}

.day-track {
  position: relative;
  border-right: 1px solid var(--border);
  background: var(--layer-canvas);
  min-width: 0;
}

.day-track.is-locked {
  cursor: not-allowed;
}

.day-track.drag-hover {
  background: rgba(26, 115, 232, 0.08);
}

.day-track.invalid-drop {
  background: rgba(217, 48, 37, 0.1);
}

.calendar-drop-indicator {
  position: absolute;
  left: 6px;
  right: 6px;
  border-radius: var(--event-radius);
  border: 2px dashed rgba(26, 115, 232, 0.92);
  background: rgba(26, 115, 232, 0.14);
  box-sizing: border-box;
  pointer-events: none;
  z-index: 6;
}

.calendar-drop-indicator::after {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-bottom: 3px solid rgba(26, 115, 232, 0.98);
  border-bottom-left-radius: var(--event-radius);
  border-bottom-right-radius: var(--event-radius);
}

.day-track.drop-invalid .calendar-drop-indicator {
  border-color: rgba(217, 48, 37, 0.92);
  background: rgba(217, 48, 37, 0.14);
}

.day-track.drop-invalid .calendar-drop-indicator::after {
  border-bottom-color: rgba(217, 48, 37, 0.98);
}

.past-mask {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  background: rgba(95, 99, 104, 0.22);
  border-bottom: 1px solid var(--border);
  pointer-events: none;
  z-index: 4;
}

@media (prefers-color-scheme: dark) {
  .past-mask {
    background: rgba(0, 0, 0, 0.36);
  }
}

.hour-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid var(--border-soft);
  pointer-events: none;
}

.scheduled-block {
  position: absolute;
  left: 6px;
  right: 6px;
  border-radius: var(--event-radius);
  background: var(--item-fill, rgba(138, 180, 248, 0.2));
  border: 1px solid var(--item-accent, var(--primary));
  border-left-width: 4px;
  padding: 6px 8px;
  display: grid;
  gap: 2px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  cursor: grab;
}

.scheduled-block:active {
  cursor: grabbing;
}

.scheduled-block.is-dragging {
  opacity: 0.55;
}

.scheduled-title {
  font-size: 0.98rem;
  line-height: 1.3;
  padding-right: 0;
}

.scheduled-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.scheduled-title-inline {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scheduled-title-duration {
  flex: 0 0 auto;
  white-space: nowrap;
}

.scheduled-meta {
  font-size: 0.86rem;
  color: var(--muted);
}

.scheduled-routine-step-list {
  display: grid;
  gap: 2px;
  margin-top: 2px;
}

.scheduled-routine-step {
  font-size: 0.84rem;
  line-height: 1.35;
  color: var(--muted);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.scheduled-routine-step-label {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scheduled-routine-step-duration {
  flex: 0 0 auto;
  font-size: 0.76rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.draggable-list {
  display: grid;
  gap: 12px;
}

.drag-card {
  border: 1px solid var(--item-accent, var(--border));
  border-radius: var(--event-radius);
  background: var(--item-fill, var(--surface-2));
  padding: 12px;
  cursor: grab;
  box-shadow: var(--shadow);
}

.drag-card.is-dragging {
  opacity: 0.45;
}

.grid {
  display: grid;
  gap: 20px;
  margin-bottom: 20px;
}

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

.full-span {
  grid-column: 1 / -1;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--event-radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1.06rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.stack {
  display: grid;
  gap: 14px;
}

.compact-form {
  margin-bottom: 12px;
}

.inline-grid {
  display: grid;
  gap: 10px;
}

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

label {
  display: grid;
  gap: 6px;
  font-size: 0.95rem;
}

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

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 10px 11px;
  border-radius: var(--event-radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

button {
  border: 1px solid transparent;
  border-radius: var(--event-radius);
  padding: 9px 12px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: var(--primary-hover);
}

.icon-button {
  width: 32px;
  height: 32px;
  border-radius: var(--event-radius);
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.plus-button {
  font-size: 0;
  background: transparent !important;
  border: 0 !important;
  color: #fff;
  box-shadow: none;
}

.plus-button:hover {
  background: transparent !important;
  color: #fff;
  opacity: 0.88;
}

.plus-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 500;
  line-height: 1;
  transform: translateY(-1px);
}

.close-button {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.close-button:hover {
  background: var(--surface-2);
}

button.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

button.danger:hover {
  background: rgba(217, 48, 37, 0.1);
}

.icon-delete-button {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  border: 0 !important;
  background: transparent !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--danger);
  line-height: 1;
}

.icon-delete-button .trash-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.icon-save-button {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.icon-save-button .floppy-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.icon-edit-button {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  border: 0 !important;
  background: transparent !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  line-height: 1;
}

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

.icon-edit-button .pencil-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.icon-duplicate-button {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  border: 0 !important;
  background: transparent !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  line-height: 1;
}

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

.icon-duplicate-button .duplicate-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stack > .button-row {
  width: 100%;
}

.stack > .button-row > :is(.icon-save-button, .icon-delete-button) {
  order: 2;
}

.stack > .button-row > :not(.icon-save-button):not(.icon-delete-button) {
  order: 1;
}

.stack > .button-row > .icon-save-button {
  margin-left: auto;
}

.stack > .button-row > .icon-delete-button:first-child,
.stack > .button-row > :not(.icon-save-button):not(.icon-delete-button) + .icon-delete-button:last-child {
  margin-left: auto;
}

.stack > :is(.icon-save-button, .icon-delete-button) {
  justify-self: end;
}

.fieldset p {
  margin: 0 0 8px;
  color: var(--muted);
}

.routine-composer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.routine-dropzone {
  margin-top: 6px;
  min-height: 168px;
  border: 1px dashed var(--border);
  border-radius: var(--event-radius);
  background: var(--surface-2);
  padding: 10px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.routine-dropzone.drag-hover {
  border-color: var(--primary);
  background: rgba(26, 115, 232, 0.08);
}

.routine-item {
  border: 1px solid var(--item-accent, var(--border));
  border-radius: var(--event-radius);
  background: var(--item-fill, var(--surface));
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow);
}

.routine-item.is-dragging {
  opacity: 0.45;
}

.routine-item-name {
  font-size: 0.9rem;
  font-weight: 600;
  flex: 1 1 auto;
  min-width: 0;
}

.run-step-duration-field {
  display: grid;
  gap: 4px;
  min-width: 112px;
  max-width: 132px;
  margin: 0;
}

.run-step-duration-field .meta {
  line-height: 1;
}

.run-step-duration-input {
  width: 100%;
  padding: 5px 6px;
}

.run-editor-toolbar {
  margin-top: 6px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.run-step-control-button {
  width: 30px;
  min-width: 30px;
  height: 30px;
  border: 0 !important;
  background: transparent !important;
  color: var(--text);
  box-shadow: none;
}

.run-step-control-button:hover {
  color: var(--primary);
  background: transparent !important;
}

.run-step-control-button:disabled {
  color: var(--muted);
  opacity: 0.45;
  cursor: not-allowed;
}

.run-step-remove-button {
  color: var(--danger);
}

.run-step-remove-button:hover:not(:disabled) {
  color: var(--danger);
}

.run-add-step-dropdown {
  position: absolute;
  top: 34px;
  left: 0;
  z-index: 6;
  min-width: 220px;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--event-radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 6px;
  display: grid;
  gap: 4px;
}

.run-add-step-dropdown[hidden] {
  display: none !important;
}

.run-add-step-option {
  border: 0 !important;
  background: transparent !important;
  color: var(--text);
  text-align: left;
  padding: 7px 8px;
  border-radius: var(--event-radius);
}

.run-add-step-option:hover {
  background: var(--surface-2) !important;
}

#run-step-sequence .routine-item {
  cursor: pointer;
}

#run-step-sequence .routine-item.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), var(--shadow);
}

.grabber {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: grab;
  user-select: none;
  flex: 0 0 auto;
}

.ghost-button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 8px;
}

.ghost-button:hover {
  background: var(--surface);
}

.routine-item .danger:not(.icon-delete-button) {
  padding: 5px 8px;
}

.chips,
.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--border);
  border-radius: var(--event-radius);
  background: var(--surface-2);
  padding: 6px 10px;
  font-size: 0.88rem;
}

.list {
  display: grid;
  gap: 12px;
}

.list.empty {
  color: var(--muted);
  font-style: italic;
}

.address-item {
  border: 1px solid var(--border);
  border-radius: var(--event-radius);
  background: var(--surface);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.address-item-main {
  min-width: 0;
}

.address-item-main .meta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-item {
  border: 1px solid var(--border);
  border-radius: var(--event-radius);
  background: var(--surface);
  padding: 12px;
}

.template-item header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.title-with-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  position: relative;
}

.title-with-dot strong {
  min-width: 0;
}

.template-kind {
  font-size: 0.74rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.template-summary {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--item-accent, var(--primary));
}

.color-dot-button {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: var(--event-radius);
  background: transparent;
  padding: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.color-dot-button:hover {
  background: var(--surface-2);
}

.color-dot-button .color-dot {
  pointer-events: none;
}

.color-swatch-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-width: 116px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--event-radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.color-swatch-popover[hidden] {
  display: none !important;
}

.color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
  margin: 0;
  cursor: pointer;
  background: var(--swatch-color);
}

.color-swatch:hover {
  transform: scale(1.08);
}

.color-swatch.is-selected {
  border-color: var(--text);
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(32, 33, 36, 0.44);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-shell[hidden] {
  display: none !important;
}

.modal-panel {
  width: min(560px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--event-radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
}

.modal-panel.wide {
  width: min(860px, 100%);
}

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

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

.travel-mode-field {
  grid-column: 1 / -1;
}

.template-driving-fields > .inline-field {
  min-width: 0;
}

.template-driving-fields > .inline-field:last-child {
  grid-column: 1 / -1;
  max-width: 220px;
}

.travel-mode-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.travel-mode-button {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 5px 9px;
}

.travel-mode-button:hover {
  background: var(--surface);
}

.travel-mode-button.is-selected {
  border-color: var(--item-accent, var(--primary));
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--item-accent, var(--primary));
}

.address-locker {
  display: grid;
  gap: 6px;
}

.address-lock-editor {
  display: grid;
  gap: 6px;
}

.notification-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.notification-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--event-radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.82rem;
}

.notification-chip.is-base {
  border-style: dashed;
}

.notification-chip-remove {
  width: 16px;
  min-width: 16px;
  height: 16px;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.notification-chip-remove .trash-icon {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.notification-chip-remove:hover {
  color: var(--text);
}

.notification-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.notification-input-row input {
  flex: 1 1 auto;
  min-width: 0;
}

.address-lock-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--event-radius);
  background: var(--surface-2);
}

.address-lock-chip span {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.address-clear-button {
  flex: 0 0 auto;
  margin-left: auto;
}

.address-clear-button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 4px 8px;
}

.address-clear-button:hover {
  background: var(--surface);
}

.inline-field {
  display: grid;
  gap: 5px;
  font-size: 0.82rem;
  color: var(--muted);
}

.inline-field input {
  padding: 8px 9px;
  font-size: 0.9rem;
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
}

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

code {
  padding: 2px 6px;
  border-radius: var(--event-radius);
  background: var(--surface-2);
}

@media (max-width: 1180px) {
  .schedule-layout {
    grid-template-columns: 280px minmax(0, 1fr);
  }
}

@media (max-width: 980px) {
  .two-col {
    grid-template-columns: 1fr;
  }

  .inline-grid.two-up {
    grid-template-columns: 1fr;
  }

  .routine-composer-grid {
    grid-template-columns: 1fr;
  }

  .template-edit-row {
    grid-template-columns: 1fr;
  }

  .template-driving-fields {
    grid-template-columns: 1fr;
  }

  #builder-tab,
  #telegram-tab {
    padding: 14px;
  }
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .layout {
    min-height: auto;
  }

  .tab-panel.is-active {
    flex: initial;
  }

  .schedule-layout {
    grid-template-columns: 1fr;
  }

  .schedule-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    max-height: 40vh;
  }

  .week-head,
  .week-body {
    grid-template-columns: 64px repeat(7, minmax(120px, 1fr));
  }

  .week-calendar {
    overflow-x: auto;
  }
}
