:root {
  --bg: #f8f7f2;
  --panel: #fffdfa;
  --border: #20160a;
  --accent: #1f5eff;
  --text: #1f130a;
  --muted: #6c6259;
  --column-divider-width: 0px;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(120deg, #fefefe, #f7f4ea);
  color: var(--text);
}

.page {
  margin: 0 auto;
  padding: 0.5rem;
  width: 100%;
  max-width: 960px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: flex-end;
  flex-wrap: wrap;
  border: 3px solid var(--border);
  padding: 1rem;
  background: var(--panel);
  box-shadow: 7px 9px 0 var(--border);
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.app-header h1 {
  margin: 0.6rem 0;
  font-size: 3rem;
}

.lede {
  margin: 0;
  color: var(--muted);
}

button {
  font: inherit;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: none;
  position: relative;
  z-index: 1;
  box-shadow:
    0 0 0 0px var(--panel),
    0 0 0 6px var(--accent);
}

.ghost {
  border: 3px solid var(--border);
  background: transparent;
  padding: 0.75rem 1.25rem;
  font-weight: 600;
}

main {
  margin-top: 2rem;
  display: grid;
  gap: 1.5rem;
  justify-items: center;
}

.add-course-row {
  margin: 1.5rem auto 0;
  width: 100%;
  max-width: 800px;
  display: flex;
  justify-content: flex-start;
}

.add-course-row .ghost {
  width: 100%;
  text-align: left;
  background: var(--panel);
  box-shadow: 7px 9px 0 var(--border);
}

.course-card {
  border: 3px solid var(--border);
  background: var(--panel);
  box-shadow: 7px 9px 0 var(--border);
  width: 100%;
  max-width: 800px;
  margin-inline: auto;
  font-size: 1.1rem;
}

.course-header {
  display: flex;
  justify-content: space-between;
  position: relative;
  flex-wrap: wrap;
  column-gap: 1rem;
  row-gap: 0.25rem;
  padding: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 5px solid var(--border);
  align-items: flex-start;
}

.course-name {
  border: none;
  border-bottom: 5px solid var(--border);
  font-size: 2.6rem;
  flex: 1 1 auto;
  width: 100%;
  padding-right: 0;
  min-width: 200px;
  font-weight: 700;
  background: transparent;
  padding: 0.1rem 0 0.25rem;
}

.goal-input {
  margin: 0.15rem 0 0;
  width: 100%;
  border: none;
  border-radius: 0;
  font-size: 1.3rem;
  background: transparent;
  color: var(--text);
  line-height: 1.2;
}

.goal-input::placeholder {
  color: var(--muted);
}

.card-body {
  padding: 1rem 1rem 1rem;
  overflow-x: auto;
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.items-table th,
.items-table td {
  border-bottom: 5px solid var(--border);
  text-align: left;
  font-size: 1.2rem;
}

.items-table td + td {
  border-left: var(--column-divider-width) solid var(--border);
}

.items-table th + th {
  border-left: none;
}

.items-table th:first-child,
.items-table td:first-child {
  width: 42%;
}

.items-table th:nth-child(2),
.items-table td:nth-child(2),
.items-table th:nth-child(3),
.items-table td:nth-child(3) {
  width: 26%;
  min-width: 70px;
  text-align: center;
}

.items-table th:nth-child(4),
.items-table td:nth-child(4) {
  width: 1%;
  text-align: right;
  padding-inline: 0.2rem;
  white-space: nowrap;
}

.items-table tbody tr:first-child td {
  border-top: 5px solid var(--border);
}

.items-table input[type="text"],
.items-table input[type="number"] {
  display: block;
  width: 100%;
  min-width: 0;
  height: 100%;
  border: none;
  font-size: 1.3rem;
  background: transparent;
  padding: 0.35rem 0.4rem;
  box-sizing: border-box;
}
.items-table input[type="number"] {
  text-align: center;
}

input[type='number'] {
  -moz-appearance: textfield;
}

input[type='number']::-webkit-outer-spin-button,
input[type='number']::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.actions {
  display: flex;
  justify-content: flex-end;
}

.actions-right {
  justify-content: flex-end;
}

.icon-button {
  border: none;
  background: transparent;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  color: var(--border);
}

.delete-item-button {
  border: none;
  background: transparent;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  color: var(--border);
}

.remove-course {
  margin-left: 0;
  margin-right: 0;
  position: absolute;
  top: 1rem;
  right: 1rem;
}

.item-main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.item-main .item-name {
  flex: 1;
  padding: 0.4rem 0;
}

.toggle-children {
  flex-shrink: 0;
  font-size: 1rem;
  transform: translateY(-1px);
  /*margin-left: -0.4rem;  align arrow with left edge */
}

.add-sub-item {
  flex-shrink: 0;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  padding: 0.1rem 0.4rem;
  width: 100%;
  text-align: left;
}

.add-sub-item[hidden] {
  display: none;
}

.item-row.sub-item .add-sub-item {
  display: none;
}

.item-row.sub-item .item-main {
  position: relative;
  padding-left: 2.6rem;
}

.item-row.sub-item .item-main::before {
  content: '↳';
  position: absolute;
  left: 0.9rem;
  color: var(--muted);
}

.item-row.sub-item .item-main::after {
  content: '';
  position: absolute;
  left: -1px;
  width: 2.34rem;
  height: 7px;
  bottom: -7px;
  background: var(--panel);
  pointer-events: none;
  z-index: 1;
}

.item-row.sub-item .item-name {
  padding-left: 0.25rem;
}

.item-row.sub-item {
  position: relative;
}

.sub-add-row {
  position: relative;
}

.sub-add-row td {
  border: none;
  padding: 0;
}

.sub-add-row .add-sub-item {
  min-width: 0;
  width: calc(100% - 2.36rem);
  padding: 0.4rem 0.4rem 0.4rem 0;
  margin-left: 2.36rem;
  display: block;
  height: 100%;
  text-align: left;
  white-space: nowrap;
}

.derived-value {
  color: var(--muted);
  user-select: none;
  caret-color: transparent;
}

.derived-value:focus-visible {
  outline: none;
}

.flash-highlight {
  animation: derived-flash 0.7s ease-out forwards;
  background: rgba(31, 94, 255, 0.12);
  box-shadow: 0 0 0 3px rgba(31, 94, 255, 0.35);
}

.enter-hint {
  position: absolute;
  pointer-events: none;
  font-size: 1.3rem;
  color: var(--accent);
  background: transparent;
  padding: 0;
  transform: translate(-95%, -50%);
  z-index: 2000;
  white-space: nowrap;
}

@keyframes derived-flash {
  0% {
    background: rgba(31, 94, 255, 0.25);
    box-shadow: 0 0 0 5px rgba(31, 94, 255, 0.5);
  }
  100% {
    background: transparent;
    box-shadow: none;
  }
}

.text-button {
  border: none;
  font-weight: 600;
  color: var(--accent);
  padding: 0.6rem 0.5rem;
  background: transparent;
  display: block;
  width: 100%;
  text-align: left;
}

.text-button:hover,
.text-button:focus-visible {
  background: rgba(31, 94, 255, 0.15);
}

.totals {
  display: flex;
  gap: 1.5rem;
  margin: 1rem 0;
  align-items: flex-end;
  justify-content: flex-start;
}

.totals > div {
  text-align: left;
  display: flex;
  flex-direction: column;
}

.totals-spacer {
  display: none;
}

.goal-total {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.3rem;
  font-size: 1.2rem;
}

.goal-label {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
}

.header-goal {
  position: static;
  width: auto;
  text-align: left;
}

.header-goal .goal-input {
  padding: 0.15rem 0.2rem;
  text-align: center;
  width: 2.6ch;
  font-size: 1.2rem;
}

.goal-suffix {
  font-size: 1.2rem;
  font-weight: 600;
}

.label {
  margin: 0;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.value {
  margin: 0.15rem 0 0;
  font-size: 1.7rem;
  font-weight: 600;
}

.weight-warning {
  background: #fff4ce;
  border-left: 4px solid #f0a202;
  padding: 0.5rem 0.5rem;
  margin: 0.5rem 0 0.25rem;
  font-weight: 600;
}

.needed-copy {
  margin: 0.5rem 0 0.75rem;
  font-size: 1.4rem;
  font-weight: 700;
}

.needed-copy span {
  color: var(--accent);
}

@media (max-width: 700px) {
  :root {
    font-size: 18px;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
  }

  .course-header {
    flex-direction: column;
    align-items: stretch;
  }

  .course-name {
    width: 100%;
    padding-right: 3.5rem;
  }

  .header-goal {
    position: static;
    width: 100%;
    text-align: left;
  }

  .header-goal .goal-input {
    text-align: center;
  }

  .actions {
    justify-content: flex-end;
  }
}
.goal-warning {
  background: #fff4ce;
  border-left: 4px solid #f0a202;
  padding: 0.5rem 0.5rem;
  margin: 0.5rem 0 0.25rem;
  font-weight: 600;
  cursor: pointer;
}
