*  {
  box-sizing: border-box;
}

body  {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  color: #111;
  background: #fff;
  font-family: Arial, "Noto Sans KR", sans-serif;
}

button, input, textarea  {
  font: inherit;
}

.app-shell  {
  flex: 1;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
  min-height: 0;
  padding: 24px;
}

.editor-panel  {
  border: 1px solid #ccc;
  padding: 16px;
}

h1  {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.control-group, .stacked-field, .field-grid label  {
  display: grid;
  gap: 6px;
}

.control-group, .field-grid, .stacked-field  {
  margin-top: 14px;
}

.field-grid  {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.symbol-toolbar  {
  flex-wrap: wrap;
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.symbol-toolbar button  {
  min-width: 52px;
}

#clearInputsButton  {
  min-width: 88px;
}

.ritual-fields  {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

.ritual-header, .ritual-row  {
  display: grid;
  grid-template-columns: 38px 1fr 1fr 1fr 1fr;
  gap: 6px;
  align-items: center;
}

.ritual-header  {
  font-size: 12px;
  font-weight: bold;
}

label span, .control-group > label  {
  font-size: 14px;
  font-weight: bold;
}

input, textarea  {
  width: 100%;
  border: 1px solid #aaa;
  border-radius: 0;
  color: #111;
  background: #fff;
  outline: none;
}

input  {
  height: 34px;
  padding: 0 8px;
}

textarea  {
  min-height: 68px;
  resize: vertical;
  padding: 8px;
  line-height: 1.5;
}

#bodyInput  {
  min-height: 180px;
}

input:focus, textarea:focus  {
  border-color: #111;
}

.segmented  {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid #aaa;
}

.segmented input  {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.segmented label  {
  display: grid;
  min-height: 34px;
  place-items: center;
  border-right: 1px solid #aaa;
  font-size: 14px;
  cursor: pointer;
}

.segmented label:last-child  {
  border-right: 0;
}

.segmented input:checked + label  {
  color: #fff;
  background: #111;
}

.button-row  {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

button  {
  min-height: 36px;
  border: 1px solid #111;
  border-radius: 0;
  color: #111;
  background: #fff;
  cursor: pointer;
}

button:hover  {
  background: #eee;
}

.status-message  {
  min-height: 20px;
  margin: 10px 0 0;
  font-size: 13px;
}

.preview-panel  {
  display: grid;
  align-content: start;
  justify-content: center;
  padding: 16px;
  border: 1px solid #ccc;
  overflow: auto;
}

#handoutPreview  {
  width: max-content;
}

[hidden]  {
  display: none !important;
}

@media (max-width: 820px)  {
  .app-shell  {
    grid-template-columns: 1fr;
    padding: 12px;
  }
  .button-row  {
    grid-template-columns: 1fr;
  }
}

.home-page  {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 36px;
  padding: 64px 24px;
  text-align: center;
}

.home-page h1  {
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.4;
  word-break: keep-all;
}

.rule-grid  {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 200px));
  justify-content: center;
  gap: 16px;
  width: 100%;
  max-width: 848px;
}

.update-notice  {
  margin: -16px 0 0;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.rule-button  {
  aspect-ratio: 1 / 1;
  border: 1px solid #111;
  border-radius: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 12px;
  color: #111;
  text-decoration: none;
}

.rule-button span  {
  display: block;
  font-size: 13px;
  font-weight: normal;
  line-height: 1.5;
}

.rule-button strong  {
  display: block;
  font-size: 24px;
  line-height: 1.4;
  font-weight: 700;
  word-break: keep-all;
}

.rule-button:hover  {
  background: #eee;
  text-decoration: none;
}

a:focus-visible, button:focus-visible  {
  outline: 2px solid #111;
  outline-offset: 4px;
}

.back-link  {
  display: inline-block;
  color: #000;
  font-size: 14px;
  font-weight: bold;
  text-decoration: none;
  margin-bottom: 20px;
}

.site-footer  {
  padding: 24px;
  border-top: 1px solid #ddd;
  text-align: center;
  color: #555;
  font-size: 13px;
  line-height: 1.8;
  word-break: keep-all;
}

.site-footer p  {
  margin: 0;
}

.site-footer a  {
  color: inherit;
  text-underline-offset: 3px;
}

@media (max-width: 820px)  {
  .rule-grid  {
    grid-template-columns: repeat(2, minmax(0, 210px));
    max-width: 440px;
  }
}

@media (max-width: 420px)  {
  .home-page  {
    padding: 48px 16px;
    gap: 28px;
  }
  .rule-grid  {
    gap: 12px;
  }
  .rule-button span  {
    font-size: 11px;
  }
  .rule-button strong  {
    font-size: 19px;
  }
  .site-footer  {
    padding: 20px 16px;
  }
}

.three-tabs  {
  grid-template-columns: repeat(3, 1fr);
}

.two-tabs  {
  grid-template-columns: repeat(2, 1fr);
}

.fragment-fields  {
  display:grid;
  gap:12px;
  margin-top:14px;
}

.fragment-input-row  {
  display:grid;
  gap:8px;
}

.fragment-input-row label  {
  display:grid;
  gap:6px;
  min-width:0;
}
