:root {
  color-scheme: light;
  --bg: #f5f6f0;
  --surface: #ffffff;
  --surface-strong: #f0f3ed;
  --text: #1f2a2a;
  --muted: #687171;
  --line: #d9ded6;
  --teal: #197d76;
  --teal-soft: #e3f2ef;
  --coral: #c75b45;
  --coral-soft: #fae7df;
  --amber: #b68118;
  --amber-soft: #f7ecd0;
  --indigo: #405891;
  --indigo-soft: #e7ebf7;
  --ok: #2f7d4e;
  --danger: #a83f36;
  --shadow: 0 18px 50px rgba(31, 42, 42, 0.11);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(227, 242, 239, 0.85), rgba(245, 246, 240, 0) 260px),
    var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

#app {
  min-height: 100vh;
}

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

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compact-brand {
  align-items: flex-start;
}

.brand-title {
  margin: 0;
  font-size: 21px;
  line-height: 1.2;
  font-weight: 760;
}

.brand-subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.top-panel {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
}

.compact-top-panel {
  gap: 0;
}

.identity-panel,
.actor-panel {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 10px 24px rgba(31, 42, 42, 0.06);
}

.identity-panel {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.compact-identity {
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.cat-avatar {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 34% 44%, #1f2a2a 0 4px, transparent 5px),
    radial-gradient(circle at 66% 44%, #1f2a2a 0 4px, transparent 5px),
    radial-gradient(circle at 50% 60%, #c75b45 0 4px, transparent 5px),
    linear-gradient(145deg, #f5c56d, #f19d61 58%, #df7557);
  overflow: hidden;
  border: 1px solid rgba(31, 42, 42, 0.12);
}

.cat-avatar::before,
.cat-avatar::after {
  content: "";
  position: absolute;
  top: -9px;
  width: 32px;
  height: 32px;
  background: #df7557;
  border: 1px solid rgba(31, 42, 42, 0.12);
  transform: rotate(45deg);
}

.cat-avatar::before {
  left: 7px;
}

.cat-avatar::after {
  right: 7px;
}

.cat-avatar span {
  position: absolute;
  left: 27px;
  top: 51px;
  width: 18px;
  height: 8px;
  border-bottom: 2px solid rgba(31, 42, 42, 0.55);
  border-radius: 0 0 20px 20px;
}

.field-label,
.tiny-label {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.select-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.select,
.input,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  min-height: 42px;
  padding: 9px 10px;
  outline: none;
}

.textarea {
  min-height: 84px;
  resize: vertical;
}

.select:focus,
.input:focus,
.textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(25, 125, 118, 0.15);
}

.actor-panel {
  display: grid;
  gap: 10px;
}

.meta-row,
.pill-row,
.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.teal {
  color: var(--teal);
  background: var(--teal-soft);
}

.pill.coral {
  color: var(--coral);
  background: var(--coral-soft);
}

.pill.amber {
  color: var(--amber);
  background: var(--amber-soft);
}

.pill.indigo {
  color: var(--indigo);
  background: var(--indigo-soft);
}

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

.view-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.view-title h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.view-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.panel,
.record-card,
.day-card,
.reminder-card,
.member-card {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(31, 42, 42, 0.05);
}

.panel {
  padding: 14px;
}

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

.panel-header h3 {
  margin: 0;
  font-size: 16px;
}

.panel-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 760;
  text-decoration: none;
  white-space: nowrap;
}

.primary-button {
  color: #fff;
  background: var(--teal);
}

.primary-button:hover {
  background: #146963;
}

.secondary-button {
  color: var(--text);
  border-color: var(--line);
  background: #fff;
}

.secondary-button:hover {
  border-color: #bcc8c0;
  background: var(--surface-strong);
}

.ghost-button {
  color: var(--teal);
  background: transparent;
}

.danger-button {
  color: #fff;
  background: var(--danger);
}

.icon-button {
  min-width: 40px;
  padding: 8px;
  color: var(--muted);
  border-color: var(--line);
  background: #fff;
}

.normal-button {
  width: 100%;
  min-height: 82px;
  justify-content: flex-start;
  padding: 14px;
  font-size: 18px;
}

.normal-button .button-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.18);
  font-size: 24px;
}

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

.simple-home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.simple-action-panel {
  display: grid;
  gap: 10px;
}

.simple-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.simple-action-button {
  min-height: 58px;
  white-space: normal;
}

.quick-button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
  font-weight: 760;
}

.quick-button:hover,
.quick-button.active {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.quick-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--indigo);
  background: var(--indigo-soft);
  font-size: 18px;
}

.quick-button small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  margin-top: 2px;
}

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

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 12px;
}

.split-grid,
.dashboard-grid,
.manage-grid,
.report-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.record-list,
.reminder-list,
.member-list,
.timeline-list,
.summary-list {
  display: grid;
  gap: 10px;
}

.record-card,
.reminder-card,
.member-card {
  padding: 11px;
}

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

.record-title {
  margin: 0;
  font-weight: 800;
  line-height: 1.35;
}

.record-meta,
.empty-state,
.small-text {
  color: var(--muted);
  font-size: 13px;
}

.record-note {
  margin: 6px 0 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.attachment-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.attachment-thumb {
  width: 58px;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-strong);
}

.attachment-file {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 12px;
}

.day-card {
  overflow: hidden;
}

.day-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: var(--surface-strong);
  border-bottom: 1px solid var(--line);
}

.day-date {
  font-size: 15px;
  font-weight: 800;
}

.day-records {
  display: grid;
  gap: 9px;
  padding: 10px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.segmented button {
  min-width: 84px;
  min-height: 38px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segmented button.active {
  color: #fff;
  background: var(--indigo);
}

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

.stat-tile {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.stat-tile strong {
  display: block;
  font-size: 20px;
  margin-bottom: 4px;
}

.report-text {
  min-height: 220px;
  line-height: 1.55;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: min(620px, calc(100% - 24px));
  transform: translateX(-50%);
  border: 1px solid rgba(31, 42, 42, 0.12);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(16px);
}

.nav-button {
  min-height: 58px;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 800;
}

.nav-button span {
  font-size: 19px;
  line-height: 1;
}

.nav-button.active {
  color: var(--teal);
  background: var(--teal-soft);
}

.notice {
  position: fixed;
  left: 50%;
  bottom: 88px;
  z-index: 30;
  width: min(420px, calc(100% - 24px));
  transform: translateX(-50%);
  border-radius: 8px;
  background: #1f2a2a;
  color: #fff;
  padding: 11px 13px;
  box-shadow: var(--shadow);
  font-size: 14px;
}

.empty-state {
  min-height: 84px;
  display: grid;
  place-items: center;
  border: 1px dashed #c8d0c8;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
  text-align: center;
  padding: 14px;
}

.danger-zone {
  border-color: rgba(168, 63, 54, 0.35);
  background: #fff8f7;
}

@media (min-width: 720px) {
  .app-shell {
    padding: 24px 22px 106px;
  }

  .top-panel {
    grid-template-columns: minmax(0, 1.55fr) minmax(260px, 0.7fr);
  }

  .select-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .quick-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

  .span-2 {
    grid-column: span 2;
  }

  .dashboard-grid,
  .simple-home-grid,
  .manage-grid,
  .report-grid {
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  }

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

  .stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1060px) {
  .app-shell {
    padding-bottom: 28px;
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
  }

  .app-header {
    position: sticky;
    top: 18px;
    align-self: start;
  }

  .brand-row,
  .top-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .brand-row {
    display: grid;
  }

  .identity-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .cat-avatar {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
  }

  .cat-avatar span {
    left: calc(50% - 9px);
    top: 70%;
  }

  .bottom-nav {
    position: sticky;
    left: auto;
    bottom: auto;
    top: 240px;
    transform: none;
    width: 100%;
    border: 1px solid rgba(31, 42, 42, 0.12);
    border-radius: 8px;
    grid-template-columns: minmax(0, 1fr);
    box-shadow: none;
  }

  .nav-button {
    grid-template-columns: 28px minmax(0, 1fr);
    place-items: center start;
    min-height: 50px;
    padding: 0 14px;
  }

  .content {
    min-width: 0;
  }
}
