:root {
  color-scheme: light;
  --bg: #f3f0e8;
  --panel: #fffdf7;
  --line: #d8d0c0;
  --line-strong: #b8ad99;
  --text: #28261f;
  --muted: #706a5e;
  --muted-soft: #ebe5d8;
  --red: #9b4f36;
  --red-dark: #6f3628;
  --red-soft: #f2ddd4;
  --green: #4f6f52;
  --green-soft: #e5eadf;
  --amber: #95672c;
  --amber-soft: #f4e5c8;
  --ink-soft: #3f4338;
  --focus-ring: rgba(155, 79, 54, 0.34);
  --shadow: 0 18px 45px rgba(54, 45, 34, 0.08);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
}

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

button {
  cursor: pointer;
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

::selection {
  background: var(--green-soft);
  color: var(--text);
}

.shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 82px;
  padding: 18px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.94);
  backdrop-filter: blur(14px);
}

.identity {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 16px;
}

.identity h1 {
  margin: 0;
  color: var(--red);
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.1;
}

.identity p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

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

select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf8;
  color: var(--text);
  max-width: 100%;
}

select,
input {
  min-height: 40px;
  padding: 0 12px;
  width: 100%;
}

textarea {
  display: block;
  width: 100%;
  resize: vertical;
  padding: 12px;
}

.workspace {
  display: grid;
  gap: 18px;
  width: min(1480px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 26px 0 42px;
}

.panel,
.sync-panel,
.recent-panel,
.timeline-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.65);
}

.file-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 0.95fr);
  gap: 18px;
  align-items: start;
}

.panel,
.recent-panel,
.timeline-panel {
  padding: 22px;
}

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

.date-field {
  display: grid;
  gap: 6px;
  min-width: 170px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.daily-panel {
  display: grid;
  gap: 16px;
}

.field-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.field-copy {
  color: var(--text);
}

.field-row strong {
  display: block;
  margin-bottom: 3px;
}

.field-row small {
  display: block;
  color: var(--muted);
}

.response-control {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.format-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.tool-button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf8;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 850;
  padding: 0 10px;
}

.tool-button:hover {
  border-color: var(--line-strong);
  color: var(--red-dark);
}

.figure-control {
  display: grid;
  gap: 10px;
}

.figure-control input[type="file"] {
  min-height: 44px;
  padding: 8px;
}

.figure-control textarea {
  min-height: 72px;
}

.form-actions,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.compact-field {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button,
.filter-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: var(--radius);
  font-weight: 800;
  text-decoration: none;
}

.primary-button {
  border: 1px solid var(--red);
  background: var(--red);
  color: #fff;
  padding: 0 18px;
}

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

.secondary-button,
.icon-button,
.filter-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 0 14px;
}

.secondary-button:hover,
.icon-button:hover,
.filter-button:hover {
  border-color: var(--line-strong);
}

.danger-button {
  border: 1px solid #d9b7a9;
  background: var(--panel);
  color: var(--red-dark);
  padding: 0 14px;
}

.icon-button {
  min-width: 92px;
}

.task-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 0.55fr) 136px;
  gap: 10px;
  margin-bottom: 14px;
  align-items: end;
}

.task-title-field {
  min-width: 180px;
}

.add-task-button {
  min-width: 72px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.task-filter {
  width: min(220px, 100%);
  margin-bottom: 14px;
}

.filter-button {
  min-width: 82px;
}

.filter-button.active {
  border-color: var(--red);
  color: var(--red-dark);
  background: var(--red-soft);
  box-shadow: inset 0 0 0 1px var(--red);
}

.status-summary {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: right;
}

.tasks-panel .panel-header {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.tasks-panel .status-summary {
  text-align: left;
}

.task-list {
  display: grid;
  border-top: 1px solid var(--line);
}

.task-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 128px 64px 32px;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.task-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--green);
}

.task-title {
  min-width: 0;
  font-weight: 750;
}

.task-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.task-key {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  padding: 0 8px;
}

.task-key.terra,
.calendar-event.terra {
  border-color: #d9b7a9;
  background: var(--red-soft);
  color: var(--red-dark);
}

.task-key.sage,
.calendar-event.sage {
  border-color: #b7c7ad;
  background: var(--green-soft);
  color: var(--green);
}

.task-key.ochre,
.calendar-event.ochre {
  border-color: #d7bd83;
  background: var(--amber-soft);
  color: var(--amber);
}

.task-key.clay,
.calendar-event.clay {
  border-color: #c9b4a0;
  background: #eee2d6;
  color: #684a34;
}

.task-key.moss,
.calendar-event.moss {
  border-color: #b7c7ad;
  background: #edf1e8;
  color: #64764c;
}

.task-key.stone,
.calendar-event.stone {
  border-color: var(--line-strong);
  background: var(--muted-soft);
  color: var(--ink-soft);
}

.task-title-button {
  display: block;
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 800;
  text-align: left;
  overflow-wrap: anywhere;
  padding: 0;
}

.task-title-button:hover {
  color: var(--red-dark);
}

.task-meta {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.status-select {
  width: 100%;
  min-height: 34px;
  font-size: 13px;
  font-weight: 800;
}

.status-select.not_started {
  background: var(--muted-soft);
  color: var(--ink-soft);
}

.status-select.in_progress {
  background: var(--green-soft);
  border-color: #b7c7ad;
  color: var(--green);
}

.status-select.waiting {
  background: #edf1e8;
  border-color: #c5d0b8;
  color: #64764c;
}

.status-select.blocked {
  background: var(--amber-soft);
  border-color: #d7bd83;
  color: var(--amber);
}

.status-select.done {
  background: var(--muted-soft);
  color: var(--ink-soft);
}

.date-pair {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.date-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  padding: 0 10px;
  white-space: nowrap;
}

.date-chip.do-date {
  border-color: #b7c7ad;
  background: var(--green-soft);
  color: var(--green);
}

.date-chip.deadline {
  border-color: #d9b7a9;
  background: var(--red-soft);
  color: var(--red-dark);
}

.date-chip.empty {
  background: var(--muted-soft);
  color: var(--muted);
}

.delete-task {
  width: 32px;
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
}

.delete-task:hover {
  background: var(--red-soft);
  color: var(--red-dark);
}

.compact-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.empty-state {
  margin: 0;
  padding: 28px 0;
  color: var(--muted);
}

.sync-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: 18px 22px;
}

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

.sync-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  padding: 12px;
  text-decoration: none;
}

.sync-card:hover {
  border-color: var(--line-strong);
}

.sync-card strong,
.sync-card small {
  display: block;
}

.sync-card small {
  color: var(--muted);
}

.file-icon.doc {
  background: var(--red-soft);
}

.file-icon.doc::before {
  content: "Doc";
  color: var(--red-dark);
  font-size: 11px;
  font-weight: 900;
}

.file-icon.sheet {
  background: var(--green-soft);
}

.file-icon.sheet::before {
  content: "Sheet";
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
}

.recent-list {
  display: grid;
  gap: 10px;
}

.recent-item {
  display: grid;
  gap: 5px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.recent-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.recent-item strong {
  font-size: 14px;
}

.recent-item p {
  margin: 0;
  color: var(--muted);
}

.timeline-panel {
  display: grid;
  gap: 18px;
}

.timeline-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(4, minmax(130px, 0.7fr)) minmax(160px, 0.75fr);
  gap: 10px;
  align-items: end;
}

.timeline-search {
  min-width: 220px;
}

.timeline-list {
  display: grid;
  gap: 14px;
}

.timeline-view-toggle {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf8;
}

.segmented-control button {
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.segmented-control button:last-child {
  border-right: 0;
}

.segmented-control button.active {
  background: var(--green-soft);
  color: var(--green);
}

.timeline-day {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.timeline-day:first-child {
  border-top: 0;
  padding-top: 0;
}

.timeline-day h3 {
  margin: 0;
  color: var(--ink-soft);
  font-size: 15px;
}

.timeline-items {
  display: grid;
  gap: 8px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf8;
  padding: 12px;
}

.timeline-item.do {
  border-left: 4px solid var(--green);
}

.timeline-item.deadline {
  border-left: 4px solid var(--red);
}

.timeline-item.log {
  grid-template-columns: 92px minmax(0, 1fr);
}

.timeline-item strong {
  display: block;
  margin-bottom: 3px;
}

.timeline-title-line {
  align-items: flex-start;
  margin-bottom: 3px;
}

.timeline-title-line strong {
  margin-bottom: 0;
}

.timeline-item p {
  margin: 0;
  color: var(--muted);
}

.timeline-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  padding: 0 10px;
  white-space: nowrap;
}

.timeline-badge.log,
.timeline-badge.entry {
  background: var(--red-soft);
  color: var(--red-dark);
}

.timeline-badge.do {
  background: var(--green-soft);
  color: var(--green);
}

.timeline-badge.deadline {
  background: var(--red-soft);
  color: var(--red-dark);
}

.timeline-badge.unscheduled,
.timeline-badge.not_started {
  background: var(--muted-soft);
  color: var(--ink-soft);
}

.timeline-badge.in_progress {
  background: var(--green-soft);
  color: var(--green);
}

.timeline-badge.waiting {
  background: #edf1e8;
  color: #64764c;
}

.timeline-badge.blocked {
  background: var(--amber-soft);
  color: var(--amber);
}

.timeline-badge.done {
  background: var(--muted-soft);
  color: var(--ink-soft);
}

.timeline-badge.do {
  background: var(--green-soft);
  color: var(--green);
}

.timeline-badge.deadline {
  background: var(--red-soft);
  color: var(--red-dark);
}

.timeline-list.calendar-view {
  gap: 18px;
}

.calendar-month,
.log-activity,
.calendar-unscheduled {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.calendar-month:first-child,
.log-activity:first-child,
.calendar-unscheduled:first-child {
  border-top: 0;
  padding-top: 0;
}

.calendar-month h3,
.log-activity h3,
.calendar-unscheduled h3 {
  margin: 0;
  color: var(--ink-soft);
  font-size: 15px;
}

.calendar-carousel-header,
.log-activity-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.calendar-carousel-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.calendar-nav-button {
  min-height: 32px;
  min-width: 40px;
  padding: 0 10px;
  font-size: 13px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf8;
}

.calendar-weekday {
  min-height: 34px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--muted-soft);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 900;
  padding: 8px;
  text-align: center;
}

.calendar-weekday:nth-child(7n) {
  border-right: 0;
}

.calendar-day {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 6px;
  min-height: 132px;
  min-width: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fffdf8;
  padding: 8px;
}

.calendar-day:nth-child(7n) {
  border-right: 0;
}

.calendar-day.empty {
  background: #f8f5ed;
}

.calendar-day.today {
  box-shadow: inset 0 0 0 2px rgba(79, 111, 82, 0.28);
}

.calendar-date-number {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.calendar-events {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
}

.calendar-event {
  display: block;
  width: 100%;
  min-height: 28px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 6px;
  background: #fffdf8;
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.2;
  padding: 5px 7px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button.calendar-event:hover {
  border-color: var(--line-strong);
}

.calendar-event.log {
  border-left-color: var(--amber);
  background: #f8f1e4;
  color: var(--ink-soft);
}

.calendar-event.do {
  border-left-color: var(--green);
}

.calendar-event.deadline {
  border-left-color: var(--red);
}

.log-activity {
  gap: 12px;
}

.log-activity-summary {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: right;
}

.activity-scroll {
  overflow-x: auto;
  padding-bottom: 2px;
}

.activity-grid {
  display: grid;
  grid-template-columns: 28px repeat(var(--activity-weeks), 14px);
  grid-template-rows: 18px repeat(7, 14px);
  grid-auto-flow: row;
  gap: 4px;
  width: max-content;
  min-width: 100%;
  align-items: center;
}

.activity-month-label,
.activity-day-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  line-height: 1;
}

.activity-day-label {
  text-align: right;
}

.activity-cell {
  display: block;
  width: 14px;
  height: 14px;
  border: 1px solid rgba(63, 67, 56, 0.08);
  border-radius: 3px;
  background: #ebe5d8;
}

.activity-cell.level-1 {
  background: #dce9d3;
}

.activity-cell.level-2 {
  background: #b8d49d;
}

.activity-cell.level-3 {
  background: #7da369;
}

.activity-cell.level-4 {
  background: #416f47;
}

.activity-cell.future {
  opacity: 0.42;
}

.activity-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.modal {
  width: min(620px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 0;
}

.compact-modal {
  width: min(420px, calc(100vw - 28px));
}

.modal::backdrop {
  background: rgba(40, 38, 31, 0.34);
}

.modal form {
  display: grid;
  gap: 18px;
  padding: 20px;
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.icon-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
}

.stacked-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.settings-list {
  display: grid;
  gap: 10px;
}

.settings-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.settings-list span {
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(380px, calc(100vw - 36px));
  border-radius: var(--radius);
  background: #2f2d25;
  color: #fff;
  font-weight: 800;
  opacity: 0;
  padding: 12px 14px;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .topbar,
  .sync-panel {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions,
  .sync-targets {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    display: grid;
  }

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

  .task-controls,
  .timeline-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-summary {
    text-align: left;
  }
}

@media (max-width: 680px) {
  body {
    font-size: 14px;
  }

  .topbar {
    padding: 18px;
  }

  .workspace {
    width: calc(100vw - 28px);
    padding-top: 14px;
  }

  .panel,
  .sync-panel,
  .recent-panel,
  .timeline-panel {
    padding: 16px;
  }

  .field-row,
  .task-controls,
  .task-row,
  .timeline-filters,
  .timeline-item,
  .timeline-item.log,
  .modal-grid {
    grid-template-columns: 1fr;
  }

  .task-row {
    gap: 8px;
    padding: 12px 0;
  }

  .task-row input[type="checkbox"] {
    grid-row: 1;
  }

  .status-select {
    width: 160px;
  }

  .timeline-search {
    min-width: 0;
  }

  .timeline-list.calendar-view {
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .calendar-month {
    min-width: 720px;
  }

  .calendar-carousel-header,
  .log-activity-header {
    display: grid;
  }

  .calendar-carousel-controls {
    justify-content: flex-start;
  }

  .log-activity-summary {
    text-align: left;
  }

  .panel-header {
    display: grid;
  }

  .date-field {
    min-width: 0;
  }

  .form-actions,
  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .format-toolbar {
    justify-content: flex-start;
  }

  .form-actions button,
  .modal-actions button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
