.habits-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
}

.habits-plus-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.segment-tone-morning {
  background: linear-gradient(180deg, #fbfefc 0%, #f7fcf8 100%);
  border: 1px solid #edf7ef;
}

.segment-tone-day {
  background: linear-gradient(180deg, #f8fdf9 0%, #f1faf3 100%);
  border: 1px solid #e7f3ea;
}

.segment-tone-evening {
  background: linear-gradient(180deg, #f6fcf7 0%, #eef8f0 100%);
  border: 1px solid #e1efe5;
}

.segment-tone-general {
  background: linear-gradient(180deg, #f3fbf5 0%, #ebf7ee 100%);
  border: 1px solid #dceee2;
}

.segment-tone-minus {
  background: linear-gradient(180deg, #fff1f4 0%, #ffe8ec 100%);
  border: 1px solid #efc7d0;
}

.habit-segment-card,
.add-habit-form {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.habit-calibration-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 16px;
  padding: 18px;
  border-radius: 24px;
  border: 1px solid rgba(186, 151, 74, 0.22);
  background:
    radial-gradient(circle at top right, rgba(64, 177, 105, 0.15), transparent 34%),
    radial-gradient(circle at bottom left, rgba(202, 166, 75, 0.18), transparent 38%),
    linear-gradient(180deg, rgba(255, 253, 247, 0.98), rgba(250, 241, 222, 0.94));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.78),
    0 18px 38px rgba(82, 60, 16, 0.08);
}

.habit-calibration-card[data-state="ready"] {
  border-color: rgba(34, 153, 93, 0.26);
}

.habit-calibration-card[data-state="locked"] {
  background:
    radial-gradient(circle at top right, rgba(202, 166, 75, 0.12), transparent 34%),
    linear-gradient(180deg, rgba(255, 253, 247, 0.96), rgba(248, 242, 230, 0.94));
}

.habit-calibration-copy {
  display: grid;
  gap: 8px;
  align-content: start;
}

.habit-calibration-kicker {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(186, 151, 74, 0.18);
  background: rgba(255, 255, 255, 0.72);
  color: #785b1f;
  font-size: 10px;
  line-height: 1.2;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.habit-calibration-copy h3 {
  margin: 0;
  color: var(--text);
  font-size: clamp(18px, 2.6vw, 24px);
  line-height: 1.08;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.habit-calibration-copy p {
  margin: 0;
  max-width: 680px;
  color: #6d5a36;
  font-size: 13px;
  line-height: 1.58;
}

.habit-calibration-side {
  display: grid;
  gap: 10px;
  align-content: center;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid rgba(186, 151, 74, 0.16);
  background: rgba(255, 255, 255, 0.66);
}

.habit-calibration-meter {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(186, 151, 74, 0.16);
  background: rgba(255, 250, 238, 0.88);
  color: #6b5220;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 800;
  text-align: center;
}

.habit-calibration-card[data-state="ready"] .habit-calibration-meter {
  border-color: rgba(34, 153, 93, 0.22);
  background: rgba(231, 248, 236, 0.88);
  color: #0f7a54;
}

.habit-calibration-btn {
  width: 100%;
  min-height: 44px;
}

.habit-calibration-status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
}

.habit-segment-title {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 12px;
}

.habit-segment-list {
  min-height: 58px;
  border: 1px dashed transparent;
  border-radius: 12px;
}

.habit-segment-list.drag-over {
  border-color: var(--blue);
  background: rgba(37,99,235,.04);
}

.habit-manage-empty {
  font-size: 14px;
  padding: 12px 0;
}

.habit-manage-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  background: rgba(255,255,255,.72);
  border-radius: 12px;
  margin-bottom: 10px;
  position: relative;
  width: 100%;
  border: 1px solid rgba(229,231,235,.8);
}

.habit-manage-item.dragging {
  opacity: .45;
}

.habit-drag-handle {
  width: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 18px;
  flex-shrink: 0;
}

.habit-type-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 8px;
}

.habit-type-dot.plus { background: var(--green); }
.habit-type-dot.minus { background: var(--red); }

.habit-manage-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 4px;
}

.habit-manage-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.habit-manage-name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
}

.habit-manage-focus-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.22);
  color: #0f7a54;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.habit-manage-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.habit-manage-desc {
  font-size: 12px;
  line-height: 1.45;
  color: rgba(92, 103, 123, 0.95);
  word-break: break-word;
}

.habit-manage-controls {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
  min-width: 0;
}

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

.habit-mobile-actions {
  display: none;
  width: 100%;
  margin-top: 8px;
  gap: 4px;
  flex-wrap: nowrap;
  overflow: hidden;
  align-items: center;
  min-width: 0;
}

.habit-mobile-actions button {
  border: 1px solid var(--border);
  background: white;
  border-radius: 8px;
  padding: 5px 6px;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  flex: 1 1 0;
  min-width: 0;
}

.habit-manage-weight {
  width: 58px;
  padding: 8px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  text-align: center;
  background: white;
  flex-shrink: 0;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1.5px solid var(--border);
  background: white;
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.add-habit-form {
  background: linear-gradient(180deg, #fffdf8 0%, #fffaf0 100%);
  border: 1px solid #f2e5c4;
}

.add-habit-form .form-group input[type="text"] {
  width: 100%;
}

.add-habit-form h3 {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 16px;
}

.type-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.type-btn {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.type-btn.plus.active { background: var(--green-light); border-color: var(--green); color: #14532d; }
.type-btn.minus.active { background: var(--red-light); border-color: var(--red); color: #7f1d1d; }

.habit-focus-field {
  margin: 2px 0 16px;
}

.habit-focus-control {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 15px;
  border-radius: 18px;
  border: 1px solid rgba(186, 151, 74, 0.18);
  background:
    radial-gradient(circle at top right, rgba(255, 232, 176, 0.30), transparent 38%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(255, 249, 236, 0.92) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.82),
    0 10px 22px rgba(82, 60, 16, 0.05);
  cursor: pointer;
  transition:
    transform .18s ease,
    border-color .18s ease,
    box-shadow .18s ease,
    background .18s ease;
}

.habit-focus-control input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.habit-focus-control:hover {
  transform: translateY(-1px);
  border-color: rgba(186, 151, 74, 0.28);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.88),
    0 16px 28px rgba(82, 60, 16, 0.08);
}

.habit-focus-control:focus-within {
  border-color: rgba(22, 163, 74, 0.34);
  box-shadow:
    0 0 0 4px rgba(22, 163, 74, 0.08),
    0 16px 28px rgba(82, 60, 16, 0.08);
}

.habit-focus-control.is-disabled {
  cursor: not-allowed;
  border-color: rgba(176, 155, 116, 0.14);
  background:
    radial-gradient(circle at top right, rgba(255, 232, 176, 0.12), transparent 38%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(248, 244, 236, 0.9) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.82),
    0 8px 18px rgba(82, 60, 16, 0.03);
}

.habit-focus-control.is-disabled:hover {
  transform: none;
  border-color: rgba(176, 155, 116, 0.14);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.82),
    0 8px 18px rgba(82, 60, 16, 0.03);
}

.habit-focus-control.is-disabled .habit-focus-title,
.habit-focus-control.is-disabled .habit-focus-chip,
.habit-focus-control.is-disabled .habit-focus-title-icon {
  color: #9c8b67;
}

.habit-focus-mark {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1.5px solid rgba(186, 151, 74, 0.28);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 247, 225, 0.96) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    border-color .18s ease,
    background .18s ease,
    transform .18s ease,
    box-shadow .18s ease;
}

.habit-focus-mark-core {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(186, 151, 74, 0.22);
  transform: scale(0.7);
  transition:
    transform .18s ease,
    background .18s ease,
    box-shadow .18s ease;
}

.habit-focus-copy {
  display: grid;
  gap: 5px;
  min-width: 0;
  flex: 1 1 auto;
}

.habit-focus-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.habit-focus-title-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.habit-focus-title-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(245, 203, 92, 0.22) 0%, rgba(70, 182, 101, 0.16) 100%);
  color: #7a5a1c;
  font-size: 11px;
  box-shadow: 0 6px 12px rgba(120, 93, 32, 0.08);
}

.habit-focus-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}

.habit-focus-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid rgba(186, 151, 74, 0.18);
  background: rgba(255, 255, 255, 0.74);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #7a5a1c;
}

.habit-focus-note {
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.habit-focus-control input[type="checkbox"]:checked + .habit-focus-mark {
  border-color: rgba(22, 163, 74, 0.34);
  background: linear-gradient(180deg, rgba(232, 248, 236, 0.98) 0%, rgba(220, 245, 227, 0.94) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.86),
    0 8px 16px rgba(22, 163, 74, 0.12);
}

.habit-focus-control input[type="checkbox"]:checked + .habit-focus-mark .habit-focus-mark-core {
  background: #14915c;
  transform: scale(1);
  box-shadow: 0 0 0 5px rgba(20, 145, 92, 0.12);
}

.habit-focus-control input[type="checkbox"]:checked ~ .habit-focus-copy .habit-focus-title {
  color: #0f7a54;
}

.habit-focus-control input[type="checkbox"]:checked ~ .habit-focus-copy .habit-focus-chip {
  border-color: rgba(22, 163, 74, 0.24);
  background: rgba(230, 248, 236, 0.88);
  color: #0f7a54;
}

.habit-focus-control input[type="checkbox"]:checked ~ .habit-focus-copy .habit-focus-title-icon {
  background: linear-gradient(180deg, rgba(77, 190, 107, 0.22) 0%, rgba(30, 160, 89, 0.14) 100%);
  color: #0f7a54;
}

@media (max-width: 820px) {
  .habits-layout,
  .habit-calibration-card {
    grid-template-columns: 1fr;
  }

  .habit-calibration-card {
    gap: 14px;
    padding: 16px;
    border-radius: 20px;
  }

  .habit-calibration-side {
    padding: 12px;
  }
}
