:root {
  --parch: #f7e6bb;
  --parch-dark: #ecd29c;
  --line: #dcbf86;
  --wood: #b0743f;
  --wood-light: #dba366;
  --wood-dark: #6b3d1b;
  --ink: #3a2614;
  --muted: #84633f;
  --cream: #fff6dc;
  --red: #c4382c;
  --orange: #d4791c;
  --green: #4f9a3a;
  --blue: #3f74b8;
  --purple: #8e5bc4;
  --teal: #3f8f9a;
  --gold: #ffd84a;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #78b84a;
  color: var(--ink);
  font: 17px/1.35 "Pixelify Sans", ui-monospace, monospace;
  -webkit-font-smoothing: none;
}

a { color: var(--blue); }

#world {
  position: fixed;
  inset: 0;
  display: block;
  image-rendering: pixelated;
  touch-action: none;
}

/* A wooden frame around parchment, built from flat shadows so it stays crisp. */
.wood {
  background: var(--parch);
  color: var(--ink);
  border: 3px solid var(--wood-dark);
  border-radius: 7px;
  box-shadow:
    inset 0 0 0 3px var(--wood),
    inset 0 0 0 5px var(--wood-light),
    0 4px 0 var(--wood-dark),
    0 10px 22px rgba(30, 20, 5, 0.35);
  padding: 12px 14px;
}

h2 {
  font-size: 19px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.3px;
}

.btn, #hotbar button, select, input, textarea { font: inherit; }

a.btn { text-decoration: none; }
.btn {
  display: inline-block;
  font-size: 15px;
  line-height: 1.2;
  color: var(--cream);
  background: var(--wood);
  border: 2px solid var(--wood-dark);
  border-radius: 4px;
  padding: 4px 10px 5px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: inset 0 2px 0 var(--wood-light), 0 2px 0 var(--wood-dark);
  text-shadow: 0 1px 0 var(--wood-dark);
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(2px); box-shadow: inset 0 2px 0 var(--wood-light); }
.btn.small { font-size: 13px; padding: 2px 8px 3px; }
.btn.go { background: var(--green); box-shadow: inset 0 2px 0 #7cc45f, 0 2px 0 var(--wood-dark); }
.btn.danger { background: var(--red); box-shadow: inset 0 2px 0 #e06a5c, 0 2px 0 var(--wood-dark); }
.btn[disabled] { opacity: 0.55; cursor: default; }

.x {
  background: none;
  border: 0;
  font: 600 26px/1 "Pixelify Sans", monospace;
  color: var(--wood-dark);
  cursor: pointer;
  padding: 0 4px;
}

.tag {
  display: inline-block;
  font-size: 12px;
  line-height: 1.3;
  padding: 0 5px;
  border-radius: 3px;
  margin-right: 5px;
  color: #fff;
  background: var(--muted);
  vertical-align: 1px;
}
.tag.ask { background: var(--red); }
.tag.comments { background: var(--orange); }
.tag.review { background: var(--purple); }
.tag.todo { background: var(--green); }
.tag.email { background: var(--blue); }
.tag.done { background: var(--teal); }

/* --- Clock ----------------------------------------------------------------- */

#clock {
  position: fixed;
  top: 10px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 5;
  padding: 7px 10px;
  font-size: 17px;
}
#clock img { width: 20px; height: 20px; image-rendering: pixelated; }
#clock .time { font-weight: 600; }
#clock .sync { font-size: 13px; color: var(--muted); }
#clock .sync:empty { display: none; }
#clock .sync .err { color: var(--red); }

/* --- Hotbar ----------------------------------------------------------------- */

#hotbar {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 8px;
  z-index: 5;
}
#hotbar button {
  position: relative;
  width: 66px;
  height: 66px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: var(--parch-dark);
  border: 2px solid var(--wood);
  border-radius: 4px;
  box-shadow: inset 0 0 0 2px #f6dfae;
  cursor: pointer;
  color: var(--ink);
  padding: 0;
}
#hotbar button:hover { background: #f2dca8; }
#hotbar button[aria-pressed="true"] { border-color: var(--gold); box-shadow: inset 0 0 0 2px var(--gold), 0 0 0 2px var(--wood-dark); }
#hotbar img { width: 36px; height: 36px; image-rendering: pixelated; object-fit: contain; }
#hotbar .lbl { font-size: 12px; line-height: 1; }
#hotbar .n {
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 13px;
  font-weight: 600;
  color: var(--cream);
  text-shadow: 1px 0 var(--wood-dark), -1px 0 var(--wood-dark), 0 1px var(--wood-dark), 0 -1px var(--wood-dark);
}
#hotbar .n.alert { color: #ffd0c8; }

/* --- Inventory (the list behind each hotbar slot) ------------------------------ */

#inventory {
  position: fixed;
  left: 50%;
  bottom: 104px;
  transform: translateX(-50%);
  width: min(780px, calc(100vw - 24px));
  max-height: min(68vh, calc(100vh - 220px));
  display: flex;
  flex-direction: column;
  z-index: 6;
}
#inventory[hidden] { display: none; }
.inv-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
#inv-body { overflow-y: auto; min-height: 0; padding-right: 2px; }

.rows { list-style: none; margin: 0; padding: 0; }
.rows > li {
  padding: 7px 4px;
  border-top: 2px dashed var(--line);
  cursor: pointer;
  border-radius: 3px;
}
.rows > li:hover { background: rgba(255, 255, 255, 0.35); }
.rows .line1 { display: flex; gap: 8px; align-items: baseline; }
.rows .num { color: var(--muted); min-width: 3.2em; }
.rows .t { flex: 1; min-width: 0; }
.rows .when { color: var(--muted); font-size: 14px; white-space: nowrap; }
.rows .line2 { padding-left: calc(3.2em + 8px); font-size: 14px; color: var(--muted); }
.rows .line2.flush { padding-left: 0; }
.rows .recap { display: block; margin-top: 2px; }
.list-h { font-weight: 600; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin: 12px 0 2px; }
.list-h:first-child { margin-top: 0; }

.chip {
  display: inline-block;
  font-size: 13px;
  line-height: 1.35;
  padding: 0 7px;
  border-radius: 9px;
  background: var(--parch-dark);
  color: var(--ink);
  white-space: nowrap;
  margin: 1px 3px 1px 0;
}
.chip.warn { background: var(--red); color: #fff; }
.chip.soon { background: var(--orange); color: #fff; }
.chip.good { background: var(--green); color: #fff; }

.todo-form { display: grid; gap: 6px; margin-bottom: 10px; }
.todo-form[hidden] { display: none; }
.todo-form .row { display: flex; gap: 6px; flex-wrap: wrap; }
.todo-form input[name="link"] { flex: 1; min-width: 140px; }
input, select, textarea {
  color: var(--ink);
  background: var(--cream);
  border: 2px solid var(--wood);
  border-radius: 4px;
  padding: 4px 8px;
  min-width: 0;
  font-size: 16px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--wood-dark); background: #fff; }
.todo-row { display: flex; gap: 8px; align-items: baseline; }
.todo-row input[type="checkbox"] { accent-color: var(--green); transform: translateY(2px); }
.todo-row.done .t { text-decoration: line-through; color: var(--muted); }

.guide { margin: 0; padding-left: 20px; }
.guide li { margin: 6px 0; }

/* --- Drawer (details for one thing) ------------------------------------------ */

#drawer {
  width: min(640px, calc(100vw - 24px));
  max-height: calc(100vh - 48px);
  padding: 18px 20px;
}
#drawer::backdrop { background: rgba(20, 14, 8, 0.4); }
#drawer > .x { position: absolute; top: 10px; right: 12px; }
#drawer h3 { margin: 0 32px 4px 0; font-size: 21px; font-weight: 600; }
#drawer .meta { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
#drawer .actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
#drawer h4 { font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin: 16px 0 4px; }
#drawer .comment { border-left: 3px solid var(--wood-light); padding: 2px 0 2px 10px; margin: 8px 0; font-size: 15px; }
#drawer .comment .who { color: var(--muted); font-size: 13px; }
#drawer .recap { background: rgba(255, 255, 255, 0.45); border: 2px solid var(--line); padding: 7px 10px; border-radius: 4px; margin: 6px 0; font-size: 15px; white-space: pre-wrap; }
#drawer form { display: grid; gap: 8px; }
#drawer label { display: grid; gap: 3px; font-size: 14px; color: var(--muted); }
#drawer textarea { min-height: 80px; resize: vertical; }
.mono { font-family: ui-monospace, monospace; font-size: 13px; }

.tip {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  max-width: 320px;
  padding: 7px 11px;
  font-size: 15px;
  box-shadow: inset 0 0 0 2px var(--wood-light), 0 3px 0 var(--wood-dark);
}
.tip b { display: block; font-weight: 600; }
.tip .sub { color: var(--muted); font-size: 14px; }

/* --- Small screens -------------------------------------------------------- */

@media (max-width: 700px) {
  html, body { font-size: 16px; }
  #clock { font-size: 15px; gap: 6px; }
  #clock #date, #clock .sync, #clock .btn { display: none; }
  #hotbar { gap: 4px; padding: 6px; bottom: 8px; }
  #hotbar button { width: 50px; height: 50px; }
  #hotbar img { width: 28px; height: 28px; }
  #hotbar .lbl { display: none; }
  #inventory { bottom: 84px; max-height: calc(100vh - 170px); }
}
.repos { list-style: none; padding: 0; margin: 0; }
.repos li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 0; }
#inv-body h4 { margin: 14px 0 6px; }
