:root {
  color-scheme: light;
  --bg: #f8f4f1;
  --card: #ffffff;
  --ink: #25211f;
  --muted: #827b74;
  --line: #eee7e0;
  --pink: #f7dce5;
  --pink-strong: #e78ca9;
  --green: #dcebd9;
  --green-strong: #93b88d;
  --peony: #cf6687;
  --indigo: #2e407a;
  --mint: #7eae83;
  --coral: #df8276;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 12%, rgba(247, 220, 229, 0.9), transparent 28%),
    radial-gradient(circle at 78% 20%, rgba(220, 235, 217, 0.85), transparent 30%),
    var(--bg);
  color: var(--ink);
}

button, input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--green-strong);
  color: white;
  min-height: 42px;
  padding: 0 14px;
}

.app-shell {
  max-width: 560px;
  min-height: 100svh;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 18px calc(env(safe-area-inset-bottom) + 128px);
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

h1, h2, p {
  margin: 0;
}

h1 {
  font-size: 36px;
  letter-spacing: 0;
}

h2 {
  font-size: 19px;
}

.icon-button {
  width: 46px;
  padding: 0;
  font-size: 22px;
}

.settings-button {
  background: white;
  color: var(--green-strong);
  box-shadow: 0 8px 22px rgba(70, 56, 50, 0.08);
}

.menu-panel {
  margin-top: 16px;
  padding: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 14px 34px rgba(70, 56, 50, 0.08);
}

.menu-panel[hidden] {
  display: none;
}

.menu-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.menu-row p,
.toggle-row small,
.section-title p,
.empty-state p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.toggle-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed rgba(147, 184, 141, 0.45);
}

.toggle-row span,
.toggle-row small {
  display: block;
}

.toggle-row input {
  appearance: none;
  width: 54px;
  height: 32px;
  border-radius: 999px;
  background: #e7ded6;
  position: relative;
  transition: background 0.2s ease;
}

.toggle-row input::before {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  left: 4px;
  top: 4px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(60, 45, 50, 0.18);
  transition: transform 0.2s ease;
}

.toggle-row input:checked {
  background: var(--green-strong);
}

.toggle-row input:checked::before {
  transform: translateX(22px);
}

.memo-card, .project-card {
  background: var(--card);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(70, 56, 50, 0.08);
}

.memo-card {
  position: relative;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.9);
}

.hero-memo {
  min-height: 178px;
  overflow: hidden;
}

.memo-tape {
  position: absolute;
  width: 96px;
  height: 22px;
  left: 50%;
  top: -8px;
  transform: translateX(-50%) rotate(-2deg);
  background: rgba(220, 235, 217, 0.92);
  border-radius: 5px;
  box-shadow: 0 6px 14px rgba(80, 70, 62, 0.08);
}

.memo-content {
  min-height: 142px;
  display: grid;
  align-content: center;
}

.mini-stamp {
  display: inline-flex;
  width: max-content;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--pink);
  color: #a94b68;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 12px;
}

.character-name {
  margin-bottom: 6px;
  font-weight: 700;
}

.label {
  color: var(--muted);
  font-size: 12px;
}

.focus-title {
  font-size: 24px;
  font-weight: 800;
}

.deadline {
  margin-top: 8px;
  color: #a94b68;
  font-size: 32px;
  font-weight: 800;
}

.meter {
  height: 9px;
  overflow: hidden;
  margin-top: 14px;
  border-radius: 999px;
  background: #eee9e3;
}

.meter > span {
  display: block;
  width: var(--progress);
  height: 100%;
  background: var(--accent, var(--peony));
}

.stats {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.stepper-row {
  display: grid;
  grid-template-columns: 46px 1fr 46px;
  align-items: center;
  gap: 12px;
  text-align: center;
  margin-top: 14px;
}

.stepper-row button, .section-title button {
  padding: 0;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--peony);
}

.project-memo {
  background:
    linear-gradient(#fff 0 0) padding-box,
    repeating-linear-gradient(0deg, transparent 0 33px, rgba(220, 235, 217, 0.55) 34px 35px);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title button {
  width: 42px;
  background: var(--pink-strong);
}

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

.project-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent, var(--peony));
}

.project-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.project-title {
  font-weight: 800;
}

.client {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.project-card .deadline-small {
  color: #a94b68;
  font-size: 13px;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.project-actions {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 10px;
  margin-top: 12px;
}

.project-actions button {
  min-height: 38px;
  font-size: 14px;
}

.edit-project {
  background: #eee8e1;
  color: var(--ink);
}

.complete-project {
  background: var(--green-strong);
}

.completed-list {
  margin-top: 14px;
}

.completed-list details {
  border-top: 1px dashed rgba(147, 184, 141, 0.6);
  padding-top: 12px;
}

.completed-list summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
}

.completed-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  color: var(--muted);
}

.completed-item button {
  min-height: 34px;
  background: var(--pink);
  color: #a94b68;
}

.empty-state {
  padding: 8px 0;
}

.floating-companion {
  position: fixed;
  right: max(4px, calc((100vw - 560px) / 2 + 4px));
  bottom: calc(env(safe-area-inset-bottom) + 2px);
  width: 330px;
  height: 230px;
  z-index: 6;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  animation: companionFloat 4.2s ease-in-out infinite;
}

.floating-companion.is-hidden {
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
}

.speech-bubble {
  position: absolute;
  right: 174px;
  bottom: 58px;
  width: 158px;
  min-height: 82px;
  padding: 10px 12px;
  border-radius: 18px 18px 6px 18px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 12px 28px rgba(60, 45, 50, 0.14);
  border: 2px solid rgba(247, 220, 229, 0.92);
  pointer-events: auto;
}

.speech-bubble::after {
  content: "";
  position: absolute;
  right: -8px;
  bottom: 26px;
  width: 18px;
  height: 18px;
  background: rgba(255, 255, 255, 0.94);
  border-right: 2px solid rgba(247, 220, 229, 0.92);
  border-bottom: 2px solid rgba(247, 220, 229, 0.92);
  transform: rotate(-45deg);
}

.speech-bubble .character-name {
  display: block;
  color: #a94b68;
  font-size: 13px;
  font-weight: 900;
  margin-bottom: 5px;
}

.speech-bubble #characterLine {
  display: block;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.floating-character {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 164px;
  height: 176px;
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: none;
}

.floating-character span {
  display: block;
  width: 100%;
  height: 100%;
  background-image: var(--sprite);
  background-size: contain;
  background-position: center bottom;
  background-repeat: no-repeat;
  filter: drop-shadow(0 12px 16px rgba(60, 45, 50, 0.18));
}

@keyframes companionFloat {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-12px) rotate(1deg); }
}

dialog {
  width: min(92vw, 440px);
  border: 0;
  border-radius: 8px;
  padding: 0;
}

dialog::backdrop {
  background: rgba(20, 18, 16, 0.45);
}

.project-form {
  display: grid;
  gap: 12px;
  padding: 18px;
}

@media (max-width: 380px) {
  .app-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  h1 {
    font-size: 32px;
  }

  .floating-companion {
    right: max(2px, calc((100vw - 560px) / 2 + 2px));
    width: 304px;
    height: 212px;
  }

  .speech-bubble {
    right: 156px;
    bottom: 52px;
    width: 150px;
    min-height: 74px;
  }

  .speech-bubble #characterLine {
    font-size: 12px;
  }

  .floating-character {
    width: 146px;
    height: 160px;
  }
}

.project-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid #d7d1c8;
  border-radius: 8px;
  padding: 8px 10px;
}

.project-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

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

.complete-dialog-button {
  width: 100%;
  background: var(--pink);
  color: #a94b68;
}

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

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.dialog-actions button:first-child {
  background: #e8e2da;
  color: var(--ink);
}

.dialog-actions button:last-child {
  background: var(--green-strong);
}
