@font-face {
  font-family: "MiSans";
  src: url("./assets/fonts/MiSans-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "MiSans";
  src: url("./assets/fonts/MiSans-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-serf: "Noto Serif SC", serif;
  --font-sans: "Noto Sans SC", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --font-misans: "MiSans", "Noto Sans SC", sans-serif;
  --font-klee: "Klee One", cursive;
  --text: rgba(255, 255, 255, 0.78);
  --muted: rgba(255, 255, 255, 0.45);
  --glass: rgba(170, 180, 170, 0.1);
  --glass-border: rgba(255, 255, 255, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-serf);
  background: #0a0f13;
  color: var(--text);
}

.scene-bg {
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle at 25% 68%, rgba(97, 126, 85, 0.55), transparent 34%),
    radial-gradient(circle at 77% 72%, rgba(173, 181, 167, 0.42), transparent 35%),
    radial-gradient(circle at 50% 20%, rgba(101, 71, 44, 0.48), transparent 30%),
    linear-gradient(125deg, #101820, #29313d 48%, #171d24);
  filter: blur(18px) saturate(0.92) brightness(0.82);
  transform: scale(1.06);
}

#weather-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

.glass {
  background: linear-gradient(145deg, rgba(38, 54, 77, 0.28), rgba(22, 34, 52, 0.4));
  border: 1px solid rgba(190, 212, 245, 0.2);
  backdrop-filter: blur(18px) saturate(1.05);
  -webkit-backdrop-filter: blur(18px) saturate(1.05);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 24px 80px rgba(0, 0, 0, 0.36);
}

.toolbar {
  position: fixed;
  left: 16px;
  top: 20px;
  z-index: 8;
}

.font-panel {
  width: 52px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
}

.type-icon {
  width: 50px;
  height: 50px;
  margin: 0;
  border-radius: 50%;
  border: 1px solid rgba(225, 232, 243, 0.28);
  background: linear-gradient(180deg, rgba(33, 38, 47, 0.82), rgba(20, 24, 31, 0.84));
  color: rgba(245, 247, 252, 0.84);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.font-panel-body {
  width: 102px;
  border-radius: 20px;
  padding: 9px 9px 10px;
  background: linear-gradient(180deg, rgba(29, 35, 44, 0.9), rgba(19, 24, 31, 0.9));
  border: 1px solid rgba(214, 223, 238, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 16px 40px rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.font-panel:hover .font-panel-body {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.font-panel:focus-within .font-panel-body {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.group-title {
  margin: 0;
  font-size: 10px;
  color: rgba(214, 225, 242, 0.42);
  letter-spacing: 0.06em;
  text-align: left;
  padding-left: 4px;
}

.divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 6px 4px;
}

.font-list,
.font-size {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.font-size {
  flex-direction: row;
  justify-content: center;
  gap: 4px;
  margin-top: 8px;
}

.font-list button,
.font-size button,
.writer-actions button,
.top-mode-switch button,
.panel-item button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.font-list button,
.font-size button {
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.1;
  text-align: center;
  padding: 8px 8px;
}

.font-size button {
  text-align: center;
  padding: 5px 5px;
  font-size: 11px;
  min-width: 23px;
}

.font-list button.active,
.font-size button.active,
.top-mode-switch button.active {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.9);
  font-weight: 600;
}

.writer-wrap {
  position: relative;
  z-index: 3;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 64px 24px 120px;
}

.writer {
  width: min(900px, 88vw);
  height: min(600px, 72vh);
  border-radius: 18px;
  padding: clamp(20px, 2.2vw, 34px);
  position: relative;
  background: linear-gradient(145deg, rgba(36, 51, 74, 0.38), rgba(28, 41, 61, 0.52));
  border: 1px solid rgba(186, 207, 238, 0.24);
}

#editor {
  width: 100%;
  height: 100%;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.74);
  font: 400 24px/1.58 var(--font-serf);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
  caret-color: rgba(255, 255, 255, 0.95);
}

#editor::placeholder {
  color: rgba(255, 255, 255, 0.42);
}

.writer-actions {
  position: absolute;
  right: 24px;
  bottom: 18px;
  display: flex;
  gap: 18px;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.writer:hover .writer-actions {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.writer-actions button {
  font-family: var(--font-klee);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: rgba(247, 250, 255, 0.34);
}

.writer-actions button:hover {
  color: rgba(255, 255, 255, 0.7);
}

.top-mode-switch {
  z-index: 8;
  border-radius: 999px;
  padding: 4px 8px;
  display: flex;
  gap: 0;
  background: linear-gradient(180deg, rgba(78, 67, 56, 0.6), rgba(53, 47, 42, 0.58));
  border: 1px solid rgba(239, 226, 208, 0.24);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 8px 22px rgba(0, 0, 0, 0.34);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.top-mode-switch button {
  font-size: 12px;
  font-family: var(--font-klee);
  border-radius: 0;
  padding: 10px 16px;
  letter-spacing: 0.02em;
  color: rgba(241, 234, 224, 0.45);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  min-width: 110px;
  justify-content: center;
  line-height: 1;
}

.top-mode-switch button + button {
  border-left: 1px solid rgba(237, 223, 201, 0.24);
}

.top-mode-switch .mode-ico-img {
  width: 17px;
  height: 17px;
  object-fit: contain;
  opacity: 0.48;
  filter: grayscale(1) brightness(0) invert(1);
  transition: opacity 0.2s ease, filter 0.2s ease;
  display: block;
  flex: 0 0 auto;
}

.top-mode-switch button[data-mode="snowy"] .mode-ico-img {
  width: 22px;
  height: 22px;
}

.top-mode-switch button.active {
  background: transparent;
  color: rgba(255, 255, 255, 0.86);
  font-weight: 600;
}

.top-mode-switch button.active .mode-ico-img {
  opacity: 0.82;
  filter: grayscale(1) brightness(0) invert(1);
}

.top-mode-switch button:not(.active):hover {
  color: rgba(246, 239, 229, 0.66);
}

.top-mode-switch button:not(.active):hover .mode-ico-img {
  opacity: 0.62;
  filter: grayscale(1) brightness(0) invert(1);
}

.top-mode-shell {
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 260px;
  height: 64px;
  z-index: 8;
  display: grid;
  place-items: start center;
}

.top-mode-shell.is-open .top-mode-switch {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.bottom-controls {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 8;
  width: min(560px, calc(100vw - 32px));
  display: grid;
  justify-items: center;
}

.settings-fab {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1px solid rgba(226, 235, 245, 0.4);
  background: linear-gradient(180deg, rgba(117, 126, 138, 0.4), rgba(72, 82, 95, 0.6));
  color: rgba(236, 244, 255, 0.88);
  font-size: 15px;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3), inset 0 0 0 2px rgba(245, 250, 255, 0.14);
}

.bottom-panel {
  position: absolute;
  bottom: 66px;
  border-radius: 16px;
  width: min(520px, calc(100vw - 32px));
  padding: 11px 16px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  background: linear-gradient(180deg, rgba(132, 132, 129, 0.62), rgba(114, 117, 123, 0.6));
  border: 1px solid rgba(236, 239, 244, 0.24);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.bottom-controls.is-open .bottom-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.panel-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-item label,
.panel-item span {
  font-size: 10px;
  font-family: var(--font-klee);
  color: rgba(246, 249, 255, 0.6);
  letter-spacing: 0.14em;
  font-weight: 500;
}

.panel-item span {
  color: rgba(248, 251, 255, 0.7);
  letter-spacing: 0.06em;
}

.panel-divider {
  width: 1px;
  height: 39px;
  background: rgba(225, 233, 244, 0.26);
  justify-self: center;
}

.panel-item input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  border-radius: 999px;
  background: rgba(241, 245, 252, 0.32);
  outline: none;
}

.panel-item input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #f2f5fb;
  border: 1px solid rgba(146, 154, 166, 0.5);
  box-shadow: 0 2px 6px rgba(10, 12, 15, 0.24);
}

.panel-item input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #eef5ff;
  border: 1px solid rgba(61, 87, 122, 0.5);
}

.settings-icon {
  width: 18px;
  height: 18px;
  stroke: rgba(240, 246, 255, 0.94);
  stroke-width: 1.6;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.panel-head label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
}

.panel-ico-img {
  width: 14px;
  height: 14px;
  object-fit: contain;
  opacity: 0.58;
  filter: grayscale(1) brightness(0) invert(1);
  display: block;
  flex: 0 0 auto;
  margin-top: 0;
}

#weather-icon[data-mode="snowy"] {
  width: 17px;
  height: 17px;
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(8, 11, 16, 0.58);
  display: grid;
  place-items: center;
  padding: 20px;
}

.confirm-overlay[hidden] {
  display: none !important;
}

.confirm-dialog {
  width: min(420px, calc(100vw - 40px));
  border-radius: 16px;
  padding: 16px 16px 14px;
  background: linear-gradient(180deg, rgba(38, 46, 58, 0.92), rgba(27, 33, 43, 0.92));
  border: 1px solid rgba(224, 233, 246, 0.26);
}

.confirm-dialog h3 {
  margin: 0 0 8px;
  font-family: var(--font-klee);
  font-size: 15px;
  color: rgba(247, 251, 255, 0.9);
}

.confirm-dialog p {
  margin: 0;
  font-family: var(--font-klee);
  font-size: 12px;
  line-height: 1.5;
  color: rgba(241, 247, 255, 0.72);
}

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

.confirm-actions button {
  border: 1px solid rgba(223, 233, 246, 0.24);
  border-radius: 10px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(246, 250, 255, 0.82);
  font-family: var(--font-klee);
  font-size: 12px;
  cursor: pointer;
}

#confirm-accept {
  border-color: rgba(239, 170, 170, 0.34);
  color: rgba(255, 220, 220, 0.9);
}

.credit {
  display: none;
}

body.font-serif #editor {
  font-family: var(--font-serf);
}

body.font-sans #editor {
  font-family: var(--font-sans);
}

body.font-mono #editor {
  font-family: var(--font-mono);
}

body.font-misans #editor {
  font-family: var(--font-misans);
}

body.font-klee #editor {
  font-family: var(--font-klee);
}

body.size-small #editor {
  font-size: clamp(14px, 1.2vw, 18px);
}

body.size-medium #editor {
  font-size: clamp(17px, 1.55vw, 24px);
}

body.size-large #editor {
  font-size: clamp(20px, 1.9vw, 30px);
}

@media (max-width: 900px) {
  .top-mode-switch button {
    font-size: 16px;
    padding: 6px 14px;
  }

  .writer {
    width: calc(100vw - 46px);
    height: min(70vh, 650px);
  }

  .writer-actions button {
    font-size: 16px;
  }

  .bottom-panel {
    grid-template-columns: 1fr;
    width: min(460px, calc(100vw - 22px));
  }

  .panel-divider {
    display: none;
  }

  .bottom-controls {
    width: min(480px, calc(100vw - 22px));
  }

  .credit {
    display: none;
  }
}
