:root {
  color-scheme: light;
  --bg: #f2f5f2;
  --surface: #ffffff;
  --surface-soft: #eef5f0;
  --ink: #19222c;
  --muted: #5b6670;
  --line: #e5e9e4;
  --green: #2f8c61;
  --green-dark: #1f5f44;
  --green-soft: #e9f5ee;
  --blue: #3a6ea5;
  --yellow: #cf9a36;
  --rose: #cf6b6b;
  --shadow-sm: 0 1px 2px rgba(20, 45, 32, 0.05);
  --shadow: 0 12px 32px rgba(22, 48, 34, 0.1), 0 2px 8px rgba(22, 48, 34, 0.05);
  --shadow-pop: 0 24px 64px rgba(18, 40, 28, 0.2);
  --radius: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(820px 480px at 100% -8%, rgba(47, 140, 97, 0.08), transparent 60%),
    radial-gradient(680px 460px at -8% 2%, rgba(58, 110, 165, 0.06), transparent 55%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 42%);
  background-attachment: fixed;
  color: var(--ink);
  font-family:
    "Hiragino Sans",
    "Hiragino Kaku Gothic ProN",
    "Noto Sans JP",
    "Yu Gothic UI",
    Meiryo,
    system-ui,
    sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  position: relative;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

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

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(150deg, #45c98c, var(--green));
  box-shadow: 0 8px 20px rgba(47, 140, 97, 0.3);
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(1.5rem, 1.2rem + 1vw, 2.05rem);
  letter-spacing: -0.03em;
}

h2 {
  font-size: 1.18rem;
}

h3 {
  font-size: 0.98rem;
}

.date-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.date-controls input,
.task-form input,
.task-form select,
.event-form input,
.want-form input,
.routine-form input,
.routine-form select,
.sync-form input,
textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.date-controls input:focus,
.task-form input:focus,
.task-form select:focus,
.event-form input:focus,
.want-form input:focus,
.routine-form input:focus,
.routine-form select:focus,
.sync-form input:focus,
textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 140, 97, 0.16);
}

.date-controls input {
  min-height: 40px;
  padding: 8px 10px;
}

.icon-button,
.text-button,
.primary-button,
.quiet-button,
.segmented-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease,
    box-shadow 0.16s ease,
    color 0.16s ease;
}

.icon-button {
  display: inline-grid;
  width: 40px;
  place-items: center;
  font-size: 1.35rem;
  line-height: 1;
}

.icon-button-small {
  width: 34px;
  min-height: 34px;
  font-size: 1.1rem;
}

.text-button,
.quiet-button,
.segmented-button {
  padding: 0 14px;
}

.segmented-button {
  font-weight: 400;
}

.primary-button {
  align-self: end;
  padding: 0 18px;
  border-color: transparent;
  background: linear-gradient(180deg, #37a070, var(--green));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(47, 140, 97, 0.28);
}

.icon-button:hover,
.text-button:hover,
.quiet-button:hover,
.segmented-button:hover {
  border-color: #aebfb6;
  transform: translateY(-1px);
}

.primary-button:hover {
  background: linear-gradient(180deg, #2f8c61, var(--green-dark));
  box-shadow: 0 9px 22px rgba(47, 140, 97, 0.34);
  transform: translateY(-1px);
}

.icon-button:active,
.text-button:active,
.quiet-button:active,
.segmented-button:active,
.primary-button:active {
  transform: translateY(0);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 0.48fr);
  gap: 18px;
  align-items: start;
}

.side-column {
  display: grid;
  gap: 18px;
}

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

.plan-panel,
.calendar-panel,
.want-panel,
.routine-panel,
.account-panel,
.sync-panel,
.progress-panel,
.cnp-panel,
.chart-panel,
.weekly-panel,
.export-panel,
.diary-panel {
  padding: 20px;
}

.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.save-state {
  min-width: 68px;
  border: 1px solid #cbd8cf;
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--green-dark);
  background: var(--surface-soft);
  font-size: 0.78rem;
  text-align: center;
}

.field-block {
  display: grid;
  gap: 8px;
}

.field-block span,
.task-form label span,
.event-form label span,
.want-form label span,
.routine-form label span,
.sync-form label span,
.range-field span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
}

textarea {
  width: 100%;
  resize: vertical;
  padding: 12px;
  line-height: 1.65;
}

.positive-line-block {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
  margin-top: 14px;
}

.positive-line-card {
  display: grid;
  gap: 6px;
  min-height: 72px;
  border: 1px solid #d7e4dc;
  border-radius: var(--radius);
  padding: 12px;
  background: #f6fbf8;
}

.positive-line-card span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.positive-line-card p {
  margin: 0;
  color: var(--green-dark);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.55;
}

textarea:focus,
input:focus,
select:focus {
  outline: none;
  border-color: var(--green);
}

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

.compact-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.daily-mode,
.focus-box,
.cleanup-panel {
  margin: 14px 0;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.mode-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-copy,
.cleanup-copy,
.task-notice {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.task-notice {
  min-height: 1.4em;
  color: var(--green-dark);
  font-weight: 600;
}

.task-notice.is-warn {
  color: #9b5d1f;
}

.focus-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.focus-slot {
  flex: 1 1 0;
  min-width: 0;
  min-height: 40px;
  border: 1px solid rgba(63, 139, 105, 0.22);
  border-radius: var(--radius);
  padding: 9px 10px;
  background: #f6fbf8;
  color: var(--green-dark);
  font-size: 0.88rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.focus-slot.is-empty {
  border-style: dashed;
  background: #fbfcfb;
  color: var(--muted);
  font-weight: 600;
}

.focus-slot.is-done {
  color: #7a8380;
  text-decoration: line-through;
}

.focus-slot.is-rest {
  white-space: normal;
  border-style: dashed;
  background: #f3f8fb;
  color: var(--blue);
  font-weight: 600;
}

.range-field {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
}

.range-field output {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: #ecf4ef;
  color: var(--green-dark);
  font-weight: 700;
}

input[type="range"] {
  accent-color: var(--green);
  min-width: 80px;
}

.task-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px auto;
  gap: 10px;
  align-items: end;
  margin: 16px 0 12px;
}

.task-form label,
.event-form label,
.want-form label,
.routine-form label,
.sync-form label {
  display: grid;
  gap: 8px;
}

.task-form input,
.task-form select,
.event-form input,
.want-form input,
.routine-form input,
.routine-form select,
.sync-form input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
}

.task-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.segmented-button.is-active {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green-dark);
  font-weight: 400;
  box-shadow: 0 4px 12px rgba(47, 140, 97, 0.16);
}

.task-list {
  display: grid;
  gap: 8px;
  min-height: 160px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.task-item {
  display: grid;
  grid-template-columns: 34px 38px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.task-item.is-focus {
  border-color: rgba(63, 139, 105, 0.46);
  background: #fbfdfb;
}

.task-focus-button {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: #9a9f98;
  font-size: 1rem;
  line-height: 1;
}

.task-focus-button.is-active {
  border-color: rgba(213, 157, 53, 0.45);
  background: #fff7e6;
  color: #a86f12;
}

.task-check {
  width: 30px;
  height: 30px;
  border: 2px solid #aebbb3;
  border-radius: 50%;
  background: #fff;
}

.task-item.is-done .task-check {
  border-color: var(--green);
  background:
    linear-gradient(135deg, transparent 0 42%, #fff 42% 54%, transparent 54%),
    var(--green);
}

.task-content {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.task-title-input {
  width: 100%;
  min-width: 0;
  border: 0;
  border-bottom: 1px solid rgba(99, 112, 107, 0.22);
  border-radius: 0;
  padding: 2px 0;
  background: transparent;
  color: var(--ink);
  transition: border-color 0.15s ease;
}

.task-title-input:hover {
  border-bottom-color: rgba(99, 112, 107, 0.45);
}

.task-title-input:focus {
  outline: 0;
  border-bottom-color: var(--green);
}

.task-item.is-done .task-title-input {
  color: #7a8380;
  text-decoration: line-through;
}

.task-area {
  width: fit-content;
  border: 0;
  border-radius: 999px;
  padding: 3px 22px 3px 8px;
  background: #f2f0ea;
  color: #65706b;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2365706b' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
}

.quiet-button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--muted);
}

.quiet-button:hover {
  color: #8b3e3e;
  border-color: #e0b7b7;
  background: #fff5f5;
}

.empty-state {
  display: none;
  margin-top: -120px;
  min-height: 120px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.empty-state p {
  margin: 4px 0;
}

.empty-state.is-visible {
  display: grid;
}

.cleanup-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.calendar-nav {
  display: flex;
  gap: 6px;
}

.calendar-month {
  margin: -4px 0 12px;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
}

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

.calendar-weekdays {
  margin-bottom: 6px;
}

.calendar-weekdays span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
}

.calendar-days {
  margin-bottom: 14px;
}

.calendar-day {
  display: grid;
  align-content: start;
  gap: 3px;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.calendar-day:hover {
  border-color: #b9c6bf;
  background: #fbfcfb;
}

.calendar-day.is-outside {
  color: #a8b0aa;
  background: #f5f6f3;
}

.calendar-day.is-today {
  border-color: var(--yellow);
}

.calendar-day.is-selected {
  border-color: var(--green);
  background: #eaf4ee;
  box-shadow: inset 0 0 0 1px var(--green);
}

.calendar-day-number {
  font-size: 0.82rem;
  font-weight: 400;
}

.calendar-day-badge {
  overflow: hidden;
  max-width: 100%;
  border-radius: 999px;
  padding: 2px 5px;
  background: rgba(60, 111, 159, 0.12);
  color: #245884;
  font-size: 0.64rem;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-day-badge.task-badge {
  background: rgba(63, 139, 105, 0.12);
  color: var(--green-dark);
}

.event-form {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.event-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.event-item {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 48px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.event-item input {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.event-item input:focus {
  outline: 0;
}

.event-title-input {
  width: 100%;
}

.event-time-input {
  color: var(--blue);
  font-weight: 700;
}

.event-empty {
  display: none;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.event-empty.is-visible {
  display: block;
}

.want-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.want-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.want-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  min-height: 48px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.want-title-input {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.want-title-input:focus {
  outline: 0;
}

.want-empty {
  display: none;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.want-empty.is-visible {
  display: block;
}

.routine-form {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(140px, 1fr) 160px auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.routine-title-field {
  grid-column: 1 / -1;
}

.routine-title-field input {
  min-height: 46px;
  font-size: 1rem;
}

.routine-templates {
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

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

.template-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 400;
  text-align: center;
}

.template-button:hover {
  border-color: rgba(63, 139, 105, 0.4);
  background: #f2faf5;
}

.weekday-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0 0 10px;
}

.weekday-picker label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 9px;
  background: #fff;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.weekday-picker input {
  accent-color: var(--green);
}

.weekday-picker.is-disabled {
  opacity: 0.45;
}

.routine-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.routine-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 54px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.routine-content {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.routine-title-input {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.routine-title-input:focus {
  outline: 0;
}

.routine-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.routine-badge {
  width: fit-content;
  border-radius: 999px;
  padding: 3px 8px;
  background: #f2f0ea;
  color: #65706b;
  font-size: 0.76rem;
  font-weight: 700;
}

.routine-badge.is-due {
  background: rgba(63, 139, 105, 0.12);
  color: var(--green-dark);
}

.routine-empty {
  display: none;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.routine-empty.is-visible {
  display: block;
}

.sync-state {
  min-width: 68px;
  border: 1px solid #d4d8dc;
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  background: #f5f6f5;
  font-size: 0.78rem;
  text-align: center;
}

.account-state {
  min-width: 68px;
  border: 1px solid #d4d8dc;
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  background: #f5f6f5;
  font-size: 0.78rem;
  text-align: center;
}

.account-state.is-on {
  border-color: #cbd8cf;
  color: var(--green-dark);
  background: var(--surface-soft);
}

.account-state.is-busy {
  border-color: rgba(60, 111, 159, 0.28);
  color: var(--blue);
  background: #eaf1f8;
}

.sync-state.is-on {
  border-color: #cbd8cf;
  color: var(--green-dark);
  background: var(--surface-soft);
}

.sync-state.is-busy {
  border-color: rgba(60, 111, 159, 0.28);
  color: var(--blue);
  background: #eaf1f8;
}

.account-profile {
  display: grid;
  gap: 6px;
  border: 1px solid #d7e4dc;
  border-radius: var(--radius);
  padding: 12px;
  background: #f6fbf8;
}

.account-profile strong {
  color: var(--ink);
  line-height: 1.45;
}

.account-profile p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.account-actions,
.migration-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.account-actions {
  margin-top: 10px;
}

.migration-prompt {
  display: none;
  gap: 10px;
  margin-top: 10px;
  border: 1px solid rgba(213, 157, 53, 0.42);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(213, 157, 53, 0.1);
}

.migration-prompt.is-visible {
  display: grid;
}

.migration-prompt p {
  margin: 0;
  color: #6d5526;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.55;
}

.sync-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.sync-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.sync-message {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.sync-message.is-error {
  color: #8b3e3e;
}

.sync-message.is-ok {
  color: var(--green-dark);
}

.progress-panel strong {
  color: var(--green-dark);
  font-size: 1.8rem;
  line-height: 1;
}

.progress-track {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ebe6;
  box-shadow: inset 0 1px 2px rgba(20, 45, 32, 0.08);
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.progress-track span.is-achieved {
  background: linear-gradient(90deg, #2f8c61, #43c489);
  box-shadow: 0 0 12px rgba(67, 196, 137, 0.5);
}

.progress-copy {
  min-height: 44px;
  margin: 12px 0 14px;
  color: var(--muted);
  line-height: 1.55;
}

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

.stat-grid div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #fbfcfb;
}

.stat-grid span {
  display: block;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 700;
}

.stat-grid p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.week-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(28px, 1fr));
  gap: 8px;
  align-items: end;
  min-height: 180px;
}

.chart-day {
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 7px;
  min-width: 0;
  height: 180px;
}

.bar-frame {
  display: flex;
  align-items: end;
  justify-content: center;
  min-height: 112px;
  border-radius: 999px;
  background: #edf0ed;
  overflow: hidden;
}

.bar-fill {
  width: 100%;
  min-height: 4px;
  border-radius: inherit;
  background: linear-gradient(180deg, var(--yellow), var(--green));
}

.bar-fill.is-achieved {
  background: linear-gradient(180deg, #6fce9d, #2faa6b);
}

.chart-day time,
.chart-day span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.74rem;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-day span {
  color: var(--ink);
  font-weight: 700;
}

.weekly-range {
  margin: -6px 0 12px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

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

.weekly-summary div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #fbfcfb;
}

.weekly-summary span {
  display: block;
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 700;
}

.weekly-summary p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.weekly-insight,
.export-message {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.weekly-note {
  margin-top: 12px;
}

.weekly-note textarea {
  min-height: 120px;
}

.diary-panel textarea {
  min-height: 210px;
}

.export-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.export-actions .text-button {
  font-weight: 400;
}

.export-message.is-ok {
  color: var(--green-dark);
  font-weight: 600;
}

@media (max-width: 900px) {
  .topbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .date-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .workspace {
    display: grid;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 14px;
  }

  .plan-panel,
  .calendar-panel,
  .want-panel,
  .routine-panel,
  .account-panel,
  .sync-panel,
  .progress-panel,
  .chart-panel,
  .weekly-panel,
  .export-panel,
  .diary-panel {
    padding: 14px;
  }

  .checkin-grid,
  .task-form,
  .positive-line-block,
  .event-form,
  .want-form,
  .routine-form,
  .sync-form {
    grid-template-columns: 1fr;
  }

  .primary-button {
    width: 100%;
  }

  .focus-list {
    flex-direction: column;
  }

  .task-item {
    grid-template-columns: 34px 34px minmax(0, 1fr);
  }

  .task-item .quiet-button {
    grid-column: 3;
    width: fit-content;
  }

  .cleanup-actions .text-button,
  .cleanup-actions .quiet-button,
  .export-actions .text-button,
  .mode-options .segmented-button {
    flex: 1 1 0;
  }

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

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

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

  .template-grid,
  .weekly-summary {
    grid-template-columns: 1fr;
  }

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

  .week-chart {
    gap: 5px;
  }
}

/* ===== CNP 相棒・コレクション ===== */
.cnp-count {
  padding: 3px 10px;
  border-radius: 999px;
  background: #eef4f0;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 700;
}

.cnp-setup-copy {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.cnp-pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 10px;
}

.cnp-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px;
  border: 1px solid rgba(63, 139, 105, 0.2);
  border-radius: var(--radius);
  background: #fbfdfc;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.cnp-pick:hover {
  border-color: var(--green);
  transform: translateY(-1px);
}

.cnp-pick-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--green-dark);
}

.cnp-avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #f1f7f3;
  border: 1px solid rgba(63, 139, 105, 0.22);
  font-size: 24px;
  overflow: hidden;
  flex: none;
}

.cnp-avatar-lg {
  width: 66px;
  height: 66px;
  font-size: 36px;
}

.cnp-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 3px;
}

.cnp-avatar.has-img .cnp-emoji {
  display: none;
}

.cnp-avatar.is-locked {
  background: #edefed;
  color: #b7bdb8;
  font-weight: 700;
  font-size: 20px;
}

.cnp-partner {
  display: flex;
  gap: 14px;
  align-items: center;
}

.cnp-partner-meta {
  min-width: 0;
}

.cnp-partner-meta strong {
  display: block;
  color: var(--green-dark);
}

.cnp-bond {
  display: inline-block;
  margin-top: 2px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--blue);
}

.cnp-line {
  margin: 7px 0 0;
  color: var(--green-dark);
  font-weight: 600;
  line-height: 1.5;
}

.cnp-collection-label {
  margin: 16px 0 8px;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.cnp-collection {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 8px;
  justify-items: center;
}

.cnp-cell {
  padding: 0;
  border: none;
  background: none;
}

.cnp-cell[data-cnp-partner] {
  cursor: pointer;
}

.cnp-cell.is-partner .cnp-avatar {
  outline: 2px solid var(--green);
  outline-offset: 1px;
}

.cnp-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.cnp-note.is-celebrate {
  color: var(--green-dark);
  font-weight: 700;
}

.plan-partner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid rgba(63, 139, 105, 0.22);
  border-radius: var(--radius);
  background: #f1faf4;
}

.plan-partner-avatar {
  flex: none;
}

.plan-partner-bubble {
  min-width: 0;
}

.plan-partner-name {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--blue);
}

.plan-partner-line {
  margin: 2px 0 0;
  color: var(--green-dark);
  font-weight: 600;
  line-height: 1.5;
}

.cnp-claim {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(63, 139, 105, 0.35);
  border-radius: var(--radius);
  background: #f1faf4;
}

.cnp-claim-label {
  margin: 0 0 10px;
  color: var(--green-dark);
  font-weight: 700;
  font-size: 0.9rem;
}

/* ===== トップバーのアクション（相棒・連携ボタン） ===== */
.topbar-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.topbar-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 6px;
  border: 1px solid rgba(63, 139, 105, 0.25);
  border-radius: 999px;
  background: #fff;
  color: var(--green-dark);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.topbar-button[hidden] {
  display: none;
}

/* まだ相棒がいない時：CNPを選べることが分かるように強調 */
.topbar-button.is-cta {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green-dark);
  animation: cnpCtaPulse 2.2s ease-in-out infinite;
}

.topbar-button.is-cta .topbar-button-avatar.is-empty {
  background: var(--green);
  color: #fff;
}

@keyframes cnpCtaPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(47, 140, 97, 0);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(47, 140, 97, 0.16);
  }
}

.topbar-button:hover,
.topbar-button.is-open {
  border-color: var(--green);
  background: #f1faf4;
}

.topbar-button-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  font-size: 15px;
}

.topbar-button-avatar.is-empty {
  background: #eef0ee;
  color: #b7bdb8;
}

.topbar-button-dot {
  width: 10px;
  height: 10px;
  margin-left: 4px;
  border-radius: 50%;
  background: #c9cfca;
}

.topbar-button-dot.is-on {
  background: var(--green);
}

/* ===== ポップアップ ===== */
.popover {
  position: absolute;
  top: 58px;
  right: 0;
  z-index: 50;
  width: min(360px, calc(100vw - 32px));
  max-height: 76vh;
  overflow-y: auto;
  padding: 14px 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-pop);
}

.popover[hidden] {
  display: none;
}

.popover-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.popover-close:hover {
  background: #f1f3f1;
}

.popover .panel {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.popover .section-heading {
  padding-right: 28px;
}

/* ===== 今日のひとこと＝相棒のセリフ（統合） ===== */
.plan-voice {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 13px 15px;
  border: 1px solid rgba(47, 140, 97, 0.2);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #f3fbf6, var(--green-soft));
  box-shadow: var(--shadow-sm);
}

.plan-voice-avatar {
  flex: none;
}

.plan-voice-body {
  flex: 1 1 auto;
  min-width: 0;
}

.plan-voice-name {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--blue);
}

.plan-voice-line {
  margin: 3px 0 0;
  color: var(--green-dark);
  font-weight: 600;
  line-height: 1.55;
}

.plan-voice .text-button {
  flex: none;
  align-self: flex-start;
}

@media (max-width: 900px) {
  .topbar-actions {
    position: absolute;
    top: 0;
    right: 0;
    width: auto;
    margin: 0;
  }

  .popover {
    position: fixed;
    top: auto;
    right: 16px;
    bottom: 16px;
    left: 16px;
    width: auto;
    max-height: 70vh;
  }
}
