:root {
  --bg: #f4f1ea;
  --panel: #ffffff;
  --ink: #23201c;
  --muted: #8a847a;
  --line: #e4ddd0;
  --accent: #2b5f4f;
  --accent-2: #d97a34;
  --shadow: 0 2px 8px rgba(35,32,28,0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 8%, rgba(43,95,79,0.06), transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(217,122,52,0.06), transparent 45%),
    var(--bg);
  color: var(--ink);
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  min-height: 100vh;
}

.ww-app { max-width: 1140px; margin: 0 auto; padding: 20px 16px 60px; }

/* header */
.ww-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.ww-brand { display: flex; align-items: center; gap: 14px; }
.ww-logo {
  width: 44px; height: 44px; display: grid; place-items: center;
  background: var(--accent); color: #fff; border-radius: 12px;
  font-size: 24px; box-shadow: var(--shadow);
}
.ww-header h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.ww-header p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.ww-header-tools { display: flex; gap: 8px; }

/* nav bar */
.ww-navbar {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 8px 12px; box-shadow: var(--shadow);
  margin-bottom: 14px; flex-wrap: wrap;
}
.ww-chev {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: #fbf9f4; font-size: 20px; cursor: pointer; color: var(--ink);
  line-height: 1; transition: background .15s;
}
.ww-chev:hover { background: var(--accent); color: #fff; }
.ww-monthlabel {
  font-size: 18px; font-weight: 700; letter-spacing: -0.01em;
  min-width: 160px; text-align: center;
}

/* buttons */
.ww-btn {
  border: 1px solid var(--line); background: #fbf9f4; color: var(--ink);
  border-radius: 9px; padding: 8px 14px; font-family: inherit; font-weight: 600;
  font-size: 14px; cursor: pointer; transition: all .15s;
}
.ww-btn.sm { padding: 6px 12px; font-size: 13px; }
.ww-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.ww-btn.primary:hover { filter: brightness(1.08); }
.ww-btn.ghost:hover { background: #efe9dd; }
.ww-btn.danger { color: #c0392b; border-color: #e8c3bd; background: #fdf2f0; }
.ww-btn.danger:hover { background: #f8e2de; }
.ww-mini {
  border: 1px solid var(--line); background: #fbf9f4; border-radius: 8px;
  padding: 0 12px; font-family: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.ww-mini:hover { background: #efe9dd; }

/* legend */
.ww-legend-wrap { margin-bottom: 14px; }
.ww-legend {
  display: flex; flex-wrap: wrap; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px; box-shadow: var(--shadow);
}
.ww-legend-empty {
  background: var(--panel); border: 1px dashed var(--line); border-radius: 14px;
  padding: 14px; color: var(--muted); font-size: 14px;
}
.ww-legend-item {
  display: flex; align-items: center; gap: 8px;
  background: #fbf9f4; border: 1px solid var(--line);
  border-radius: 10px; padding: 5px 8px 5px 5px;
}
.ww-swatch {
  width: 26px; height: 26px; border-radius: 7px; position: relative;
  cursor: pointer; overflow: hidden; flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}
.ww-swatch input[type="color"] {
  position: absolute; inset: -6px; width: 200%; height: 200%;
  border: none; padding: 0; cursor: pointer; opacity: 0;
}
.ww-legend-name {
  border: none; background: transparent; font-family: inherit; font-weight: 600;
  font-size: 14px; color: var(--ink); width: 120px; outline: none;
}
.ww-legend-name:focus { border-bottom: 1px solid var(--accent); }
.ww-count {
  font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--muted);
  background: #fff; border: 1px solid var(--line); border-radius: 20px;
  padding: 1px 8px; min-width: 22px; text-align: center;
}
.ww-legend-del {
  border: none; background: transparent; color: var(--muted); font-size: 18px;
  cursor: pointer; line-height: 1; padding: 0 2px;
}
.ww-legend-del:hover { color: #c0392b; }

/* calendar */
.ww-cal {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 12px; box-shadow: var(--shadow);
}
.ww-dayhead { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 8px; }
.ww-dayhead-cell {
  text-align: center; font-family: 'IBM Plex Mono', monospace;
  font-size: 12px; font-weight: 600; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--muted); padding: 4px 0;
}
.ww-weekrow-wrap { position: relative; }
.ww-weekrow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 8px; }
.ww-copyweek {
  position: absolute; top: -3px; left: -12px; z-index: 2;
  width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; color: var(--accent); cursor: pointer; font-size: 12px;
  opacity: 0; transition: opacity .15s; box-shadow: var(--shadow);
}
.ww-weekrow-wrap:hover .ww-copyweek { opacity: 1; }

.ww-cell {
  background: #fbf9f4; border: 1px solid var(--line); border-radius: 12px;
  min-height: 108px; padding: 8px; display: flex; flex-direction: column;
  transition: border-color .15s;
}
.ww-cell:hover { border-color: #cdc4b2; }
.ww-cell.empty { background: transparent; border: 1px dashed #eee6d8; }
.ww-cell.today { border: 2px solid var(--accent-2); background: #fff8f0; }

.ww-cell-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.ww-daynum { font-weight: 700; font-size: 15px; color: var(--ink); }
.ww-cell.today .ww-daynum { color: var(--accent-2); }
.ww-add {
  width: 22px; height: 22px; border-radius: 6px; border: 1px dashed var(--line);
  background: transparent; color: var(--muted); font-size: 15px; line-height: 1;
  cursor: pointer; transition: all .15s;
}
.ww-add:hover { background: var(--accent); color: #fff; border-color: var(--accent); border-style: solid; }

.ww-chips { display: flex; flex-direction: column; gap: 5px; flex: 1; }
.ww-empty-hint { color: #cbc2b0; font-size: 13px; text-align: center; margin-top: 8px; }
.ww-chip {
  border: none; border-radius: 8px; padding: 5px 8px; text-align: left;
  cursor: pointer; font-family: inherit; display: flex; flex-direction: column;
  transition: transform .1s, box-shadow .1s;
}
.ww-chip:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0,0,0,0.15); }
.ww-chip-name { font-weight: 600; font-size: 13px; line-height: 1.2; }
.ww-chip-time { font-family: 'IBM Plex Mono', monospace; font-size: 10px; opacity: 0.85; margin-top: 2px; }

.ww-empty-state, .ww-onboard {
  text-align: center; color: var(--muted); font-size: 14px; padding: 16px;
}
.ww-onboard {
  margin-top: 14px; background: var(--panel); border: 1px dashed var(--line);
  border-radius: 14px;
}

/* footer */
.ww-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 13px; flex-wrap: wrap; gap: 8px;
}
.ww-footer a { color: var(--accent); font-weight: 600; text-decoration: none; }
.ww-footer a:hover { text-decoration: underline; }

/* modal */
.ww-backdrop {
  position: fixed; inset: 0; background: rgba(35,32,28,0.4);
  display: grid; place-items: center; padding: 16px; z-index: 50;
  animation: ww-fade .15s ease;
}
@keyframes ww-fade { from { opacity: 0; } to { opacity: 1; } }
.ww-modal {
  background: var(--panel); border-radius: 18px; padding: 22px;
  width: 100%; max-width: 400px; box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  animation: ww-pop .2s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes ww-pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.ww-modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.ww-modal-head h3 { margin: 0; font-size: 20px; font-weight: 800; }
.ww-x { border: none; background: transparent; font-size: 26px; cursor: pointer; color: var(--muted); line-height: 1; }
.ww-x:hover { color: var(--ink); }
.ww-lbl {
  display: block; font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted);
  margin: 12px 0 5px;
}
.ww-input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-family: inherit; font-size: 15px; color: var(--ink);
  background: #fbf9f4; outline: none; transition: border-color .15s;
}
.ww-input:focus { border-color: var(--accent); background: #fff; }
select.ww-input { flex: 1; }
.ww-row { display: flex; gap: 8px; }
.ww-modal-actions { display: flex; gap: 8px; margin-top: 20px; align-items: center; }

/* toast */
.ww-toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 14px; font-weight: 500; z-index: 100; box-shadow: 0 8px 20px rgba(0,0,0,0.3);
  animation: ww-toast-in .25s ease;
}
@keyframes ww-toast-in { from { transform: translate(-50%, 16px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* responsive */
@media (max-width: 720px) {
  .ww-dayhead { display: none; }
  .ww-weekrow { grid-template-columns: 1fr; gap: 6px; }
  .ww-cell { min-height: auto; flex-direction: row; align-items: flex-start; gap: 10px; }
  .ww-cell.empty { display: none; }
  .ww-cell-head { flex-direction: column; margin: 0; min-width: 42px; align-items: center; gap: 6px; }
  .ww-daynum::after { content: attr(data-dow); }
  .ww-chips { min-height: 24px; }
  .ww-copyweek { left: auto; right: 4px; top: 4px; opacity: 1; }
  .ww-monthlabel { min-width: 0; flex: 1; }
}