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

body {
  font-family: "Consolas", "Microsoft YaHei", monospace;
  background: #f0f0f0;
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #fff;
}

/* ===== 菜单栏 ===== */
#menubar {
  display: flex;
  background: #f0f0f0;
  border-bottom: 1px solid #d4d4d4;
  padding: 2px 0;
  min-height: 24px;
}

.menu-item {
  padding: 2px 8px;
  font-size: 13px;
  cursor: default;
  border: 1px solid transparent;
}

.menu-item:hover {
  background: #e5f3ff;
  border-color: #99cfff;
}

.menu-item.active {
  background: #cce8ff;
  border-color: #99cfff;
}

/* ===== 工具栏 ===== */
#toolbar {
  display: flex;
  align-items: center;
  background: #e8e8e8;
  border-bottom: 1px solid #d4d4d4;
  padding: 1px 6px;
  min-height: 32px;
  gap: 2px;
}

.toolbar-btn {
  background: transparent;
  border: 1px solid transparent;
  padding: 4px;
  cursor: default;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  min-height: 30px;
}

.toolbar-btn svg {
  display: block;
  transition: opacity 0.1s;
}

.toolbar-btn:hover {
  background: #d4d4d4;
  border-color: #b0b0b0;
}

.toolbar-btn:hover svg {
  opacity: 0.75;
}

.toolbar-btn:active {
  background: #c0c0c0;
}

.toolbar-btn:active svg {
  opacity: 0.6;
}

.toolbar-sep {
  width: 0;
  height: 20px;
  border-left: 1px solid #c0c0c0;
  margin: 0 6px;
}

/* ===== 下拉菜单 ===== */
#dropdown {
  position: fixed;
  z-index: 1000;
  background: #f2f2f2;
  border: 1px solid #c0c0c0;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.15);
  min-width: 180px;
  padding: 2px 0;
}

#dropdown.hidden {
  display: none;
}

.dropdown-item {
  padding: 3px 24px;
  font-size: 13px;
  cursor: default;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dropdown-item:hover {
  background: #cce8ff;
}

.dropdown-item .shortcut {
  color: #666;
  margin-left: 40px;
  font-size: 12px;
}

.dropdown-separator {
  height: 1px;
  background: #d4d4d4;
  margin: 3px 2px;
}

.dropdown-item.disabled {
  color: #aaa;
  pointer-events: none;
}

/* ===== 标签栏 ===== */
#tabbar {
  display: flex;
  align-items: stretch;
  background: #d4d4d4;
  border-bottom: 1px solid #b0b0b0;
  min-height: 28px;
  padding: 2px 2px 0 2px;
}

#tablist {
  display: flex;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  gap: 1px;
}

#tablist::-webkit-scrollbar {
  height: 3px;
}

#tablist::-webkit-scrollbar-thumb {
  background: #aaa;
  border-radius: 2px;
}

.tab {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: default;
  background: #d4d4d4;
  border: 1px solid #b0b0b0;
  border-bottom: none;
  border-radius: 3px 3px 0 0;
  min-width: 60px;
  max-width: 200px;
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
  color: #333;
}

.tab:hover {
  background: #e0e0e0;
}

.tab.active {
  background: #fff;
  border-bottom: 1px solid #fff;
  margin-bottom: -1px;
  z-index: 1;
}

.tab .tab-indicator {
  width: 4px;
  height: 14px;
  border-radius: 2px;
  flex-shrink: 0;
  background: transparent;
}

.tab .tab-title {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.tab .tab-close {
  font-size: 12px;
  color: #888;
  padding: 0 2px;
  line-height: 1;
  border-radius: 2px;
  opacity: 0;
}

.tab:hover .tab-close {
  opacity: 1;
}

.tab .tab-close:hover {
  background: #c0c0c0;
  color: #000;
}

.tab.active .tab-close {
  opacity: 0.6;
}

.tab.modified .tab-title::after {
  content: '*';
  margin-left: 2px;
}

#tab-new {
  background: transparent;
  border: none;
  font-size: 16px;
  cursor: default;
  padding: 0 8px;
  color: #555;
  line-height: 1;
  flex-shrink: 0;
}

#tab-new:hover {
  background: #c0c0c0;
}

/* ===== 标签颜色菜单 ===== */
#tab-color-menu {
  position: fixed;
  z-index: 3000;
  background: #f2f2f2;
  border: 1px solid #c0c0c0;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.15);
  padding: 4px;
  min-width: 164px;
}

#tab-color-menu.hidden {
  display: none;
}

#tab-color-menu .color-menu-header {
  font-size: 11px;
  color: #666;
  padding: 2px 6px 4px;
  cursor: default;
}

#tab-color-menu .color-menu-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 4px 4px;
}

#tab-color-menu .color-swatch {
  width: 18px;
  height: 18px;
  border: 1px solid #999;
  border-radius: 2px;
  cursor: default;
}

#tab-color-menu .color-swatch:hover {
  border-color: #000;
  transform: scale(1.15);
}

#tab-color-menu .color-menu-item {
  padding: 3px 6px;
  font-size: 12px;
  cursor: default;
  border-top: 1px solid #d4d4d4;
  margin-top: 2px;
}

#tab-color-menu .color-menu-item:hover {
  background: #cce8ff;
}

/* Tab color variants — subtle background tints */
.tab.color-blue   { background: #d6e8fa; border-top: 2px solid #4a90d9; }
.tab.color-green  { background: #d5f0e0; border-top: 2px solid #50b86c; }
.tab.color-orange { background: #fcefd2; border-top: 2px solid #f5a623; }
.tab.color-red    { background: #f8d7da; border-top: 2px solid #e74c3c; }
.tab.color-purple { background: #e4d5f0; border-top: 2px solid #9b59b6; }
.tab.color-teal   { background: #d1f0eb; border-top: 2px solid #1abc9c; }
.tab.color-pink   { background: #fad4e4; border-top: 2px solid #e91e8a; }
.tab.color-yellow { background: #f8f0cf; border-top: 2px solid #d4a017; }
.tab.color-brown  { background: #e8ddd0; border-top: 2px solid #8b6b4b; }
.tab.color-grey   { background: #e0e0e0; border-top: 2px solid #888; }

.tab.color-blue:hover   { background: #c5ddf5; }
.tab.color-green:hover  { background: #c4e8d4; }
.tab.color-orange:hover { background: #f5e5c0; }
.tab.color-red:hover    { background: #f0c4c8; }
.tab.color-purple:hover { background: #d8c4e8; }
.tab.color-teal:hover   { background: #c0e8e0; }
.tab.color-pink:hover   { background: #f0c4d8; }
.tab.color-yellow:hover { background: #f0e8bc; }
.tab.color-brown:hover   { background: #dccfc0; }
.tab.color-grey:hover   { background: #d0d0d0; }

.tab.active.color-blue   { background: #e8f1fc; border-bottom-color: #e8f1fc; }
.tab.active.color-green  { background: #e0f5e8; border-bottom-color: #e0f5e8; }
.tab.active.color-orange { background: #fef5e0; border-bottom-color: #fef5e0; }
.tab.active.color-red    { background: #fce8e8; border-bottom-color: #fce8e8; }
.tab.active.color-purple { background: #f0e8f8; border-bottom-color: #f0e8f8; }
.tab.active.color-teal   { background: #e0f5f0; border-bottom-color: #e0f5f0; }
.tab.active.color-pink   { background: #fce8f0; border-bottom-color: #fce8f0; }
.tab.active.color-yellow { background: #fef8e0; border-bottom-color: #fef8e0; }
.tab.active.color-brown  { background: #f0e8dc; border-bottom-color: #f0e8dc; }
.tab.active.color-grey   { background: #f0f0f0; border-bottom-color: #f0f0f0; }

/* ===== 编辑区容器 ===== */
#editor-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.editor-wrapper {
  position: absolute;
  inset: 0;
}

.editor-wrapper textarea {
  position: absolute;
  inset: 0;
  border: none;
  outline: none;
  resize: none;
  padding: 4px 6px;
  font-family: "Consolas", "Microsoft YaHei", monospace;
  font-size: 14px;
  line-height: 1.5;
  tab-size: 4;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  overflow-y: auto;
  background: #fff;
  color: #000;
  caret-color: #000;
}

.editor-wrapper textarea.wrap {
  white-space: pre-wrap;
  overflow-x: hidden;
}

/* ===== 状态栏 ===== */
#statusbar {
  display: flex;
  align-items: center;
  background: #f0f0f0;
  border-top: 1px solid #d4d4d4;
  padding: 2px 8px;
  font-size: 12px;
  color: #333;
  gap: 16px;
  min-height: 22px;
}

#status-tabcount {
  margin-left: auto;
  color: #888;
}

/* ===== 通用工具类 ===== */
.hidden {
  display: none !important;
}

/* ===== 对话框 ===== */
.dialog {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.dialog.hidden {
  display: none;
}

.dialog-box {
  background: #f0f0f0;
  border: 1px solid #808080;
  box-shadow: 4px 4px 12px rgba(0,0,0,0.25);
  padding: 20px 24px 16px;
  min-width: 320px;
}

.dialog-box label {
  font-size: 13px;
  display: block;
  margin-bottom: 6px;
}

.dialog-box input[type="text"] {
  width: 100%;
  padding: 4px 6px;
  font-size: 13px;
  border: 1px solid #808080;
  outline: none;
  background: #fff;
  font-family: inherit;
}

.dialog-box input[type="text"]:focus {
  border-color: #0078d7;
}

/* 替换对话框 */
.find-box {
  min-width: 400px;
}

.replace-label {
  margin-top: 10px;
}

#replace-input {
  width: 100%;
  padding: 4px 6px;
  font-size: 13px;
  border: 1px solid #808080;
  outline: none;
  background: #fff;
  font-family: inherit;
}

#replace-input:focus {
  border-color: #0078d7;
}

.dialog-options {
  margin-top: 10px;
}

.dialog-options label {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: default;
}

.dialog-actions {
  margin-top: 14px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.dialog-box button {
  padding: 3px 16px;
  font-size: 13px;
  cursor: default;
  background: #e1e1e1;
  border: 1px solid #adadad;
  outline: none;
}

.dialog-box button:hover {
  background: #e5f1fb;
  border-color: #0078d7;
}

.dialog-box button:active {
  background: #cce4f7;
}

/* 关闭保存对话框 */
.close-save-box {
  min-width: 340px;
}

.close-save-message {
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}

.close-save-actions {
  justify-content: center;
  gap: 12px;
}

.close-save-actions button {
  min-width: 80px;
  padding: 4px 20px;
}

/* 关于对话框 */
.about-box {
  text-align: left;
  min-width: 400px;
  max-width: 480px;
}

.about-box .about-content p {
  font-size: 13px;
  color: #333;
  margin-bottom: 8px;
  line-height: 1.7;
  text-indent: 2em;
}

.about-box .about-author,
.about-box .about-email {
  font-size: 13px;
  color: #333;
  margin-top: 6px;
  text-indent: 0;
}

.about-box button {
  margin-top: 16px;
  padding: 4px 32px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* ===== 信息摘要对话框 ===== */
.hash-box {
  min-width: 480px;
}

.hash-box h3 {
  font-size: 14px;
  font-weight: normal;
  margin-bottom: 10px;
}

.hash-source {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
}

.hash-source label {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: default;
}

#hash-input {
  width: 100%;
  padding: 4px 6px;
  font-size: 13px;
  border: 1px solid #808080;
  outline: none;
  background: #fff;
  font-family: "Consolas", "Microsoft YaHei", monospace;
  resize: vertical;
}

#hash-input:focus {
  border-color: #0078d7;
}

#hash-file-area {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

#hash-file-area.hidden {
  display: none;
}

#hash-file-name {
  font-size: 12px;
  color: #555;
}

.hash-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.hash-btn {
  flex: 1;
}

#hash-results {
  margin-top: 12px;
  padding: 8px;
  background: #fff;
  border: 1px solid #d4d4d4;
}

#hash-results.hidden {
  display: none;
}

.hash-result-item {
  font-size: 11px;
  color: #888;
  margin-bottom: 4px;
}

.hash-result-value {
  font-size: 12px;
  font-family: "Consolas", monospace;
  word-break: break-all;
  line-height: 1.5;
}

.hash-copy-btn {
  margin-top: 6px;
  padding: 2px 12px;
  font-size: 12px;
  cursor: default;
  background: #e1e1e1;
  border: 1px solid #adadad;
  outline: none;
}

.hash-copy-btn:hover {
  background: #e5f1fb;
  border-color: #0078d7;
}

.hash-copy-btn:active {
  background: #cce4f7;
}

/* ===== 加密/解密对话框 ===== */
.crypto-box {
  min-width: 380px;
}

.crypto-box h3 {
  font-size: 14px;
  font-weight: normal;
  margin-bottom: 12px;
}

.crypto-field {
  margin-bottom: 10px;
}

.crypto-field label {
  font-size: 12px;
  display: block;
  margin-bottom: 4px;
}

.crypto-field select,
.crypto-field input[type="password"] {
  width: 100%;
  padding: 4px 6px;
  font-size: 13px;
  border: 1px solid #808080;
  outline: none;
  background: #fff;
  font-family: inherit;
  box-sizing: border-box;
}

.crypto-field select:focus,
.crypto-field input[type="password"]:focus {
  border-color: #0078d7;
}

.crypto-actions {
  margin-top: 14px;
  display: flex;
  gap: 8px;
}

.crypto-actions button {
  flex: 1;
  padding: 3px 16px;
  font-size: 13px;
  cursor: default;
  background: #e1e1e1;
  border: 1px solid #adadad;
  outline: none;
}

.crypto-actions button:hover {
  background: #e5f1fb;
  border-color: #0078d7;
}

.crypto-actions button:active {
  background: #cce4f7;
}
