:root {
  --bg: #f6f1e5;
  --panel: #fffaf0;
  --ink: #2e2a22;
  --muted: #786f5f;
  --green: #587444;
  --green-dark: #3e5b30;
  --line: rgba(56, 46, 32, 0.14);
  --danger: #c94132;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: max(14px, env(safe-area-inset-top)) 14px 12px;
  background: #1f170e;
  color: #fff8df;
}

.topbar h1 {
  margin: 0 0 4px;
  font-size: 22px;
}

.topbar p,
.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.topbar p {
  color: rgba(255, 248, 223, 0.72);
}

main {
  padding: 12px 10px 40px;
}

.panel,
.item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 250, 240, 0.94);
  box-shadow: 0 10px 28px rgba(54, 39, 20, 0.14);
}

.panel {
  padding: 14px;
}

h2,
h3 {
  margin: 0 0 12px;
}

.form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(62, 91, 48, 0.24);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  padding: 9px 10px;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: var(--green);
  color: #fff;
  font: inherit;
  font-weight: 900;
  padding: 8px 12px;
}

.secondary,
.icon {
  border: 1px solid rgba(62, 91, 48, 0.2);
  background: rgba(255, 250, 240, 0.86);
  color: var(--green-dark);
}

.danger {
  background: var(--danger);
}

.icon {
  width: 44px;
  flex: 0 0 auto;
  font-size: 20px;
}

.icon.add {
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: 28px;
  line-height: 1;
}

.add-wide {
  width: 100%;
  border: 1px dashed rgba(62, 91, 48, 0.32);
  background: rgba(88, 116, 68, 0.1);
  color: var(--green-dark);
}

.code-row,
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.item {
  padding: 12px;
}

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

.month-card {
  padding: 0;
  overflow: hidden;
}

.month-head {
  display: flex;
  width: 100%;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.month-head span:first-child {
  display: grid;
  gap: 2px;
}

.month-head em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.month-card > div:not(.hidden) {
  border-top: 1px solid var(--line);
  padding: 12px;
}

.status {
  display: inline-grid;
  min-width: 58px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.status.done {
  background: rgba(88, 116, 68, 0.18);
  color: var(--green-dark);
}

.status.todo {
  background: rgba(201, 65, 50, 0.12);
  color: #9b352b;
}

.item-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.editor-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 46px;
  height: 30px;
  border-radius: 999px;
  background: rgba(88, 116, 68, 0.16);
  color: var(--green-dark);
  font-weight: 900;
  padding: 0 10px;
}

.question,
.submission {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 10px;
}

.editable-question {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.52);
  padding: 10px;
}

.editable-question textarea {
  min-height: 72px;
}

.editable-question.saved input,
.editable-question.saved textarea {
  border-color: transparent;
  background: rgba(88, 116, 68, 0.07);
  color: var(--ink);
  opacity: 1;
}

.editable-question.editing {
  background: rgba(255, 255, 255, 0.74);
  box-shadow: inset 0 0 0 1px rgba(88, 116, 68, 0.12);
}

.answer {
  border-radius: 8px;
  background: rgba(88, 116, 68, 0.08);
  padding: 8px;
  font-size: 13px;
}

.error {
  margin: 0;
  color: var(--danger);
  font-weight: 800;
}

.hidden {
  display: none !important;
}

.compact {
  gap: 8px;
}

@media (max-width: 420px) {
  .row {
    grid-template-columns: 1fr;
  }
}
