:root {
  --bg-1: #f4f5f7;
  --bg-2: #fafbfc;
  --bg-3: #eceef2;
  --text: #17191c;
  --muted: rgba(23, 25, 28, 0.62);
  --line: rgba(23, 25, 28, 0.1);
  --line-strong: rgba(23, 25, 28, 0.18);
  --shadow: 0 24px 64px rgba(12, 16, 20, 0.12);
  --accent-a: #17191c;
  --accent-b: #17191c;
  --accent-c: #c23a2b;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.96) 0%, rgba(255, 255, 255, 0) 34%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 58%, var(--bg-3) 100%);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Avenir Next", "Futura", "Hiragino Sans", "Yu Gothic", sans-serif;
  background: transparent;
}

.app-header,
.app-footer {
  background: transparent;
  border-color: rgba(23, 25, 28, 0.08);
}

.app-header-brand,
.app-footer-link {
  color: rgba(23, 25, 28, 0.88);
}

.clock-shell {
  min-height: calc(100vh - 122px);
  padding: 16px;
}

.clock-stage {
  --face-bg: radial-gradient(circle at 36% 32%, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.9) 52%, rgba(245, 247, 250, 0.92) 100%);
  --face-shadow-a: rgba(12, 16, 20, 0.055);
  --face-shadow-b: rgba(12, 16, 20, 0.085);
  --tick-color: rgba(23, 25, 28, 0.34);
  --tick-major-color: rgba(23, 25, 28, 0.62);
  --numeral-color: rgba(23, 25, 28, 0.9);
  --hour-hand-color: #17191c;
  --minute-hand-color: #17191c;
  --second-hand-color: var(--accent-c);
  --center-cap-color: #17191c;
  --center-ring-color: rgba(255, 255, 255, 0.86);
  --panel-text: var(--text);
  --panel-line: var(--line-strong);
  --panel-bg: rgba(255, 255, 255, 0.08);
  --panel-bg-hover: rgba(23, 25, 28, 0.06);
  --panel-bg-active: rgba(23, 25, 28, 0.08);
  --panel-line-hover: rgba(23, 25, 28, 0.28);
  --status-color: rgba(23, 25, 28, 0.58);
  position: relative;
  min-height: calc(100vh - 154px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.42);
  box-shadow: 0 18px 42px rgba(12, 16, 20, 0.06);
  backdrop-filter: blur(10px);
  isolation: isolate;
}

.clock-stage[data-theme="light"]:not(.has-background) {
  background: #e6e7eb;
}

.clock-stage[data-theme="dark"] {
  --face-bg: radial-gradient(circle at 36% 32%, rgba(60, 67, 80, 0.98) 0%, rgba(28, 31, 38, 0.96) 58%, rgba(12, 14, 18, 0.98) 100%);
  --face-shadow-a: rgba(0, 0, 0, 0.22);
  --face-shadow-b: rgba(0, 0, 0, 0.34);
  --tick-color: rgba(255, 255, 255, 0.22);
  --tick-major-color: rgba(255, 255, 255, 0.46);
  --numeral-color: rgba(255, 255, 255, 0.92);
  --hour-hand-color: #f4f5f7;
  --minute-hand-color: #f4f5f7;
  --second-hand-color: #ff6a5e;
  --center-cap-color: #f4f5f7;
  --center-ring-color: rgba(18, 20, 24, 0.82);
  --panel-text: #f4f5f7;
  --panel-line: rgba(255, 255, 255, 0.24);
  --panel-bg: rgba(255, 255, 255, 0.08);
  --panel-bg-hover: rgba(255, 255, 255, 0.12);
  --panel-bg-active: rgba(255, 255, 255, 0.14);
  --panel-line-hover: rgba(255, 255, 255, 0.34);
  --status-color: rgba(255, 255, 255, 0.7);
  background: #2a2d33;
}

.clock-stage[data-theme="glass"] {
  --face-bg:
    linear-gradient(145deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.14)),
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.72) 0%, rgba(255, 255, 255, 0.16) 38%, rgba(168, 199, 255, 0.12) 100%);
  --face-shadow-a: rgba(90, 132, 200, 0.18);
  --face-shadow-b: rgba(64, 98, 160, 0.24);
  --tick-color: rgba(255, 255, 255, 0.56);
  --tick-major-color: rgba(255, 255, 255, 0.82);
  --numeral-color: rgba(255, 255, 255, 0.96);
  --hour-hand-color: rgba(255, 255, 255, 0.96);
  --minute-hand-color: var(--auto-minute-hand-color, rgba(210, 235, 255, 0.96));
  --second-hand-color: var(--auto-second-hand-color, rgba(120, 170, 255, 0.95));
  --center-cap-color: rgba(255, 255, 255, 0.98);
  --center-ring-color: rgba(177, 212, 255, 0.32);
  --panel-text: #f7fbff;
  --panel-line: rgba(255, 255, 255, 0.28);
  --panel-bg: rgba(255, 255, 255, 0.14);
  --panel-bg-hover: rgba(255, 255, 255, 0.2);
  --panel-bg-active: rgba(255, 255, 255, 0.24);
  --panel-line-hover: rgba(255, 255, 255, 0.38);
  --status-color: rgba(247, 251, 255, 0.82);
  background: #18345f;
}

.clock-stage.has-background {
  background-image: var(--clock-stage-image);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.clock-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(23, 25, 28, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 25, 28, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(180deg, black, transparent 92%);
  pointer-events: none;
}

.orb {
  display: none;
}

.clock-panel {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px 32px 36px;
  overflow: hidden;
}

.dial-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--dial-size, 620px);
  height: var(--dial-size, 620px);
  transform: translate(
    calc(-50% + var(--dial-offset-x, 0px)),
    calc(-50% + var(--dial-offset-y, 0px))
  );
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: none;
  cursor: default;
}

.dial-wrap.is-dragging {
  cursor: grabbing;
}

.clock-face {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  container-type: inline-size;
  border-radius: 50%;
  background: var(--face-bg);
  border: 0;
  box-shadow:
    0 14px 30px var(--face-shadow-a),
    0 28px 56px var(--face-shadow-b);
  overflow: hidden;
  isolation: isolate;
  user-select: none;
  -webkit-user-select: none;
}

.clock-face::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: transparent;
  pointer-events: none;
  z-index: 0;
}

.clock-stage[data-theme="glass"] .clock-face::before {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.08)),
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.28) 0%, rgba(255, 255, 255, 0.08) 42%, rgba(168, 199, 255, 0.08) 100%);
  backdrop-filter: blur(24px) saturate(1.18);
  -webkit-backdrop-filter: blur(24px) saturate(1.18);
}

.minute-tick {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1px;
  height: 48%;
  transform: translate(-50%, -100%) rotate(calc(var(--i) * 6deg));
  transform-origin: 50% 100%;
  z-index: 1;
}

.minute-tick::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 1px;
  height: 4.6%;
  transform: translateX(-50%);
  background: var(--tick-color);
}

.minute-tick.major::before {
  width: 2px;
  height: 6.4%;
  background: var(--tick-major-color);
}

.numeral {
  position: absolute;
  top: var(--y);
  left: var(--x);
  font-size: 8cqi;
  font-weight: 700;
  color: var(--numeral-color);
  transform: translate(-50%, -50%);
  z-index: 1;
}

.clock-stage[data-theme="glass"] .numeral {
  text-shadow: 0 0 0.08em var(--minute-hand-color);
}

.hand {
  position: absolute;
  left: 50%;
  bottom: 50%;
  transform-origin: 50% 100%;
  border-radius: 999px;
  will-change: transform;
  z-index: 2;
}

.hand.hour {
  width: 1.95cqi;
  height: 22%;
  margin-left: -0.975cqi;
  background: var(--hour-hand-color);
  box-shadow: none;
}

.hand.minute {
  width: 0.98cqi;
  height: 33%;
  margin-left: -0.49cqi;
  background: var(--minute-hand-color);
  box-shadow: none;
}

.hand.second {
  width: 0.33cqi;
  height: 36%;
  margin-left: -0.165cqi;
  background: var(--second-hand-color);
  box-shadow: none;
}

.hand.second.is-hidden {
  display: none;
}

.center-cap {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3.55cqi;
  height: 3.55cqi;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--center-cap-color);
  box-shadow: 0 0 0 0.97cqi var(--center-ring-color);
  z-index: 3;
}

.resize-handle {
  position: absolute;
  right: 3%;
  bottom: 3%;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(23, 25, 28, 0.18);
  border-radius: 50%;
  background:
    rgba(255, 255, 255, 0.94)
    url("../common/img/resize.png")
    center / contain
    no-repeat;
  box-shadow: 0 8px 20px rgba(12, 16, 20, 0.12);
  cursor: nwse-resize;
  opacity: 0;
  pointer-events: none;
}

.resize-handle::before {
  content: none;
}

.info-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 1120px;
  margin: 18px auto 0;
  padding: 16px 18px;
  border: 1px solid rgba(23, 25, 28, 0.1);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  color: #17191c;
  color-scheme: light;
}

.usage-panel {
  max-width: 1120px;
  margin: 18px auto 0;
  padding: 16px 18px;
  border: 1px solid rgba(23, 25, 28, 0.1);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(248, 250, 252, 0.96) 100%);
  backdrop-filter: blur(10px);
}

.usage-panel summary {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 1.02rem;
  font-weight: 700;
  color: #17191c;
}

.usage-panel summary::marker {
  content: "";
}

.usage-panel summary::-webkit-details-marker {
  display: none;
}

.usage-panel summary::before {
  content: "";
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid #17191c;
  transform: translateY(0);
}

.usage-panel details[open] summary::before {
  border-top: 7px solid #17191c;
  border-right: 5px solid transparent;
  border-left: 5px solid transparent;
  border-bottom: 0;
}

.usage-list {
  margin: 10px 0 0;
  padding-left: 20px;
  color: rgba(23, 25, 28, 0.78);
  line-height: 1.7;
}

.panel-title {
  margin: 0;
  font-size: clamp(1.5rem, 1.2rem + 1vw, 2.2rem);
  line-height: 1.1;
  color: #17191c;
}

.control-bar {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  align-items: end;
  overflow-x: auto;
}

.theme-picker {
  position: relative;
  display: flex;
  width: 132px;
  min-width: 132px;
  flex: 0 0 132px;
}

.theme-picker::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 12px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid #17191c;
  transform: translateY(-35%);
  pointer-events: none;
}

.theme-select {
  appearance: none;
  color-scheme: light;
  width: 132px;
  border: 1px solid rgba(23, 25, 28, 0.18);
  border-radius: 14px;
  padding: 10px 40px 10px 14px;
  color: #17191c;
  font: inherit;
  font-weight: 700;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04)),
    rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px) saturate(1.1);
  outline: none;
  box-shadow: none;
}

.theme-select:focus,
.theme-select:focus-visible {
  outline: none;
  box-shadow: none;
}

.glass-button {
  border: 1px solid rgba(23, 25, 28, 0.18);
  border-radius: 999px;
  padding: 12px 18px;
  color: #17191c;
  font: inherit;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: none;
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition:
    transform 180ms ease,
    background-color 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.info-panel .glass-button,
.info-panel .file-button,
.info-panel .theme-select,
.info-panel .background-status {
  color: #17191c;
}

.glass-button:hover,
.glass-button:focus-visible {
  transform: none;
  background: rgba(23, 25, 28, 0.06);
  border-color: rgba(23, 25, 28, 0.28);
  outline: none;
}

.glass-button[aria-pressed="true"] {
  background: rgba(23, 25, 28, 0.08);
  border-color: rgba(23, 25, 28, 0.28);
}

.glass-button.strong {
  background: #17191c;
  color: #fff;
  border-color: #17191c;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.is-fullscreen .app-header,
body.is-fullscreen .app-footer {
  display: none;
}

body.is-fullscreen .clock-shell,
body.is-pseudo-fullscreen .clock-shell {
  min-height: 100vh;
  padding: 0;
  display: flex;
}

body.is-fullscreen .clock-stage,
body.is-pseudo-fullscreen .clock-stage {
  min-height: 100vh;
  width: 100%;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.is-fullscreen .clock-stage[data-theme="light"],
body.is-pseudo-fullscreen .clock-stage[data-theme="light"] {
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 255, 255, 1) 0%, rgba(249, 250, 252, 1) 58%, rgba(241, 243, 247, 1) 100%);
}

body.is-fullscreen .clock-stage.has-background,
body.is-pseudo-fullscreen .clock-stage.has-background {
  background-image: var(--clock-stage-image);
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
}

body.is-fullscreen .clock-panel,
body.is-pseudo-fullscreen .clock-panel {
  width: 100%;
  min-height: 100vh;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.is-fullscreen .info-panel,
body.is-pseudo-fullscreen .info-panel {
  display: none;
}

body.is-fullscreen .usage-panel,
body.is-pseudo-fullscreen .usage-panel {
  display: none;
}

body.is-fullscreen .dial-wrap,
body.is-pseudo-fullscreen .dial-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--fs-dial-size, 80vmin);
  height: var(--fs-dial-size, 80vmin);
  transform: translate(
    calc(-50% + var(--fs-dial-offset-x, 0px)),
    calc(-50% + var(--fs-dial-offset-y, 0px))
  );
  cursor: grab;
}

body.is-fullscreen .clock-face,
body.is-pseudo-fullscreen .clock-face {
  width: 100%;
}

body.is-fullscreen .dial-wrap.is-dragging,
body.is-pseudo-fullscreen .dial-wrap.is-dragging {
  cursor: grabbing;
}

body.is-fullscreen .resize-handle.is-visible,
body.is-pseudo-fullscreen .resize-handle.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.fullscreen-exit-button {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  padding: 12px 16px;
  border: 1px solid rgba(23, 25, 28, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: #17191c;
  font: inherit;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(12, 16, 20, 0.16);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.fullscreen-exit-button.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 120;
  max-width: min(92vw, 520px);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(23, 25, 28, 0.92);
  color: #fff;
  font-size: 0.92rem;
  line-height: 1.4;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

body:not(.is-fullscreen) .fullscreen-exit-button {
  display: none;
}

body.is-pseudo-fullscreen {
  overflow: hidden;
}

body.is-pseudo-fullscreen .app-header,
body.is-pseudo-fullscreen .app-footer {
  display: none;
}

body.is-pseudo-fullscreen .fullscreen-exit-button {
  display: block;
}

@media (max-width: 980px) {
  .dial-wrap {
    max-width: 78vw;
    max-height: 78vw;
  }
}

@media (max-width: 720px) {
  .clock-shell {
    padding: 0;
  }

  .clock-stage {
    min-height: calc(100vh - 88px);
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .info-panel {
    margin: 8px 10px 0;
    padding: 12px 12px;
    border-radius: 16px;
  }

  .usage-panel {
    margin: 10px 10px 0;
    padding: 14px;
    border-radius: 16px;
  }

  .clock-panel {
    padding: 4px 8px 10px;
  }

  .dial-wrap {
    max-width: 96vw;
    max-height: 96vw;
  }
}

@media (max-width: 560px) {
  .control-bar {
    flex-wrap: wrap;
  }

  .theme-picker {
    max-width: 100%;
  }

  .info-panel {
    padding: 14px;
  }

  .theme-select,
  .glass-button {
    width: 100%;
  }
}

@media (max-width: 720px) {
  body.is-pseudo-fullscreen .fullscreen-exit-button {
    left: 50%;
    right: auto;
    top: calc(50% + (var(--fs-dial-size, 80vmin) / 2) + 16px);
    bottom: auto;
    transform: translateX(-50%) translateY(8px);
  }

  body.is-pseudo-fullscreen .fullscreen-exit-button.is-visible {
    transform: translateX(-50%) translateY(0);
  }
}
