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

body {
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;
  background: #000;
  color: #fff;
  min-height: 100vh;
  min-height: 100dvh;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ===== Top Bar ===== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 20px 8px;
  position: relative;
  flex-shrink: 0;
}
.top-bar-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.top-bar-book {
  position: absolute;
  right: 16px;
  width: 40px;
  height: 40px;
  border: none;
  background: #222;
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.top-bar-book:hover { background: #333; }
.top-bar-book svg { width: 22px; height: 22px; }

/* ===== Back Button ===== */
.back-btn {
  position: absolute;
  left: 16px;
  width: 40px;
  height: 40px;
  border: none;
  background: #222;
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.back-btn:hover { background: #333; }
.back-btn svg { width: 20px; height: 20px; }

/* ===== Permission Display ===== */
.perm-display {
  text-align: center;
  padding: 24px 20px 8px;
  flex-shrink: 0;
}
.perm-octal {
  font-size: 72px;
  font-weight: 700;
  letter-spacing: 4px;
  line-height: 1;
  margin-bottom: 24px;
}

.perm-columns {
  display: flex;
  justify-content: center;
  gap: 0;
  margin-bottom: 24px;
}
.perm-col {
  flex: 1;
  text-align: center;
  max-width: 160px;
}
.perm-col-label {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}
.perm-col-sub {
  font-size: 12px;
  color: #888;
  margin-bottom: 12px;
}
.perm-bits {
  display: flex;
  justify-content: center;
  gap: 16px;
}
.perm-bit {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
  user-select: none;
}
.perm-bit.on { color: #fff; }
.perm-bit.off { color: #555; }
.perm-bit:hover { background: #1a1a1a; }

/* ===== Common Modes ===== */
.common-modes {
  padding: 0 20px 20px;
  flex: 1;
}
.common-modes-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}
.mode-item {
  display: flex;
  align-items: flex-start;
  padding: 14px 8px;
  border-bottom: 1px solid #1a1a1a;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 8px;
  margin: 0 -8px;
}
.mode-item:hover { background: #111; }
.mode-item.active { background: #111; }
.mode-octal {
  font-size: 18px;
  font-weight: 600;
  min-width: 48px;
  color: #ccc;
  flex-shrink: 0;
}
.mode-info { flex: 1; }
.mode-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}
.mode-desc {
  font-size: 13px;
  color: #888;
  line-height: 1.4;
}
.mode-check {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #0a84ff;
  margin-left: 8px;
}

/* ===== Guide List ===== */
.guide-list {
  padding: 0 20px 20px;
  flex: 1;
}
.guide-list-title {
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  padding: 16px 0 20px;
}
.guide-contents-label {
  font-size: 12px;
  color: #666;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.guide-item {
  display: flex;
  align-items: center;
  padding: 16px 8px;
  border-bottom: 1px solid #1a1a1a;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 8px;
  margin: 0 -8px;
}
.guide-item:hover { background: #111; }
.guide-num {
  font-size: 16px;
  color: #666;
  min-width: 36px;
  flex-shrink: 0;
}
.guide-info { flex: 1; }
.guide-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 2px;
}
.guide-sub {
  font-size: 13px;
  color: #888;
}
.guide-arrow {
  color: #555;
  font-size: 18px;
  flex-shrink: 0;
  margin-left: 8px;
}

/* ===== Guide Detail ===== */
.guide-detail {
  padding: 0 20px 40px;
  flex: 1;
  overflow-y: auto;
}
.guide-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0 20px;
  font-size: 12px;
  color: #666;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.guide-detail h1 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 24px;
  line-height: 1.2;
}
.guide-detail h2 {
  font-size: 13px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin: 28px 0 12px;
  font-weight: 600;
}
.guide-detail p {
  font-size: 16px;
  line-height: 1.6;
  color: #ccc;
  margin-bottom: 16px;
}
.guide-detail .mono-line {
  font-size: 16px;
  line-height: 1.8;
  color: #ddd;
}
.guide-detail .note {
  font-size: 14px;
  color: #888;
  line-height: 1.6;
  margin-bottom: 12px;
}
.guide-detail .note sup { color: #666; }
.guide-detail .example-line {
  font-size: 18px;
  color: #fff;
  margin: 8px 0;
}
.guide-detail .calc-line {
  font-size: 17px;
  color: #ccc;
  margin: 4px 0;
}
.guide-detail a {
  color: #0a84ff;
  text-decoration: underline;
}

/* ===== Screens ===== */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
}
.screen.active { display: flex; }

/* ===== Responsive ===== */
@media (min-width: 768px) {
  .app {
    border-left: 1px solid #1a1a1a;
    border-right: 1px solid #1a1a1a;
  }
}
