* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  height: 100dvh;
  background: #c8c8c8;
  font-family: "Segoe UI", "Malgun Gothic", sans-serif;
  color: #1f1f1f;
  overscroll-behavior: none;
}

button,
input,
a {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

.app {
  height: 100%;
  height: var(--vvh, 100dvh);
  display: grid;
  grid-template-rows: 32px 28px 52px 28px 1fr 44px 22px 28px;
  background: #fff;
  min-height: 0;
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 10px;
  background: #217346;
  color: #fff;
}

.app-mark {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  background: #fff;
  color: #217346;
  font-weight: 700;
  font-size: 13px;
  display: grid;
  place-items: center;
}

.filename {
  font-size: 12px;
  opacity: 0.95;
  flex: 1;
}

.win-btns {
  display: flex;
}

.win-btn {
  width: 46px;
  height: 32px;
  color: #fff;
  text-decoration: none;
  display: grid;
  place-items: center;
  font-size: 18px;
}

.win-btn:hover {
  background: #c75050;
}

.menubar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  background: #217346;
  color: #fff;
  font-size: 12px;
}

.menubar span {
  padding: 4px 10px;
  border-radius: 3px 3px 0 0;
}

.menubar .on {
  background: #fff;
  color: #217346;
}

.ribbon {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 6px 12px;
  background: #fff;
  border-bottom: 1px solid #d0d0d0;
}

.rib-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rib-btn {
  border: 1px solid #c6c6c6;
  background: #f8f8f8;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}

.rib-btn:hover:not(:disabled) {
  background: #e6f2ea;
  border-color: #217346;
}

.rib-btn.primary {
  background: #217346;
  color: #fff;
  border-color: #1a5c38;
}

.rib-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.stats-strip {
  font-size: 12px;
  color: #444;
  gap: 16px;
}

.stats-strip b {
  color: #217346;
}

.formula {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid #d0d0d0;
  background: #fff;
}

.fx {
  width: 36px;
  display: grid;
  place-items: center;
  font-style: italic;
  font-weight: 700;
  color: #666;
  border-right: 1px solid #d0d0d0;
}

.prompt {
  flex: 1;
  padding: 4px 10px;
  font-size: 13px;
  line-height: 20px;
  white-space: pre;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: "Malgun Gothic", "Segoe UI", sans-serif;
}

.prompt .ok {
  color: #217346;
}

.prompt .bad {
  color: #c00000;
  background: #ffe2e2;
}

.prompt .rest {
  color: #1f1f1f;
}

.sheet-wrap {
  min-height: 0;
  overflow: auto;
  background: #e6e6e6;
}

.sheet {
  display: grid;
  grid-template-columns: 36px 1fr;
  min-height: 100%;
}

.row-heads,
.col-heads {
  background: #f3f3f3;
  color: #555;
  font-size: 11px;
}

.row-heads {
  display: grid;
  border-right: 1px solid #c6c6c6;
}

.row-heads span {
  display: grid;
  place-items: center;
  border-bottom: 1px solid #d4d4d4;
}

.sheet-main {
  min-width: 720px;
}

.col-heads {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  height: 22px;
  border-bottom: 1px solid #c6c6c6;
}

.col-heads span {
  display: grid;
  place-items: center;
  border-right: 1px solid #d4d4d4;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
}

.cell {
  min-height: 22px;
  border-right: 1px solid #d4d4d4;
  border-bottom: 1px solid #d4d4d4;
  background: #fff;
  font-size: 12px;
  padding: 3px 6px;
  overflow: hidden;
  white-space: nowrap;
}

.cell.head {
  background: #e8f5ee;
  font-weight: 600;
  color: #1a5c38;
}

.cell.warn {
  background: #fff3cd;
}

.cell.hurt {
  background: #f8d0d0;
}

.cell.pix {
  padding: 0;
  min-height: 18px;
}

.type-dock {
  display: grid;
  grid-template-columns: 52px 1fr 48px;
  border-top: 1px solid #c6c6c6;
  background: #fff;
}

.cell-ref {
  display: grid;
  place-items: center;
  font-size: 12px;
  background: #f3f3f3;
  border-right: 1px solid #d0d0d0;
}

#type-input {
  border: 0;
  outline: none;
  padding: 0 12px;
  font-size: 16px;
  background: #fff;
}

#type-input:focus {
  box-shadow: inset 0 0 0 2px #217346;
}

.enter-btn {
  border: 0;
  background: #217346;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.enter-btn:disabled {
  background: #b7b7b7;
  cursor: default;
}

.statusbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 10px;
  background: #217346;
  color: #fff;
  font-size: 11px;
}

.statusbar b {
  font-weight: 700;
}

.hub-link {
  margin-left: auto;
  color: #fff;
  text-decoration: none;
  opacity: 0.85;
}

.sheet-tabs {
  display: flex;
  align-items: stretch;
  background: #f3f3f3;
  border-top: 1px solid #c6c6c6;
  padding: 0 8px;
  gap: 2px;
}

.tab {
  border: 1px solid transparent;
  border-bottom: 0;
  background: transparent;
  padding: 0 14px;
  font-size: 12px;
  color: #555;
  cursor: default;
}

.tab.on {
  background: #fff;
  border-color: #c6c6c6;
  color: #217346;
  font-weight: 600;
}

.tab.done {
  color: #217346;
}

.plus {
  padding: 0 10px;
  color: #888;
  display: grid;
  place-items: center;
}

.dialog-layer {
  position: fixed;
  inset: 0;
  background: rgba(32, 32, 32, 0.28);
  display: grid;
  place-items: center;
  z-index: 20;
}

.dialog {
  width: min(460px, calc(100% - 32px));
  background: #fff;
  border: 1px solid #8a8a8a;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  padding: 22px 22px 16px;
}

.dialog.slim {
  text-align: center;
}

.dialog h1,
.dialog h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 10px;
}

.dialog p {
  font-size: 13px;
  line-height: 1.55;
  color: #333;
}

.fine {
  margin-top: 8px;
  color: #777 !important;
  font-size: 12px !important;
}

.kicker {
  font-size: 11px !important;
  color: #217346 !important;
  letter-spacing: 0.04em;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.dlg-main {
  background: #217346;
  color: #fff;
  border: 1px solid #1a5c38;
  padding: 7px 16px;
  cursor: pointer;
}

.dlg-ghost {
  display: grid;
  place-items: center;
  padding: 7px 14px;
  color: #333;
  text-decoration: none;
  border: 1px solid #c6c6c6;
  background: #f8f8f8;
}

.result-stats {
  list-style: none;
  margin-top: 12px;
  font-size: 13px;
}

.result-stats li {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid #eee;
}

.float-num {
  position: fixed;
  pointer-events: none;
  font-weight: 700;
  font-size: 18px;
  z-index: 30;
  animation: rise 0.8s ease-out forwards;
}

.float-num.good {
  color: #217346;
}

.float-num.bad {
  color: #c00000;
}

@keyframes rise {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(-36px);
    opacity: 0;
  }
}

.cover {
  position: fixed;
  top: 112px;
  left: 0;
  right: 0;
  bottom: 50px;
  z-index: 15;
  background: #fff;
  overflow: auto;
  border-top: 1px solid #d0d0d0;
}

.fake-sheet {
  min-width: 640px;
}

.fake-row {
  display: grid;
  grid-template-columns: 1.4fr repeat(5, 1fr);
  border-bottom: 1px solid #d4d4d4;
  font-size: 13px;
}

.fake-row span {
  padding: 7px 10px;
  border-right: 1px solid #d4d4d4;
}

.fake-row.head {
  background: #e8f5ee;
  font-weight: 600;
  color: #1a5c38;
}

.fake-row.total {
  background: #f3f3f3;
  font-weight: 600;
}

@media (max-width: 760px) {
  .cover {
    top: 32px;
  }
  .app {
    grid-template-rows: 32px auto auto 1fr 48px 22px 28px;
  }
  .menubar {
    display: none;
  }
  .stats-strip {
    display: none;
  }
  .ribbon {
    flex-wrap: nowrap;
    gap: 8px;
    padding: 6px 10px;
    min-height: 44px;
    overflow-x: auto;
  }
  .rib-btn {
    padding: 8px 12px;
    font-size: 14px;
    flex: 0 0 auto;
  }
  .prompt {
    white-space: normal;
    overflow: auto;
    text-overflow: unset;
    min-height: 0;
    max-height: 72px;
    font-size: 15px;
    line-height: 1.45;
  }
  .formula {
    align-items: flex-start;
  }
  .sheet-main {
    min-width: 480px;
  }
  .type-dock {
    grid-template-columns: 44px 1fr 56px;
    height: 48px;
    min-height: 48px;
    max-height: 48px;
  }
  .enter-btn {
    font-size: 22px;
  }
  .sheet-tabs {
    overflow-x: auto;
  }
  .statusbar {
    padding-bottom: env(safe-area-inset-bottom);
  }
  .filename {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
