:root {
  --theme: #c8161d;
  --bg: #e9edf2;
  --paper: #f6f7f9;
  --text: #222;
  --muted: #888;
  --line: #ececec;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font-family: inherit;
}

.stage {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
}

.phone {
  width: 100%;
  max-width: 430px;
  min-height: 100dvh;
  background: var(--paper);
  box-shadow: 0 0 48px rgba(20, 30, 50, 0.08);
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: 58px;
}

.topbar {
  background: var(--theme);
  color: #fff;
  padding: 18px 16px 20px;
  text-align: center;
}

.topbar h1 {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.5px;
}

.topbar p {
  margin-top: 6px;
  font-size: 12px;
  opacity: 0.86;
}

.content {
  flex: 1;
  padding: 18px 12px 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 18px 6px;
}

.window {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.window:disabled {
  cursor: default;
  opacity: 0.45;
}

.icon {
  width: 54px;
  height: 54px;
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(20, 30, 50, 0.06);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.icon .fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}

.window span {
  font-size: 12px;
  line-height: 1.3;
  text-align: center;
  color: #333;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.footer {
  padding: 8px 16px 20px;
  text-align: center;
  color: #aaa;
  font-size: 12px;
}

.view-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--theme);
  color: #fff;
  padding: 12px 10px;
}

.view-nav button {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 15px;
  padding: 4px 8px;
  cursor: pointer;
}

.view-nav h1 {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 650;
  padding-right: 40px;
}

.paper {
  margin: 12px 12px 16px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(20, 30, 50, 0.06);
  overflow: hidden;
  max-width: calc(100% - 24px);
}

.paper.plain {
  padding: 22px 18px 32px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
  line-height: 1.8;
}

.image-wrap {
  padding: 12px;
  text-align: center;
}

.image-wrap img {
  max-width: 100%;
  max-height: 70vh;
  height: auto;
  display: inline-block;
  object-fit: contain;
}

.word-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: #666;
}

.word-toolbar a {
  color: var(--theme);
  font-weight: 600;
}

.word-body {
  padding: 14px 12px 20px;
  line-height: 1.65;
  font-size: 13px;
  overflow-x: auto;
  max-width: 100%;
  word-break: break-word;
}

.word-body * {
  max-width: 100% !important;
  box-sizing: border-box;
}

.word-body table {
  border-collapse: collapse;
  width: 100%;
  max-width: 100%;
  margin: 8px 0;
  font-size: 12px;
}

.word-body table td,
.word-body table th {
  border: 1px solid #ccc;
  padding: 4px 6px;
  word-break: break-word;
}

.word-body img {
  max-width: 100% !important;
  max-height: 220px !important;
  width: auto !important;
  height: auto !important;
  display: block;
  margin: 8px auto;
  object-fit: contain;
}

.word-body p {
  margin: 0 0 8px;
}

.hint {
  padding: 48px 20px;
  text-align: center;
  color: #999;
  line-height: 1.7;
}

.error {
  color: #c0392b;
}

@media (max-width: 360px) {
  .icon {
    width: 48px;
    height: 48px;
    border-radius: 13px;
  }
  .window span {
    font-size: 11px;
  }
}

.tabbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 58px;
  background: #fff;
  border-top: 1px solid #ececec;
  display: flex;
  justify-content: center;
  align-items: stretch;
}

.tab-item {
  min-width: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #999;
  font-size: 11px;
}

.tab-item svg {
  width: 22px;
  height: 22px;
}

.tab-item.active {
  color: var(--theme);
}
