* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Microsoft YaHei", Arial, sans-serif;
  background: #f4f4f6;
  color: #111;
}

body {
  overflow: hidden;
  background: #f5f5f7;
}

.hidden {
  display: none !important;
}

.fake-404 {
  min-height: 100dvh;
  width: min(460px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 26px 30px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: transparent;
  font-family: Georgia, "Times New Roman", serif;
  color: #111;
}

.fake-404 h1 {
  margin: 0 0 16px;
  font-size: clamp(34px, 6vw, 42px);
  font-weight: 700;
  line-height: 1.1;
  cursor: default;
  user-select: none;
  letter-spacing: -0.3px;
}

.fake-404 hr {
  width: 100%;
  border: none;
  border-top: 1px solid #cfcfcf;
  margin: 0 0 16px;
}

.fake-404 p {
  margin: 0;
  font-size: 18px;
  line-height: 1.7;
  color: #222;
}

.fake-404 .nginx {
  margin-top: 10px;
  text-align: center;
  font-size: 17px;
  color: #111;
}

/* password modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(8px);
}

.modal-box {
  width: 280px;
  padding: 18px;
  border: 1px solid #e5e5e5;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 12px 40px rgba(0,0,0,0.08);
}

.modal-box input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  margin-bottom: 10px;
  border: 1px solid #ddd;
  border-radius: 12px;
  outline: none;
  font-size: 16px;
}

.modal-box button {
  width: 100%;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: #111;
  color: #fff;
  font-size: 15px;
}

#loginMsg {
  margin: 8px 0 0;
  font-size: 13px;
  color: #777;
  min-height: 18px;
  text-align: center;
}

/* diary app */
.diary-app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at top left, rgba(255,255,255,0.95), transparent 36%),
    linear-gradient(180deg, #f7f7f9 0%, #ededf1 100%);
  overflow: hidden;
}

.diary-header {
  flex: 0 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(247, 247, 249, 0.82);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.diary-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.4px;
}

.diary-subtitle {
  margin-top: 3px;
  font-size: 13px;
  color: #777;
}

.ghost-btn {
  border: none;
  background: rgba(255,255,255,0.75);
  color: #333;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}

.message-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 14px 18px;
  -webkit-overflow-scrolling: touch;
}

.empty-tip {
  margin: 26vh auto 0;
  max-width: 260px;
  text-align: center;
  color: #999;
  font-size: 15px;
  line-height: 1.7;
}

.message-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-bottom: 14px;
}

.message-time {
  margin: 0 8px 6px;
  font-size: 12px;
  color: #9a9a9a;
}

.message-bubble {
  max-width: 88%;
  padding: 12px 14px;
  border-radius: 20px 20px 6px 20px;
  background: #111;
  color: #fff;
  font-size: 16px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.message-actions {
  margin-top: 5px;
  margin-right: 6px;
  display: flex;
  gap: 10px;
}

.message-actions button {
  border: none;
  background: transparent;
  color: #888;
  font-size: 12px;
  padding: 4px;
}

/* input composer */
.composer-wrap {
  flex: 0 0 auto;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(247, 247, 249, 0.86);
  backdrop-filter: blur(18px);
  border-top: 1px solid rgba(0,0,0,0.06);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px;
  border-radius: 26px;
  background: #fff;
  box-shadow: 0 8px 26px rgba(0,0,0,0.08);
}

.composer-input {
  flex: 1;
  min-height: 38px;
  max-height: 128px;
  padding: 8px 10px;
  border: none;
  outline: none;
  resize: none;
  font-size: 16px;
  line-height: 22px;
  background: transparent;
  color: #111;
}

.send-btn {
  flex: 0 0 auto;
  height: 38px;
  min-width: 58px;
  padding: 0 14px;
  border: none;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}

.send-btn:active {
  transform: scale(0.96);
}

.status-msg {
  min-height: 18px;
  margin-top: 5px;
  padding-left: 12px;
  color: #888;
  font-size: 12px;
}

/* desktop fallback */
@media (min-width: 780px) {
  .diary-app {
    width: 430px;
    height: 92vh;
    margin: 4vh auto;
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0,0,0,0.18);
  }

  body {
    background: #dedee3;
  }
}