:root {
  --ink: #191f28;
  --muted: #6b7684;
  --line: #e5e8eb;
  --line-strong: #d1d6db;
  --paper: #f2f4f6;
  --panel: #fbfcfd;
  --panel-raised: #ffffff;
  --accent: #64a8ff;
  --accent-strong: #4593fc;
  --accent-border: #90c2ff;
  --accent-soft: #f1f8ff;
  --soft: #f7f9fb;
  --shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
  --round-size: 72px;
  --blue: #4f7fbd;
  --red: #b55a5a;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
}

.start-page {
  min-width: 900px;
  min-height: 100vh;
  padding: 48px 30px;
  display: grid;
  place-items: start center;
}

.login-panel {
  width: min(1180px, 100%);
  display: grid;
  gap: 20px;
}

.login-box {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 20px;
  align-items: end;
}

.login-box h1 {
  font-size: 34px;
  line-height: 1.15;
  white-space: nowrap;
  word-break: keep-all;
}

.login-form {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) minmax(210px, 1fr) 96px 84px;
  gap: 10px;
  align-items: end;
}

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

.login-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 0 12px;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  background: var(--panel);
}

.login-form input::placeholder {
  color: #6b7684;
}

.login-form button,
#backToBooksButton {
  min-height: 42px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 0 16px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  word-break: keep-all;
}

#loginButton {
  border-color: var(--accent-border);
  background: var(--accent);
  color: #ffffff;
}

#loginButton:hover,
#loginButton:focus-visible {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: #ffffff;
}

.book-list {
  display: grid;
  gap: 14px;
}

.book-group {
  display: grid;
  gap: 8px;
}

.book-card {
  width: 100%;
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 24px;
  background: var(--panel-raised);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  display: grid;
  gap: 9px;
  box-shadow: var(--shadow);
}

.book-card:hover,
.book-card:focus-visible {
  outline: 3px solid rgba(100, 168, 255, 0.2);
  outline-offset: 3px;
  border-color: var(--accent-border);
  background: #f8fbff;
}

.book-card.is-selected {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.book-card-group {
  position: relative;
}

.tax-book-options {
  display: grid;
  gap: 8px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  padding: 0 12px;
  pointer-events: none;
  transform: translateY(-8px);
  transition:
    max-height 220ms ease,
    opacity 160ms ease,
    padding 220ms ease,
    transform 220ms ease;
}

.book-group.is-open .tax-book-options {
  max-height: 360px;
  opacity: 1;
  padding: 2px 12px 2px;
  pointer-events: auto;
  transform: translateY(0);
}

.tax-book-option {
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 17px;
  font-weight: 900;
  opacity: 0;
  transform: translateY(-6px);
  transition:
    opacity 180ms ease,
    transform 220ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

.book-group.is-open .tax-book-option {
  opacity: 1;
  transform: translateY(0);
}

.book-group.is-open .tax-book-option:nth-child(2) {
  transition-delay: 25ms;
}

.book-group.is-open .tax-book-option:nth-child(3) {
  transition-delay: 50ms;
}

.book-group.is-open .tax-book-option:nth-child(4) {
  transition-delay: 75ms;
}

.tax-book-option:hover,
.tax-book-option:focus-visible {
  border-color: var(--accent-border);
  background: #f8fbff;
}

.tax-book-option.is-selected {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.book-title {
  font-size: 24px;
  font-weight: 900;
}

.book-status {
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
}

.auth-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

#logoutButton {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.sync-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.app {
  min-width: 1100px;
  padding: 26px 30px 34px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0;
}

p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.summary {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 15px;
  font-weight: 800;
  color: var(--muted);
  white-space: nowrap;
}

#rowCount {
  display: flex;
  align-items: center;
  gap: 12px;
}

.summary-symbol {
  font-weight: 900;
}

#rowCount .symbol-o,
.book-status .symbol-o,
.cell-symbol.symbol-o {
  color: var(--ink);
}

#rowCount .symbol-x,
.book-status .symbol-x,
.cell-symbol.symbol-x {
  color: var(--red);
}

#rowCount .symbol-triangle,
.book-status .symbol-triangle,
.cell-symbol.symbol-triangle {
  color: var(--blue);
}

button {
  font: inherit;
  color: var(--ink);
  -webkit-text-fill-color: currentColor;
}

#resetButton {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  min-height: 42px;
  height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 800;
}

.table-shell {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  overflow: auto;
  max-height: calc(100vh - 120px);
  box-shadow: var(--shadow);
}

.review-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th:last-child,
td:last-child {
  border-right: 0;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel);
  height: 66px;
  font-size: 18px;
  font-weight: 800;
}

tbody tr:hover {
  background: #f8fbff;
}

.problem-row {
  cursor: pointer;
}

.problem-row.has-question-parts {
  background: #fbfcfd;
}

.question-part-row {
  background: #ffffff;
}

.problem-row:focus-within {
  background: #f8fbff;
}

td {
  height: 56px;
  padding: 8px 10px;
  font-size: 18px;
}

.col-type,
.col-problem {
  width: 124px;
  text-align: center;
  font-weight: 700;
}

.col-type {
  width: 96px;
}

.col-topic {
  width: 620px;
  white-space: normal;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: keep-all;
}

.topic-main {
  display: block;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: keep-all;
}

.problem-number-button {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  line-height: 1.2;
}

.problem-number-button:hover,
.problem-number-button:focus-visible {
  outline: 2px solid var(--accent-border);
  outline-offset: -2px;
  background: var(--accent-soft);
}

.question-part-spacer {
  background: #ffffff;
}

.question-part-topic-cell {
  color: var(--muted);
}

.question-part-label {
  position: relative;
  color: var(--ink);
  font-weight: 800;
  white-space: nowrap;
}

.question-part-title-trigger {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: grid;
  gap: 10px;
  text-align: left;
  font: inherit;
}

.question-part-title-trigger:hover,
.question-part-title-trigger:focus-visible {
  outline: 2px solid var(--accent-border);
  outline-offset: 2px;
  background: var(--accent-soft);
}

.question-part-title-text {
  min-width: 0;
  color: var(--muted);
  font-weight: 700;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: keep-all;
}

.question-part-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.question-part-note-preview {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: keep-all;
}

.question-part-editor {
  display: grid;
  gap: 9px;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--panel-raised);
}

.question-part-title-line {
  display: grid;
  grid-template-columns: max-content minmax(180px, 1fr);
  gap: 8px;
  align-items: center;
}

.question-part-title-input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 12px;
  background: var(--panel-raised);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
}

.question-part-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.question-part-editor-actions button {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.question-part-editor-actions button:hover,
.question-part-editor-actions button:focus-visible {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.col-round {
  width: var(--round-size);
  padding: 0;
  text-align: center;
}

.col-round.is-empty {
  background: #fbfcfd;
}

.col-days {
  width: 112px;
  text-align: center;
  font-weight: 800;
}

.unit-row td {
  height: 54px;
  padding: 9px 14px;
  background: var(--soft);
  font-size: 21px;
  font-weight: 800;
  text-align: left;
}

.round-label {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  font-size: 24px;
  line-height: 1;
}

.round-count-button {
  display: inline-grid;
  place-items: center;
  width: 100%;
  height: 66px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.round-count-button:hover,
.round-count-button:focus-visible {
  outline: 2px solid var(--accent-border);
  outline-offset: -5px;
  background: var(--accent-soft);
}

.round-cell {
  width: 100%;
  height: 56px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: grid;
  place-items: center;
  gap: 0;
  padding: 3px 2px;
}

.round-cell:hover,
.round-cell:focus-visible {
  outline: 2px solid var(--accent-border);
  outline-offset: -3px;
  background: var(--accent-soft);
}

.empty-box {
  width: 22px;
  height: 22px;
  border: 1.5px solid #8b95a1;
  background: var(--panel);
}

.cell-date {
  min-height: 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.cell-symbol {
  min-height: 28px;
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

.days-chip {
  display: inline;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.cell-menu,
.round-menu,
.question-menu {
  position: fixed;
  z-index: 10;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
}

.cell-menu {
  width: 232px;
  max-width: calc(100vw - 24px);
  overflow: hidden;
}

.round-menu,
.question-menu {
  display: grid;
  gap: 7px;
  width: 142px;
}

.menu-title {
  margin-bottom: 9px;
  font-size: 13px;
  font-weight: 800;
}

.symbol-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.symbol-options button,
.menu-actions button,
.round-menu button,
.question-menu button {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  -webkit-text-fill-color: currentColor;
  cursor: pointer;
}

.symbol-options button {
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
}

.symbol-options button[data-symbol="△"] {
  color: var(--blue);
}

.symbol-options button[data-symbol="X"] {
  color: var(--red);
}

.symbol-options button:hover,
.menu-actions button:hover,
.round-menu button:hover:not(:disabled),
.question-menu button:hover:not(:disabled),
#backToBooksButton:hover,
#logoutButton:hover,
.login-form button:hover,
#resetButton:hover {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.symbol-options button.is-selected {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-border);
}

.round-menu button:disabled,
.question-menu button:disabled {
  color: #8b95a1;
  cursor: not-allowed;
}

.date-field {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  min-width: 0;
}

.date-field input {
  display: block;
  width: calc(100% - 2px);
  max-width: 100%;
  min-width: 0;
  min-inline-size: 0;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 0 12px;
  appearance: none;
  -webkit-appearance: none;
  color: var(--ink);
  -webkit-text-fill-color: var(--ink);
  background: var(--soft);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}

.date-field input::-webkit-date-and-time-value {
  color: var(--ink);
  text-align: center;
}

.menu-actions {
  display: grid;
  grid-template-columns: 1fr 70px;
  gap: 6px;
  margin-top: 10px;
}

.menu-actions button {
  min-height: 40px;
  font-weight: 800;
}

.note-box,
.note-preview {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

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

.note-input {
  width: 100%;
  min-height: 88px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 11px 12px;
  background: var(--panel-raised);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  line-height: 1.45;
}

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

.note-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.note-actions button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 14px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.note-actions button:hover,
.note-actions button:focus-visible {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.note-preview {
  display: block;
  margin-top: 5px;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

.note-preview:hover,
.note-preview:focus-visible {
  outline: 0;
  color: var(--accent-strong);
}

.note-text {
  min-width: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: anywhere;
}

@media (max-width: 1180px) {
  .login-box {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .login-form {
    grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) 96px 84px;
  }

  .app {
    padding: 18px;
  }
}

@media (max-width: 720px) {
  .start-page {
    min-width: 0;
    padding: 22px 16px;
    place-items: start stretch;
  }

  .login-panel,
  .login-box,
  .login-form {
    width: 100%;
  }

  .login-box {
    display: grid;
    gap: 16px;
  }

  .login-box h1 {
    font-size: clamp(25px, 7vw, 28px);
  }

  .login-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .login-form label {
    grid-column: 1 / -1;
  }

  .login-form input {
    width: 100%;
  }

  .book-card {
    min-height: 0;
    padding: 18px;
  }

  .tax-book-options {
    padding: 0;
  }

  .book-group.is-open .tax-book-options {
    padding: 0;
    max-height: 420px;
  }

  .tax-book-option {
    display: grid;
    gap: 6px;
    min-height: 0;
    padding: 14px;
  }

  .book-title {
    font-size: 21px;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  .book-status,
  #rowCount {
    flex-wrap: wrap;
    gap: 6px 10px;
  }

  .app {
    min-width: 0;
    padding: 16px 12px 24px;
  }

  .app-header {
    display: grid;
    gap: 12px;
    margin-bottom: 12px;
  }

  .app-header h1 {
    font-size: 25px;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  .summary {
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    white-space: normal;
  }

  #backToBooksButton,
  #resetButton {
    flex: 1 1 132px;
  }

  .table-shell {
    max-height: calc(100vh - 170px);
    overflow: auto;
  }

  .review-table {
    min-width: 980px;
  }

  thead th {
    height: 54px;
    font-size: 15px;
  }

  td {
    height: 50px;
    font-size: 15px;
  }

  .col-type,
  .col-problem {
    width: 92px;
  }

  .col-type {
    width: 78px;
  }

  .col-topic {
    width: 520px;
    white-space: normal;
    line-height: 1.25;
  }

  .question-part-title-line {
    grid-template-columns: max-content minmax(120px, 1fr);
    gap: 6px;
  }

  .question-part-title-input {
    font-size: 14px;
  }

  .question-part-editor-actions button {
    padding: 0 9px;
    font-size: 14px;
  }

  .col-round {
    width: 58px;
  }

  .col-days {
    width: 94px;
  }

  .unit-row td {
    height: auto;
    padding: 10px 12px;
    font-size: 17px;
    line-height: 1.25;
    white-space: normal;
  }

  .round-count-button {
    height: 54px;
  }

  .round-label {
    width: 34px;
    height: 34px;
    font-size: 20px;
  }

  .round-cell {
    height: 50px;
  }

  .cell-symbol {
    font-size: 24px;
  }

  .cell-menu {
    width: min(280px, calc(100vw - 24px));
  }

  .note-actions {
    justify-content: stretch;
  }

  .note-actions button {
    flex: 1;
    padding: 0 10px;
  }

}
