:root {
  color-scheme: light;
  --ink: #161616;
  --muted: #62666d;
  --line: #242424;
  --soft-line: #e4ded2;
  --blue: #1a73e8;
  --blue-soft: #e7f0ff;
  --paper: #fffdf8;
  --surface: #fffefa;
  --bg: #f6f3ec;
  --shadow: 0 18px 45px rgba(32, 24, 12, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(26, 115, 232, 0.08), transparent 32vw),
    linear-gradient(135deg, #fbfaf6 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: "Microsoft YaHei", "Noto Sans SC", Arial, sans-serif;
}

button,
.button,
.file-btn {
  min-width: 88px;
  height: 42px;
  border: 2px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

button:hover,
.button:hover,
.file-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
  box-shadow: 0 4px 12px rgba(26, 115, 232, 0.16);
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.app-shell {
  min-height: 100vh;
  padding: 24px 32px;
}

.tool-panel {
  min-height: calc(100vh - 48px);
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: 30px;
  padding: 28px 32px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.topbar,
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar {
  flex-wrap: wrap;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--soft-line);
}

.place {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 24px;
}

.place input {
  width: 238px;
  height: 46px;
  border: 2px solid var(--line);
  border-radius: 9px;
  text-align: center;
  font-size: 22px;
  background: var(--surface);
}

textarea:focus,
input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.16);
  outline: none;
}

.actions,
.pager,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-btn {
  position: relative;
  color: var(--blue);
  border-color: var(--blue);
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.link-button {
  color: var(--blue);
  border-color: var(--blue);
}

.status-row {
  padding: 16px 0 18px;
  color: var(--muted);
  font-size: 21px;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 26px 22px;
  align-items: start;
  flex: 1;
}

.tile {
  min-width: 0;
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 6px 4px 2px;
  border-radius: 14px;
  transition: background-color 0.12s ease;
}

.tile:hover {
  background: rgba(255, 255, 255, 0.62);
}

.img-frame {
  width: 96px;
  height: 74px;
  min-width: 0;
  border: 3px solid var(--line);
  border-radius: 10px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(17, 17, 17, 0.06);
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}

.tile.selected .img-frame {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--blue-soft), 0 8px 18px rgba(26, 115, 232, 0.18);
  transform: translateY(-2px);
}

.img-frame img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.label-input {
  width: 72px;
  height: 34px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 7px;
  background: transparent;
  text-align: center;
  font: 26px/1 "Microsoft YaHei", "Noto Sans SC", serif;
  outline: none;
}

.label-input:focus {
  border-bottom-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.12);
}

.shortcut-bar {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--soft-line);
  display: grid;
  gap: 14px;
}

.shortcut-help,
.shortcut-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.shortcut-help {
  color: var(--muted);
  font-size: 15px;
}

kbd {
  min-width: 24px;
  height: 24px;
  padding: 2px 7px;
  border: 1px solid #c8c1b5;
  border-bottom-width: 2px;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: 600 14px/1.2 "Microsoft YaHei", "Noto Sans SC", Arial, sans-serif;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.shortcut-btn {
  min-width: 86px;
  height: 34px;
  border-width: 1px;
  border-color: #c9c2b6;
  color: #333;
  font-size: 15px;
  background: rgba(255, 255, 255, 0.72);
}

.modal,
.viewer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal {
  background: rgba(29, 26, 21, 0.22);
  backdrop-filter: blur(3px);
}

.modal[hidden],
.viewer[hidden] {
  display: none;
}

.paste-panel {
  width: min(700px, calc(100vw - 48px));
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: 30px;
  padding: 28px 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
}

.panel-title {
  display: block;
  margin-bottom: 12px;
  font-size: 24px;
}

textarea {
  width: 100%;
  height: 224px;
  resize: vertical;
  border: 3px solid var(--line);
  border-radius: 24px;
  padding: 18px;
  font: 24px/1.65 "Microsoft YaHei", "Noto Sans SC", serif;
  background: var(--surface);
}

.paste-actions {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 22px;
}

.viewer {
  background: rgba(0, 0, 0, 0.72);
}

.viewer img {
  max-width: min(900px, 90vw);
  max-height: 86vh;
  background: #fff;
  border-radius: 10px;
  padding: 18px;
}

.viewer-close {
  position: absolute;
  right: 24px;
  top: 20px;
  min-width: 42px;
  width: 42px;
  height: 42px;
  font-size: 28px;
  line-height: 1;
  border-color: #fff;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 8px;
  }

  .tool-panel {
    min-height: calc(100vh - 16px);
    border-radius: 18px;
    padding: 16px;
  }

  .topbar,
  .status-row,
  .place,
  .paste-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions,
  .pager,
  .shortcut-help,
  .shortcut-actions {
    flex-wrap: wrap;
  }

  .image-grid {
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
    gap: 14px 10px;
  }

  .img-frame {
    width: 68px;
    height: 54px;
  }

  button,
  .button,
  .file-btn {
    min-width: 76px;
    height: 36px;
    font-size: 16px;
  }
}
