:root {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Noto Sans", sans-serif;
  color: #202c40;
  background: #ffffff;
  font-size: 14px;
  --accent: #203b65;
  --line: #dce2eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: white;
  border-radius: 8px;
  padding: 10px 13px;
  color: inherit;
}

button:hover {
  background: #f0f4fa;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.primary:hover {
  background: #132a4c;
}

header {
  height: 88px;
  padding: 0 30px;
  display: flex;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: white;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.5px;
}

.logo {
  background: #203b65;
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 24px;
}

.brand small {
  display: block;
  font-size: 9px;
  letter-spacing: 2px;
  color: #65738a;
  margin-top: 5px;
}

.privacy {
  margin-left: auto;
  color: #52647f;
  font-size: 12px;
}

main {
  display: grid;
  grid-template-columns: 245px minmax(360px, 1fr) 335px;
  min-height: calc(100dvh - 128px);
}

aside {
  padding: 30px 24px;
  border-right: 1px solid var(--line);
  position: relative;
  display: flex;
  flex-direction: column;
}

.eyebrow {
  font-size: 10px;
  letter-spacing: 2px;
  color: #65738a;
  font-weight: 650;
}

h1 {
  font-size: 25px;
  line-height: 1.6;
  letter-spacing: -1px;
  margin: 23px 0 10px;
}

h2 {
  font-size: 21px;
  letter-spacing: -0.5px;
  font-weight: 650;
}

h2 span {
  float: right;
  color: var(--accent);
  font-size: 28px;
}

.muted {
  color: #5f6c80;
  line-height: 1.9;
  font-size: 12px;
}

.upload {
  border: 1px dashed #9aabc2;
  background: #f5f7fb;
  border-radius: 10px;
  padding: 19px 12px;
  text-align: center;
  cursor: pointer;
  margin-top: 23px;
  color: #203b65;
}

.upload small {
  display: block;
  font-size: 10px;
  margin-top: 9px;
  color: #5f6c80;
}

.upload.drag {
  background: #e7edf7;
}

.fileInfo {
  font-size: 11px;
  line-height: 1.7;
  overflow-wrap: anywhere;
  color: #65738a;
  padding: 14px 0;
}

nav {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}

nav button {
  text-align: left;
  display: flex;
  gap: 12px;
  border: none;
  background: transparent;
  padding: 14px;
  font-size: 12px;
  color: #68768b;
}

nav span {
  flex: 1;
  color: #344763;
  font-weight: 600;
}

nav button.active {
  background: #eaf0f9;
  color: var(--accent);
}

.asideFooter {
  margin-top: auto;
  padding-top: 45px;
  font-size: 9px;
  line-height: 2.5;
  letter-spacing: 1px;
  color: #65738a;
}

a {
  color: #294a7b;
}

.viewport {
  background: #ffffff;
  position: relative;
  height: 700px;
  max-height: 700px;
  min-height: 0;
  align-self: start;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.viewTop {
  position: absolute;
  top: 24px;
  left: 25px;
  right: 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 2;
}

.viewTop span {
  border: 1px solid #ccd6e5;
  font-size: 10px;
  padding: 7px 10px;
  border-radius: 30px;
  letter-spacing: 1.2px;
}

.viewTop button {
  font-size: 11px;
  background: #ffffffa0;
}

#canvasHost {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#empty {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  color: #66758c;
  pointer-events: none;
  padding-bottom: 70px;
}

#empty p {
  font-size: 12px;
}

.emptyIcon {
  font-size: 110px;
  color: #b5c2d6;
  font-weight: 200;
}

#empty h2 {
  font-size: 19px;
}

.viewBottom {
  z-index: 2;
  margin-top: auto;
  align-self: center;
  padding: 20px 12px 26px;
  display: grid;
  justify-items: center;
  gap: 15px;
}

.poses {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  background: #fffffff0;
  border: 1px solid #dce2eb;
  border-radius: 12px;
  padding: 5px;
  box-shadow: 0 5px 25px #142c4b12;
}

.poses button {
  font-size: 12px;
  border: none;
  background: transparent;
  padding: 10px 16px;
}

.poses .active {
  background: #203b65;
  color: white;
}

.viewTools {
  display: flex;
  gap: 15px;
  align-items: center;
  font-size: 11px;
}

.viewTools button {
  font-size: 11px;
  background: #ffffffa0;
}

.viewBottom small {
  font-size: 10px;
  color: #68768b;
}

.inspector {
  padding: 30px 23px;
  background: #fff;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

article {
  padding-top: 6px;
}

.card {
  background: #f7f9fc;
  border: 1px solid #e0e6ef;
  padding: 18px;
  border-radius: 12px;
  margin: 24px 0;
}

label {
  font-size: 12px;
  font-weight: 600;
}

.card output {
  float: right;
  background: #e8eef8;
  color: #203b65;
  border-radius: 5px;
  padding: 3px 7px;
  font-size: 11px;
}

.card p,
.hint {
  font-size: 11px;
  line-height: 1.85;
  color: #5f6c80;
}

.card input[type="range"] {
  width: 100%;
  margin: 22px 0 9px;
  accent-color: var(--accent);
}

.scale {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #5f6c80;
}

h3 {
  font-size: 12px;
  margin-top: 27px;
}

.choices {
  max-height: 260px;
  overflow: auto;
  display: grid;
  gap: 6px;
}

.choices label {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  border: 1px solid #e0e6ef;
  padding: 11px;
  border-radius: 7px;
  font-size: 11px;
  overflow-wrap: anywhere;
  font-weight: 400;
}

.choices input {
  accent-color: var(--accent);
  margin: 0;
  flex-shrink: 0;
}

.choices:empty:after {
  content: "VRMを読み込むと対象が表示されます";
  font-size: 11px;
  color: #68768b;
  padding: 20px 0;
}

.colorRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
}

input[type="color"] {
  width: 42px;
  height: 30px;
  border: 0;
  background: transparent;
}

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

.toggle input {
  accent-color: var(--accent);
}

.actions {
  margin-top: auto;
  padding-top: 30px;
  display: grid;
  gap: 9px;
}

.actions p {
  font-size: 11px;
  color: #65738a;
  line-height: 1.7;
  margin: 0 0 5px;
}

.actions button {
  width: 100%;
  font-size: 12px;
  padding: 13px;
}

footer {
  min-height: 40px;
  display: flex;
  justify-content: space-between;
  gap: 15px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 10px 24px;
  font-size: 10px;
  color: #65738a;
  background: white;
}

footer .error {
  color: #b14242;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
.upload:focus-within {
  outline: 3px solid #89a7d1;
  outline-offset: 3px;
}

@media (min-width: 1600px) {
  main {
    grid-template-columns: 270px 1fr 370px;
  }

  .inspector {
    padding: 35px;
  }
}

@media (max-width: 1050px) {
  main {
    grid-template-columns: 210px 1fr;
  }

  .inspector {
    grid-column: 1/-1;
    border-top: 1px solid var(--line);
  }

  .viewport {
    min-height: 0;
  }

  .choices {
    max-height: 190px;
  }

  header {
    padding: 0 20px;
  }

  .privacy {
    display: none;
  }
}

@media (max-width: 620px) {
  header {
    height: 75px;
    gap: 10px;
    padding: 0 12px;
  }

  .brand {
    font-size: 14px;
  }

  .brand small {
    font-size: 7px;
  }

  .logo {
    font-size: 18px;
    padding: 8px 10px;
  }

  header button {
    margin-left: auto;
    font-size: 10px;
    padding: 10px;
  }

  main {
    display: flex;
    flex-direction: column;
  }

  aside {
    padding: 20px;
    border-right: 0;
  }

  h1 {
    font-size: 22px;
    margin: 10px 0;
  }

  aside .muted,
  .asideFooter {
    display: none;
  }

  .upload {
    margin-top: 10px;
  }

  nav {
    display: flex;
    margin-top: 0;
  }

  nav button {
    flex: 1;
    padding: 10px;
    gap: 5px;
    font-size: 10px;
  }

  .viewport {
    min-height: 0;
    width: 100%;
    flex-shrink: 0;
  }

  .poses button {
    padding: 10px 12px;
    font-size: 11px;
  }

  .inspector {
    padding: 23px;
  }

  .fileInfo {
    padding: 10px 0;
  }

  footer {
    padding: 12px;
    align-items: flex-start;
  }

  footer > span:last-child {
    white-space: nowrap;
  }
}

/* White / navy theme: interactive states */
nav button.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

nav button.active span {
  color: var(--accent);
}

.upload:hover {
  background: #edf2fa;
  border-color: var(--accent);
}

.viewTools input {
  accent-color: var(--accent);
}

::selection {
  background: #d9e5f6;
  color: #152b4c;
}

#accessoryControls {
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 18px 0;
  padding: 14px;
}

#accessoryNumbers {
  display: grid;
  gap: 10px;
}

#accessoryNumbers label {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#accessoryNumbers input {
  width: 110px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
}

#accessoryRemove {
  margin-top: 15px;
}

#accessoryFile {
  max-width: 100%;
  margin: 16px 0;
}

/* Fixed application shell: only the two editing panels scroll. */
html {
  height: 100%;
  overflow: hidden;
}
body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
header,
footer {
  position: relative;
  z-index: 3;
  min-width: 0;
}
header > button {
  flex-shrink: 0;
}
main {
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  grid-template-rows: minmax(0, 1fr);
}
main > aside,
.inspector {
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
main > aside > *,
.inspector > * {
  flex-shrink: 0;
}
.viewport {
  height: 100%;
  max-height: 700px;
  min-width: 0;
  align-self: center;
}
footer {
  overflow-wrap: anywhere;
}
footer > span {
  min-width: 0;
}
footer > span:last-child {
  white-space: normal;
}
/* On narrow screens, keep the preview above two independently scrolling panels. */
@media (max-width: 1050px) {
  main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 3fr) minmax(0, 2fr);
  }
  .viewport {
    grid-column: 1 / -1;
    grid-row: 1;
  }
  main > aside {
    grid-column: 1;
    grid-row: 2;
    padding: 12px;
  }
  .inspector {
    grid-column: 2;
    grid-row: 2;
    padding: 12px;
  }
  .viewTop {
    top: 8px;
    left: 12px;
    right: 12px;
  }
  .viewBottom {
    padding: 8px;
    gap: 6px;
  }
  .viewBottom > small {
    display: none;
  }
  .poses button {
    padding: 7px 9px;
  }
  nav {
    display: grid;
  }
  footer {
    padding: 6px 12px;
    gap: 8px;
    font-size: 9px;
  }
  header .brand {
    font-size: 13px;
  }
  #accessoryNumbers label {
    flex-wrap: wrap;
    gap: 4px;
  }
  #accessoryNumbers input {
    max-width: 100%;
  }
}
