:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --text: #1f2937;
  --muted: #687385;
  --line: #dfe5ef;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --green: #15803d;
  --green-soft: #dcfce7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --purple: #7c3aed;
  --purple-soft: #ede9fe;
  --yellow: #a16207;
  --yellow-soft: #fef3c7;
  --gray-soft: #eef2f7;
  --shadow: 0 16px 40px rgba(31, 41, 55, 0.10);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(219, 234, 254, 0.8), rgba(245, 247, 251, 0) 240px),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  max-width: 820px;
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 16px 10px;
  background: rgba(245, 247, 251, 0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(223, 229, 239, 0.8);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 19px;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

main {
  padding: 14px 16px 96px;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 8px 20px rgba(31, 41, 55, 0.08);
}

.today-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.date-label {
  margin-bottom: 4px;
  color: var(--muted);
  font-weight: 700;
}

.progress-card {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hero-side {
  display: grid;
  grid-template-columns: auto minmax(130px, 1fr);
  gap: 10px;
  align-items: center;
}

.progress-ring {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: conic-gradient(var(--blue) 0%, var(--gray-soft) 0);
  color: var(--text);
  font-weight: 800;
}

.progress-ring span {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--panel);
}

.progress-count {
  margin-bottom: 0;
  font-weight: 800;
}

.muted {
  margin-bottom: 0;
  color: var(--muted);
}

.sync-hero-inner {
  display: grid;
  gap: 6px;
  min-width: 132px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
}

.sync-hero-title {
  margin-bottom: 0;
  font-size: 12px;
  font-weight: 900;
}

.sync-hero-message {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}

.sync-hero-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 10px;
}

.tab {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.tab.active {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}

.view-root {
  display: grid;
  gap: 12px;
}

.sync-ok {
  border-color: rgba(21, 128, 61, 0.25);
  background: var(--green-soft);
}

.sync-warning {
  border-color: rgba(161, 98, 7, 0.35);
  background: var(--yellow-soft);
}

.sync-offline {
  border-color: rgba(104, 115, 133, 0.28);
  background: var(--gray-soft);
}

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

.metric {
  min-height: 72px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  text-align: left;
}

.metric-button {
  width: 100%;
  color: inherit;
  cursor: pointer;
}

.metric-button.active {
  border-color: var(--blue);
  background: var(--blue-soft);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.metric-value {
  margin-bottom: 0;
  font-size: 22px;
  font-weight: 900;
}

.metric-label {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.focus-panel > .panel {
  margin: 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 10px;
}

.panel-title {
  margin-bottom: 0;
  font-size: 16px;
}

.panel-subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.section {
  border-top: 1px solid var(--line);
}

.section-toggle {
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 0;
  background: var(--panel);
  color: var(--text);
  text-align: left;
}

.section-chevron {
  width: 24px;
  color: var(--muted);
  font-weight: 900;
}

.section-name {
  font-weight: 850;
}

.section-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.task-list {
  display: grid;
  gap: 8px;
  padding: 0 10px 12px;
}

.task-card {
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 12px;
  background: var(--panel-2);
  overflow: hidden;
}

.task-card[data-status="実行中"] {
  border-left-color: var(--purple);
}

.task-card[data-status="繰越"] {
  border-left-color: var(--yellow);
}

.task-card[data-status="完了"] {
  border-left-color: var(--green);
}

.task-main {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.status-mark {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--green);
  font-size: 14px;
  font-weight: 900;
}

.task-title {
  margin-bottom: 3px;
  font-weight: 800;
  line-height: 1.4;
}

.task-meta {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--gray-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.badge.status-実行中 {
  background: var(--purple-soft);
  color: var(--purple);
}

.badge.status-繰越 {
  background: var(--yellow-soft);
  color: var(--yellow);
}

.badge.status-完了 {
  background: var(--green-soft);
  color: var(--green);
}

.task-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(66px, 1fr));
  gap: 6px;
  padding: 0 10px 10px;
}

.active-timer-panel {
  border-color: rgba(124, 58, 237, 0.22);
  box-shadow: 0 10px 26px rgba(124, 58, 237, 0.10);
}

.active-timer-list {
  display: grid;
  gap: 8px;
  padding: 0 10px 12px;
}

.active-timer-item {
  border: 1px solid var(--line);
  border-left: 5px solid var(--purple);
  border-radius: 12px;
  background: var(--panel-2);
  overflow: hidden;
}

.compact-main {
  grid-template-columns: 1fr auto;
}

.active-timer-time {
  margin: 6px 0 4px;
  color: var(--purple);
  font-size: 30px;
  font-weight: 950;
  line-height: 1.05;
}

.action-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.action-button.danger,
.mini-delete {
  color: var(--red);
}

.tool-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px;
}

.tool-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.compact-action {
  width: auto;
  min-width: 66px;
  padding: 0 12px;
}

.primary-button {
  min-height: 42px;
  border: 1px solid var(--blue);
  border-radius: 10px;
  background: var(--blue);
  color: white;
  font-size: 14px;
  font-weight: 900;
}

.event-list,
.calendar-list,
.check-list {
  display: grid;
  gap: 8px;
  padding: 0 14px 14px;
}

.planner-form {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px;
}

.carry-panel {
  margin: 0 10px 10px;
  padding-top: 10px;
  border: 1px solid rgba(161, 98, 7, 0.24);
  border-radius: 12px;
  background: var(--yellow-soft);
}

.carry-header {
  padding: 0 14px 8px;
}

.carry-header h3 {
  margin-bottom: 0;
  font-size: 14px;
}

.planner-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.planner-form input,
.planner-form select,
.planner-form textarea {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  padding: 0 10px;
}

.planner-form textarea {
  min-height: 78px;
  resize: vertical;
  padding-top: 10px;
}

.detail-edit-form {
  padding: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.markdown-export {
  border-top: 1px solid var(--line);
}

.export-header {
  padding-bottom: 8px;
}

.export-textarea {
  width: calc(100% - 28px);
  min-height: 280px;
  margin: 0 14px 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text);
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
}

.export-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 14px 14px;
}

.event-item,
.calendar-day,
.check-item {
  display: grid;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 12px;
  background: var(--panel-2);
}

.event-item {
  grid-template-columns: auto 1fr auto;
}

.calendar-day,
.check-item {
  grid-template-columns: auto 1fr;
}

.event-time {
  min-width: 70px;
  color: var(--blue);
  font-weight: 900;
}

.event-task-label {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--purple-soft);
  color: var(--purple);
  font-size: 11px;
  font-weight: 900;
}

.mini-delete {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  font-size: 18px;
  font-weight: 900;
}

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

.calendar-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 10px;
}

.calendar-nav {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--text);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.calendar-weekday {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-align: center;
}

.calendar-day {
  grid-template-columns: 1fr;
  min-height: 58px;
  border: 1px solid var(--line);
  text-align: center;
}

.calendar-day.empty-day {
  border-color: transparent;
  background: transparent;
}

.calendar-day.active {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.calendar-day strong {
  font-size: 16px;
}

.calendar-day span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.check-item {
  width: 100%;
  border: 0;
  color: inherit;
  text-align: left;
}

.check-item small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.project-map {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.project-chip {
  flex: 0 0 auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-panel {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: end;
  background: rgba(15, 23, 42, 0.36);
}

.detail-panel.open {
  display: flex;
}

.detail-sheet {
  width: 100%;
  max-height: 86vh;
  overflow: auto;
  padding: 16px;
  border-radius: 22px 22px 0 0;
  background: var(--panel);
}

.detail-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: -16px -16px 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.detail-header h2 {
  margin-bottom: 0;
}

.detail-back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 88px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.detail-block {
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
}

.detail-block p:last-child {
  margin-bottom: 0;
}

.empty {
  padding: 24px 16px;
  color: var(--muted);
  text-align: center;
}

@media (min-width: 720px) {
  .app-shell {
    padding: 0 18px;
  }

  .detail-panel {
    align-items: center;
    justify-content: center;
  }

  .detail-sheet {
    max-width: 640px;
    border-radius: 22px;
  }
}

@media (max-width: 420px) {
  main {
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar {
    padding-left: 12px;
    padding-right: 12px;
  }

  .today-hero {
    grid-template-columns: 1fr;
  }

  .hero-side {
    grid-template-columns: auto 1fr;
  }

  .tabs {
    grid-template-columns: repeat(3, minmax(88px, 1fr));
    overflow-x: auto;
  }

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

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