:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --muted-surface: #f2f2f7;
  --text: #1d1d1f;
  --subtext: #86868b;
  --divider: rgba(60, 60, 67, 0.12);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  --btn-red: #ff2d55;
  --btn-red-pressed: #e2264b;
  --btn-gray: #f2f2f7;
  --btn-gray-pressed: #e6e6ee;
  --radius-12: 12px;
  --radius-16: 16px;
  --radius-999: 999px;
  --inset-top: env(safe-area-inset-top, 0px);
  --inset-bottom: env(safe-area-inset-bottom, 0px);
  --inset-left: env(safe-area-inset-left, 0px);
  --inset-right: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC",
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: var(--bg);
  box-shadow: 0 0 20px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
}

.mode-selector {
  display: flex;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
  gap: 12px;
}

.mode-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}

.mode-label input {
  accent-color: var(--btn-red);
}

.statusbar {
  height: calc(24px + var(--inset-top));
  padding-top: var(--inset-top);
  padding-left: 14px;
  padding-right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  letter-spacing: 0.2px;
}

.statusbar-right {
  display: flex;
  gap: 10px;
  align-items: center;
  color: #111111;
}

.statusbar-signal,
.statusbar-wifi {
  font-size: 13px;
  opacity: 0.85;
}

.statusbar-battery {
  width: 26px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.35);
  position: relative;
  padding: 1px;
}

.statusbar-battery::after {
  content: "";
  position: absolute;
  right: -3px;
  top: 3px;
  width: 2px;
  height: 6px;
  border-radius: 1px;
  background: rgba(0, 0, 0, 0.35);
}

.statusbar-battery-level {
  display: block;
  width: 70%;
  height: 100%;
  border-radius: 2px;
  background: #111111;
}

.navbar {
  height: 44px;
  padding: 0 12px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--divider);
  background: var(--bg);
}

.navbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.navbar-left {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.navbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.nav-plain {
  appearance: none;
  border: 0;
  background: transparent;
  color: #1d1d1f;
  font-size: 15px;
  padding: 6px 6px;
  border-radius: 10px;
}

.nav-plain:active {
  background: rgba(0, 0, 0, 0.06);
}

.nav-icon {
  width: 34px;
  height: 28px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  color: #111;
  font-size: 16px;
  line-height: 28px;
}

.nav-icon:active {
  background: rgba(0, 0, 0, 0.06);
}

.page {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(92px + var(--inset-bottom));
}

.image-card {
  height: 292px;
  background: #ededf1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.upload-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  gap: 6px;
  color: rgba(0, 0, 0, 0.35);
  font-size: 14px;
  user-select: none;
  cursor: pointer;
}

.upload-plus {
  font-size: 28px;
  line-height: 28px;
  font-weight: 300;
}

.upload-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.image-viewer {
  width: 100%;
  height: 100%;
  position: relative;
}

.image-main {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-counter {
  position: absolute;
  right: 12px;
  bottom: 10px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.2px;
}

.image-skeleton {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #ededf1 0%, #f6f6f9 45%, #ededf1 80%);
  background-size: 200% 100%;
  animation: sk 1.2s ease-in-out infinite;
}

.note-card {
  background: var(--surface);
  padding: 16px 16px 20px;
}

.note-title {
  margin: 6px 0 10px;
  font-size: 20px;
  line-height: 28px;
  font-weight: 800;
}

.note-body {
  font-size: 16px;
  line-height: 26px;
  white-space: pre-wrap;
}

.note-body p {
  margin: 0 0 12px;
}

.note-tags {
  margin-top: 14px;
  font-size: 13px;
  line-height: 20px;
  color: #2c2c2e;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.note-tag {
  color: #2c2c2e;
}

.note-ai {
  margin-top: 18px;
  font-size: 12px;
  color: rgba(60, 60, 67, 0.55);
}

.actionbar {
  position: fixed;
  left: 0;
  right: 0;
  margin: 0 auto;
  max-width: 480px;
  bottom: 0;
  padding: 12px 16px calc(12px + var(--inset-bottom));
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--divider);
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 12px;
  z-index: 10;
}

.btn {
  border: 0;
  border-radius: var(--radius-999);
  height: 46px;
  font-size: 16px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
  letter-spacing: 0.2px;
}

.btn-secondary {
  background: var(--btn-gray);
  color: #5a5a60;
}

.btn-secondary:active {
  background: var(--btn-gray-pressed);
}

.btn-primary {
  background: var(--btn-red);
  color: #fff;
}

.btn-primary:active {
  background: var(--btn-red-pressed);
}

.btn:disabled {
  opacity: 0.6;
}

.btn-plus {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 18px;
  line-height: 18px;
}

.note-skeleton {
  padding-top: 6px;
}

.sk-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, #f2f2f7 0%, #eaeaef 45%, #f2f2f7 80%);
  background-size: 200% 100%;
  animation: sk 1.2s ease-in-out infinite;
  margin: 10px 0;
}

.sk-title {
  height: 18px;
  border-radius: 10px;
  width: 72%;
  margin-top: 0;
}

.sk-short {
  width: 82%;
}

.sk-tags {
  width: 92%;
  height: 14px;
  margin-top: 16px;
}

@keyframes sk {
  0% {
    background-position: 120% 0;
  }
  100% {
    background-position: -80% 0;
  }
}

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(86px + var(--inset-bottom));
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  max-width: 80%;
  text-align: center;
  box-shadow: var(--shadow);
  z-index: 20;
}
