.dashboard-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: var(--space-4);
}

@media (max-width: 930px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.habit-list,
.feed-list {
  display: grid;
  gap: var(--space-3);
}

.habit-item {
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  background: var(--bg-surface);
}

.habit-item h4 {
  margin: 0 0 var(--space-2);
  font-family: 'Outfit', sans-serif;
}

.habit-meta {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.88rem;
}

.record-item {
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  background: var(--bg-surface);
}

.record-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.record-user {
  font-weight: 700;
}

.record-date {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.record-desc {
  margin: 0 0 var(--space-3);
  color: var(--text-main);
  white-space: pre-wrap;
}

.record-badges {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.76rem;
  color: var(--primary);
  background: rgb(95 66 231 / 0.2);
}

.record-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.comments-box {
  margin-top: var(--space-3);
  border-top: 1px dashed var(--primary);
  padding-top: var(--space-3);
  display: none;
}

.comments-box.open {
  display: block;
}

.comments-list {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.comment-item {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.comment-item p {
  margin: 0;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-2);
}

.home-shell {
  max-width: 760px;
}

.home-hero {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid rgb(255 255 255 / 0.08);
}

.home-kicker {
  margin: 0;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.home-title {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: clamp(1.8rem, 5vw, 2.2rem);
  line-height: 1.05;
}

.home-card {
  display: grid;
  gap: var(--space-3);
  border: none;
  border-radius: 0;
  background: var(--bg-main);
  padding: 0;
}

.home-card .habit-list {
  display: grid;
  gap: var(--space-2);
}

.home-card .habit-item {
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 14px 14px 12px;
  background: var(--bg-surface);
  aspect-ratio: 3 / 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.home-card .habit-item.is-clickable {
  cursor: pointer;
}

.home-card .habit-item.is-clickable:hover {
  border-color: var(--surface-border-strong);
  background: var(--bg-soft);
}

.home-card .habit-item.is-clickable:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.home-card .habit-item h4 {
  font-size: 1rem;
}

.home-card .helper-text {
  margin: 0;
}

.habit-card-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: var(--space-3);
}

.habit-card-name {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: 0.98rem;
}

.habit-card-metrics {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: nowrap;
  min-width: 0;
}

.habit-metric {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.habit-metric-icon {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.habit-metric-icon svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.habit-metric-value {
  font-family: 'Outfit', sans-serif;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1;
}

.habit-metric-label {
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1;
}

.habit-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-top: 10px;
  border-top: 1px solid var(--surface-border);
}

.habit-card-footer-meta {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.habit-card-footer::after {
  content: '';
  display: block;
}

.home-fab-stack {
  position: fixed;
  right: max(var(--space-3), env(safe-area-inset-right));
  bottom: calc(86px + env(safe-area-inset-bottom));
  z-index: 70;
  display: grid;
  gap: var(--space-2);
}

.home-fab {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--surface-border-strong);
  background: rgb(95 66 231 / 0.94);
  color: var(--brand-on);
  font-family: 'Outfit', sans-serif;
  font-size: 1.45rem;
  font-weight: 700;
  box-shadow: 0 8px 22px rgb(0 0 0 / 0.34);
}

.home-fab:hover {
  transform: translateY(-1px);
  background: rgb(111 85 235);
}

.home-fab-ia {
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.home-fab-ia.is-disabled,
.home-fab-ia[aria-disabled='true'] {
  background: var(--bg-soft);
  border-color: var(--surface-border);
  color: var(--text-soft);
}

.home-page .message {
  margin-bottom: var(--space-4);
}

@media (max-width: 760px) {
  .home-card-head {
    align-items: start;
    flex-direction: column;
  }

  .habit-card-metrics {
    gap: 14px;
  }
}

.history-shell {
  max-width: 760px;
}

.history-hero {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--surface-border);
}

.history-title {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: clamp(1.75rem, 6vw, 2.4rem);
  line-height: 1.04;
}

.history-subtitle {
  max-width: 58ch;
  margin: 0;
}

.history-feed-surface {
  display: grid;
  gap: var(--space-3);
}

.history-feed {
  display: grid;
  gap: var(--space-3);
}

.history-day-separator {
  position: relative;
  display: flex;
  justify-content: center;
  margin: var(--space-2) 0;
}

.history-day-separator::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  border-top: 1px solid var(--surface-border);
}

.history-day-separator span {
  position: relative;
  z-index: 1;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text-soft);
  font-size: 0.84rem;
  font-weight: 600;
  text-transform: lowercase;
}

.history-record {
  position: relative;
  display: grid;
  gap: var(--space-3);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  overflow: hidden;
}

.history-record::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: rgb(95 66 231 / 0.9);
}

.history-record.is-friend::before {
  background: rgb(16 185 129 / 0.95);
}

.history-record-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.history-record-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.history-avatar {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--surface-border-strong);
  background: var(--bg-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.history-avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-avatar-fallback {
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
}

.history-user-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.history-user-nick {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: 1.04rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-habit-name {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.8rem;
}

.history-record-time {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.history-record-desc {
  margin: 0;
  color: var(--text-main);
  font-size: 0.94rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.history-record-footer {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.history-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.history-meta-item svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.history-loading,
.history-end,
.history-empty {
  margin: 0;
  text-align: center;
}

.history-end {
  padding-bottom: var(--space-2);
}

.history-sentinel {
  width: 100%;
  height: 1px;
}

.history-page .message {
  margin-bottom: var(--space-4);
}

@media (max-width: 760px) {
  .history-record {
    padding: var(--space-3);
  }

  .history-record-head {
    align-items: start;
  }
}

.create-habit-shell {
  max-width: 760px;
}

.create-habit-card {
  display: grid;
  gap: var(--space-4);
}

.create-habit-page .create-habit-card-flat {
  border: none;
  border-radius: 0;
  background: var(--bg-main);
  padding: 0;
}

.create-habit-subtitle {
  max-width: 52ch;
}

.card-subtitle {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: 1.08rem;
}

.create-habit-form {
  display: grid;
  gap: var(--space-5);
}

.create-habit-section {
  display: grid;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid rgb(255 255 255 / 0.08);
}

.create-habit-section-title {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: 0.96rem;
  color: var(--text-soft);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.create-habit-fields {
  display: grid;
  gap: var(--space-4);
}

.create-habit-features {
  margin-top: 0;
}

.create-habit-features-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.feature-rows {
  display: grid;
  gap: 0;
  border-top: 1px solid rgb(255 255 255 / 0.08);
}

.feature-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px 108px;
  align-items: center;
  gap: var(--space-2);
  border: none;
  border-bottom: 1px solid rgb(255 255 255 / 0.08);
  border-radius: 0;
  padding: 14px 0;
  background: var(--bg-main);
}

.feature-type {
  min-width: 0;
}

.create-habit-page .field-input,
.create-habit-page .field-textarea,
.create-habit-page .field-select {
  background: var(--bg-surface);
  border-color: rgb(255 255 255 / 0.08);
  min-height: 46px;
}

.create-habit-page .field-input:focus,
.create-habit-page .field-textarea:focus,
.create-habit-page .field-select:focus {
  border-color: rgb(95 66 231 / 0.72);
  outline: none;
}

.create-habit-page .btn-soft {
  background: var(--bg-surface);
  border-color: rgb(255 255 255 / 0.08);
}

.create-habit-page .btn-soft:hover {
  background: var(--bg-soft);
}

.create-habit-page .feature-remove-button {
  min-height: 46px;
}

.create-habit-page .create-habit-features .btn-soft {
  justify-self: start;
}

.create-habit-page .btn-primary {
  min-height: 50px;
  font-size: 1rem;
}

@media (max-width: 760px) {
  .create-habit-section {
    padding-top: var(--space-3);
  }

  .create-habit-features-head {
    flex-direction: column;
    align-items: stretch;
  }

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

  .feature-remove-button {
    width: 100%;
  }
}

.create-record-shell {
  max-width: 760px;
}

.create-record-card {
  display: grid;
  gap: var(--space-4);
}

.create-record-page .create-record-card-flat {
  border: none;
  border-radius: 0;
  background: var(--bg-main);
  padding: 0;
}

.create-record-subtitle {
  max-width: 56ch;
}

.create-record-form {
  display: grid;
  gap: var(--space-5);
}

.create-record-section {
  display: grid;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid rgb(255 255 255 / 0.08);
}

.create-record-section-title {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: 0.96rem;
  color: var(--text-soft);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.create-record-datetime {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.create-record-page .field-input,
.create-record-page .field-textarea,
.create-record-page .field-select {
  background: var(--bg-surface);
  border-color: rgb(255 255 255 / 0.08);
  min-height: 46px;
}

.create-record-page .field-input:focus,
.create-record-page .field-textarea:focus,
.create-record-page .field-select:focus {
  border-color: rgb(95 66 231 / 0.72);
  outline: none;
}

.record-mention-results {
  display: grid;
  gap: 8px;
  margin-top: calc(var(--space-2) * -1);
  border: 1px solid rgb(255 255 255 / 0.08);
  border-radius: var(--radius-md);
  padding: 10px;
  background: var(--bg-surface);
  max-height: 220px;
  overflow-y: auto;
}

.record-mention-option {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  cursor: pointer;
}

.record-mention-option:hover {
  border-color: var(--surface-border);
  background: var(--bg-soft);
}

.record-mention-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--surface-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
}

.record-mention-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.record-mention-name {
  font-size: 0.92rem;
  font-weight: 600;
}

.record-mention-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.record-mention-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgb(95 66 231 / 0.18);
  color: var(--text-main);
  font-size: 0.84rem;
  font-weight: 600;
}

.record-mention-chip button {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 999px;
  background: rgb(15 23 42 / 0.16);
  color: inherit;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.record-photo-list {
  display: grid;
  gap: var(--space-3);
}

.record-photo-item {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: var(--space-3);
  border: 1px solid rgb(255 255 255 / 0.08);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: var(--bg-surface);
}

.record-photo-preview {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.record-photo-meta {
  display: grid;
  gap: 6px;
  align-content: start;
}

.record-photo-order,
.record-photo-name {
  margin: 0;
}

.record-photo-order {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.record-photo-name {
  font-size: 0.9rem;
  font-weight: 600;
  word-break: break-word;
}

.record-photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: 1 / -1;
}

.create-record-page .record-photo-actions .btn-soft {
  border-color: rgb(255 255 255 / 0.08);
  background: var(--bg-soft);
}

.create-record-page .record-photo-actions .btn-soft:disabled {
  opacity: 0.56;
  cursor: not-allowed;
}

.record-feature-rows {
  display: grid;
  gap: var(--space-3);
}

.record-feature-row {
  display: grid;
  gap: var(--space-2);
  border: 1px solid rgb(255 255 255 / 0.08);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: var(--bg-surface);
}

.record-feature-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.record-feature-toggle {
  width: 18px;
  height: 18px;
  margin: 0;
}

.record-feature-name {
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--text-main);
}

.record-feature-kind {
  font-size: 0.78rem;
  color: var(--text-soft);
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 4px 9px;
}

.record-feature-value-wrap {
  margin-left: 28px;
}

.create-record-page .record-feature-value {
  max-width: 180px;
}

.create-record-page .btn-primary {
  min-height: 50px;
  font-size: 1rem;
}

@media (max-width: 760px) {
  .create-record-section {
    padding-top: var(--space-3);
  }

  .create-record-datetime {
    grid-template-columns: 1fr;
  }

  .record-photo-item {
    grid-template-columns: 1fr;
  }

  .record-photo-preview {
    width: 100%;
    height: 180px;
  }

  .record-feature-main {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .record-feature-kind {
    grid-column: 2;
    justify-self: start;
  }

  .record-feature-value-wrap {
    margin-left: 0;
  }
}
