:root {
  color-scheme: light;
  font-family: "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  background: #f5f5f1;
  color: #25312d;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #f5f5f1;
}

#app-shell {
  display: grid;
  grid-template-rows: 0 minmax(0, 1fr) 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  transition: grid-template-rows 160ms ease;
}

body.counselcue-input-active #app-shell {
  grid-template-rows: 0 minmax(0, 1fr) 92px;
}

#unity-stage {
  grid-row: 2;
  display: grid;
  place-items: stretch;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

body.counselcue-input-active #unity-stage {
  align-items: stretch;
}

#unity-container {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: none;
  max-height: none;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #1f2d28;
}

body.counselcue-input-active #unity-container {
  width: 100%;
  height: 100%;
}

#unity-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #1f2d28;
  outline: none;
}

#unity-canvas:focus-visible,
#unity-fullscreen-button:focus-visible {
  outline: 3px solid #f3c778;
  outline-offset: 2px;
}

#unity-loading-bar {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: 32px;
  color: #ffffff;
  text-align: center;
  background: #173b30;
}

#unity-loading-bar[hidden] { display: none; }
#loading-title { font-size: 22px; font-weight: 800; letter-spacing: 0.08em; }
#loading-copy { font-size: 15px; color: #dce8e2; }

#unity-progress-bar-empty {
  width: min(320px, 70vw);
  height: 12px;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.22);
}

#unity-progress-bar-full {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #7ac7a6;
}

#unity-fullscreen-button {
  display: none;
}

#unity-fullscreen-button:hover { background: #245e47; }

#readability-controls {
  grid-row: 1;
  position: relative;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  padding: 4px max(8px, env(safe-area-inset-right)) 4px 8px;
  border: 0;
  border-bottom: 1px solid #d5ddd9;
  border-radius: 0;
  background: #ffffff;
  color: #25312d;
}

#readability-controls span {
  font-size: 13px;
  font-weight: 700;
}

#readability-toggle {
  min-height: 34px;
  border: 1px solid #245e47;
  border-radius: 4px;
  padding: 0 12px;
  background: #347a5d;
  color: #ffffff;
  font: 700 13px/1 "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  cursor: pointer;
}

#readability-toggle:focus-visible {
  outline: 3px solid #f3c778;
  outline-offset: 2px;
}

#unity-warning {
  position: absolute;
  z-index: 40;
  top: 70px;
  left: 50%;
  width: min(560px, calc(100% - 32px));
  transform: translateX(-50%);
}

#unity-warning[hidden] { display: none; }
.warning-message, .warning-error { margin-bottom: 8px; padding: 12px 16px; border-radius: 6px; }
.warning-message { color: #49320d; background: #fff1cc; }
.warning-error { color: #7a1f1f; background: #ffe4e4; }

#counselcue-composer-slot {
  grid-row: 3;
  display: grid;
  place-items: center;
  min-width: 0;
  overflow: hidden;
  background: #f5f5f1;
}

#cci {
  position: relative;
  z-index: 60;
  display: none;
  align-items: stretch;
  width: min(1040px, calc(100vw - 24px));
  gap: 10px;
  font-family: "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
}

#cci textarea {
  min-width: 0;
  flex: 1;
  height: 64px;
  resize: none;
  border: 1px solid #347a5d;
  border-radius: 6px;
  background: #ffffff;
  color: #25312d;
  padding: 15px 18px;
  font: 500 18px/1.5 "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  outline: none;
}

#cci textarea::placeholder { color: #596761; opacity: 1; }

#cci textarea:focus-visible,
.ccb:focus-visible,
#cch:focus-visible,
.ctb:focus-visible {
  outline: 3px solid #f3c778;
  outline-offset: 2px;
}

.ccb {
  min-width: 116px;
  height: 64px;
  border: 0;
  border: 1px solid #245e47;
  border-radius: 6px;
  padding: 0 18px;
  background: #347a5d;
  color: #fff;
  font: 700 17px/1 "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  cursor: pointer;
}

.ccb:hover { background: #245e47; }
.ccb:disabled { opacity: .55; cursor: not-allowed; }
.mic { background: #7a554a; }
.mic.on { background: #b84d4d; outline: 2px solid #8f3333; }

#ccn {
  position: absolute;
  left: 8px;
  bottom: 72px;
  color: #fff;
  background: rgba(23, 59, 48, .96);
  border-radius: 4px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
}

#cch {
  display: none;
}

#cct {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  font-family: "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  pointer-events: none;
}

#ccs {
  position: fixed;
  border: 2px solid #f3c778;
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(4, 15, 12, .79);
  transition: .25s;
}

#ccp {
  position: fixed;
  width: 390px;
  max-width: calc(100vw - 32px);
  background: #faf6ec;
  color: #25312d;
  border: 1px solid #b9c5bf;
  border-radius: 8px;
  padding: 22px 24px;
  pointer-events: auto;
}

#ccp h3 { margin: 0 0 8px; color: #245e47; font-size: 21px; }
#ccp p { margin: 0 0 18px; font-size: 16px; line-height: 1.65; }
.ctb { min-height: 44px; border: 1px solid #245e47; border-radius: 6px; padding: 10px 15px; font-weight: 700; cursor: pointer; }
.next { float: right; background: #347a5d; color: #fff; }

@media (max-width: 720px) {
  #unity-stage { padding: 0; }
  body.counselcue-input-active #unity-stage { align-items: stretch; }
  #unity-container,
  body.counselcue-input-active #unity-container {
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: 0;
  }
  #cci { width: calc(100vw - 16px); gap: 6px; }
  #cci textarea { height: 60px; padding: 13px 14px; font-size: 16px; }
  .ccb { min-width: 62px; height: 60px; padding: 0 10px; font-size: 15px; }
  .lbl { display: none; }
  #ccn { bottom: 66px; font-size: 12px; }
}

@media (max-width: 1000px), (max-aspect-ratio: 4/3) {
  #app-shell {
    grid-template-rows: 44px minmax(0, 1fr) 0;
  }

  body.counselcue-input-active #app-shell {
    grid-template-rows: 44px minmax(0, 1fr) 92px;
  }

  #readability-controls { display: flex; }

  body.counselcue-readable-mode #unity-stage {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    overflow: auto;
    padding: 8px;
    scrollbar-gutter: stable both-edges;
    overscroll-behavior: contain;
  }

  body.counselcue-readable-mode #unity-container,
  body.counselcue-readable-mode.counselcue-input-active #unity-container {
    width: 1280px;
    height: 720px;
    max-width: none;
    max-height: none;
    flex: 0 0 1280px;
    margin: 0;
    border-radius: 4px;
  }

  body.counselcue-readable-mode #counselcue-composer-slot {
    position: relative;
    z-index: 80;
  }
}
