* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: #f4f6fb;

  display: flex;
  justify-content: center;
  align-items: center;

  min-height: 100vh;
  padding: 16px;
}

.app {
  width: 100%;
  max-width: 400px;
  background: white;
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 15px 35px rgba(0,0,0,0.12);
  position: relative;
}

header {
  text-align: center;
  position: relative;
}

.subtitle {
  font-size: 14px;
  color: #6b7280;
}

/* MENU BUTTON */
.history-btn {
  position: absolute;
  right: 0;
  top: 0;

  background: none;
  border: none;
  cursor: pointer;

  padding: 6px 10px;
  border-radius: 10px;

  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.history-btn:hover { background: #f3f4f6; }

/* PERFECT HAMBURGER ICON (3 lines) */
.menu-icon {
  width: 18px;
  height: 2px;
  background: #111827;
  border-radius: 2px;
  display: block;
  position: relative;
}

.menu-icon::before,
.menu-icon::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  background: #111827;
  border-radius: 2px;
}

.menu-icon::before { top: -6px; }
.menu-icon::after  { top:  6px; }

/* SMALL DROPDOWN MENU */
.hidden { display: none; }

.menu-popover {
  position: absolute;
  right: 0;
  top: 42px; /* below button */
  width: 190px;

  background: #111827;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 8px;

  box-shadow: 0 14px 30px rgba(0,0,0,0.25);
  z-index: 20;
}

.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 10px 10px;
  border-radius: 10px;

  background: transparent;
  border: none;
  cursor: pointer;

  color: #ffffff;
  font-size: 14px;
  text-align: left;
}

.menu-item:hover {
  background: rgba(255,255,255,0.08);
}

.menu-ico {
  width: 20px;
  display: inline-flex;
  justify-content: center;
}

/* WEEK STRIP */
.week-strip {
  display: flex;
  justify-content: space-between;
  margin: 18px 0;
  gap: 6px;
}

.day-box {
  width: 45px;
  padding: 8px 4px;
  text-align: center;
  border-radius: 10px;
  font-size: 12px;
  cursor: pointer;
  background: #f3f4f6;

  flex: 1;
  min-width: 40px;
}

.day-box.active {
  background: #4f46e5;
  color: white;
}

/* TODAY INDICATOR (PURPLE OUTLINE) */
.day-box.today {
  border: 2px solid #4f46e5;
}

.day-percent {
  font-size: 11px;
  margin-top: 4px;
}

.date-title {
  text-align: center;
  margin-top: 10px;
}

/* DAILY */
.progress {
  margin-top: 18px;
  text-align: center;
}

.chart-wrapper {
  position: relative;
  width: 200px;
  max-width: 70vw;
  margin: 0 auto;
}

.chart-wrapper canvas {
  width: 100% !important;
  height: auto !important;
}

.percent {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 26px;
  font-weight: bold;
}

.feedback {
  margin-top: 10px;
  font-size: 14px;
  color: #4b5563;
}

.tasks {
  margin-top: 24px;
}

.add-task {
  display: flex;
  gap: 10px;
}

.add-task input {
  flex: 1;
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
}

.add-task button {
  background: #4f46e5;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0 14px;
  font-size: 20px;
  cursor: pointer;
}

ul {
  list-style: none;
  padding: 0;
  margin-top: 14px;
}

li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #e5e7eb;
}

li.completed span {
  text-decoration: line-through;
  color: #9ca3af;
}

/* ===========================
   OVERLAY (History + Account + Pricing)
   =========================== */

.history-overlay {
  position: absolute;
  inset: 0;
  background: white;
  padding: 22px;
  border-radius: 18px;
  display: none;
  overflow-y: auto;
  z-index: 10;
}

.history-overlay.active { display: block; }

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.history-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.history-back,
.history-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 6px 10px;
  border-radius: 10px;
}
.history-back:hover,
.history-close:hover { background: #f3f4f6; }

.history-year-select {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 14px;
  background: #fff;
}

.history-subtitle {
  margin: 0 0 14px 0;
  color: #6b7280;
  font-size: 13px;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-card {
  background: #f9fafb;
  padding: 14px;
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  font-size: 13px;
  border: 1px solid #eef2f7;
}

.history-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

.history-card .muted {
  color: #6b7280;
  font-size: 12px;
  margin-top: 6px;
}

.history-day-top {
  text-align: center;
  margin-top: 6px;
}

.history-donut-wrap {
  position: relative;
  width: 180px;
  max-width: 70vw;
  margin: 14px auto 8px;
}

.history-donut-wrap canvas {
  width: 100% !important;
  height: auto !important;
}

.history-day-percent {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  font-weight: 900;
  color: #111827;
}

.history-day-meta {
  color: #6b7280;
  font-size: 13px;
  margin-bottom: 10px;
}

.history-tasks-readonly li {
  border-bottom: 1px solid #eef2f7;
  padding: 10px 0;
}

.history-soft {
  margin: 14px 0 0 0;
  text-align: center;
  color: #6b7280;
  font-size: 13px;
}

/* MOBILE */
@media (max-width: 480px) {
  body { padding: 10px; align-items: flex-start; }

  .app {
    max-width: 100%;
    padding: 18px;
    border-radius: 16px;
  }

  .day-box {
    min-width: 36px;
    font-size: 11px;
    padding: 8px 2px;
  }

  .day-percent { font-size: 10px; }
  .chart-wrapper { width: 180px; }
  .percent { font-size: 24px; }

  .history-grid { grid-template-columns: repeat(2, 1fr); }

  .menu-popover {
    width: 100%;
    right: 0;
    left: 0;
    top: 44px;
  }
}

/* DESKTOP */
@media (min-width: 900px) {
  body { padding: 32px; }

  .app {
    max-width: 460px;
    padding: 26px;
    border-radius: 20px;
  }

  .chart-wrapper { width: 220px; }
  .percent { font-size: 28px; }
}

/* Short height */
@media (max-height: 650px) {
  body { align-items: flex-start; }
}