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

body {
  background: #f5f5f5;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  padding: 20px;
  color: #333;
  display: flex;
  flex-direction: column;
}

.ie-warning {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #FFF3CD;
  border-bottom: 1px solid #FFECB5;
  padding: 12px 20px;
  text-align: center;
  z-index: 9999;
  font-size: 14px;
  color: #856404;
}

.ie-warning span {
  display: inline-block;
}

.container {
  max-width: 500px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.title-section {
  text-align: center;
  padding: 40px 20px;
}

.title {
  font-size: 32px;
  font-weight: bold;
  color: #333;
  margin-bottom: 10px;
}

.version-btn {
  font-size: 11px;
  color: #999;
  font-weight: normal;
  margin-left: 10px;
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
  padding: 0;
  transition: color 0.2s ease;
}

.version-btn:hover {
  color: #666;
}

.subtitle {
  font-size: 16px;
  color: #666;
}

.subtitle-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
}

.rule-link-btn {
  font-size: 11px;
  color: #e67e22;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
  transition: all 0.2s ease;
}

.rule-link-btn:hover {
  color: #f5a062;
}

.card {
  background: white;
  border-radius: 16px;
  padding: 25px;
  margin-bottom: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

.unit-selector {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.unit-btn {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #E0E0E0;
  border-radius: 10px;
  background: white;
  color: #666;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.unit-btn:hover {
  border-color: #EA4335;
}

.unit-btn[data-unit="cm"]:hover {
  border-color: #34A853;
}

.unit-btn[data-unit="mm"]:hover {
  border-color: #FBBC05;
}

.unit-btn.active {
  border-color: #EA4335;
  background: #EA4335;
  color: white;
}

.unit-btn[data-unit="cm"].active {
  border-color: #34A853;
  background: #34A853;
}

.unit-btn[data-unit="mm"].active {
  border-color: #FBBC05;
  background: #FBBC05;
  color: white;
}

.input-section {
  margin-bottom: 20px;
}

.label {
  display: block;
  font-size: 14px;
  color: #666;
  margin-bottom: 10px;
}

.convert-hint .hint-content {
  margin-bottom: 12px;
}

.convert-hint .hint-content p {
  margin: 0 0 8px 0;
  font-size: 13px;
  color: #666;
  line-height: 1.6;
}

.convert-hint .hint-content p:last-child {
  margin-bottom: 0;
}

.convert-hint .original-value {
  color: #E53935;
  font-weight: 600;
}

.convert-hint .converted-value {
  color: #34A853;
  font-weight: 600;
}

.convert-hint .rule-btn {
  font-size: 12px;
  color: #e67e22;
  background: none;
  border: 1px solid #e67e22;
  cursor: pointer;
  padding: 6px 16px;
  border-radius: 15px;
  transition: all 0.2s ease;
}

.convert-hint .rule-btn:hover {
  background: #e67e22;
  color: white;
}

.input-box {
  width: 100%;
  height: 56px;
  border: 2px solid #E0E0E0;
  border-radius: 12px;
  padding: 0 18px;
  font-size: 18px;
  font-family: 'SF Mono', 'Monaco', 'Consolas', 'Liberation Mono', monospace;
  letter-spacing: 0.5px;
  background: #FAFAFA;
  transition: all 0.3s ease;
}

.input-box:focus {
  outline: none;
  border-color: #444;
  background: white;
}

.convert-hint {
  margin-top: 12px;
  padding: 12px;
  background: #FFF8E7;
  border-radius: 8px;
  border-left: 4px solid #e67e22;
  min-height: 0;
}

.convert-hint:empty {
  display: none;
}

.btn-row {
  display: flex;
  justify-content: center;
  gap: 20px;
}

.btn-primary {
  background: #4285F4;
  color: white;
  border: none;
  border-radius: 25px;
  padding: 14px 35px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 5px 16px rgba(66, 133, 244, 0.3);
  transition: transform 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-3px);
  background: #3367D6;
  box-shadow: 0 8px 25px rgba(66, 133, 244, 0.4);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: #F5F5F5;
  color: #666;
  border: none;
  border-radius: 25px;
  padding: 14px 35px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.btn-secondary:hover {
  background: #E8E8E8;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.result-title {
  font-size: 18px;
  font-weight: bold;
  color: #333;
}

.copy-btn {
  font-size: 12px;
  color: #444;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 15px;
  background: #f0f0f0;
  text-decoration: none;
}

.copy-btn:hover {
  background: #e0e0e0;
}

.result-grid {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.result-item {
  padding: 15px;
  background: #F8F9FA;
  border-radius: 8px;
}

.result-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.result-item .unit {
  display: block;
  font-size: 12px;
  color: #999;
  margin-bottom: 5px;
}

.result-item .value {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#resultCard {
  animation: fadeInUp 0.4s ease;
}

.error-card {
  text-align: center;
}

.error-message {
  color: #E53935;
  font-size: 14px;
}

.history-section {
  margin-top: 5px;
  animation: fadeInUp 0.4s ease;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 200px;
  overflow: hidden;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.history-title {
  font-size: 14px;
  color: #666;
}

.clear-history-btn {
  font-size: 12px;
  color: #999;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 15px;
  background: #f5f5f5;
}

.clear-history-btn:hover {
  background: #e8e8e8;
  color: #666;
}

.history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex: 1;
  overflow-y: auto;
  align-content: flex-start;
}

.history-list::-webkit-scrollbar {
  width: 6px;
}

.history-list::-webkit-scrollbar-thumb {
  background: #d0d0d0;
  border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
  background: #b0b0b0;
}

.history-list::-webkit-scrollbar-track {
  background: transparent;
}

.empty-history {
  font-size: 14px;
  color: #999;
  padding: 20px;
  text-align: center;
  width: 100%;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #F0F0F0;
  border-radius: 12px;
  font-size: 14px;
  color: #444;
  cursor: pointer;
  transition: background 0.2s ease;
}

.history-item:hover {
  background: #E8F5E9;
  transform: translateX(5px);
}

.history-item .unit-tag {
  font-size: 11px;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
}

.history-item .unit-tag.inch {
  background: #EA4335;
}

.history-item .unit-tag.cm {
  background: #34A853;
}

.history-item .unit-tag.mm {
  background: #FBBC05;
}

.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 12px 24px;
  border-radius: 20px;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.toast.show {
  opacity: 1;
}

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal-overlay.show {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 16px;
  max-width: 800px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #eee;
}

.modal-header h2 {
  font-size: 20px;
  color: #333;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s ease;
}

.modal-close:hover {
  background: #f0f0f0;
  color: #666;
}

.modal-body {
  padding: 24px;
}

.rule-intro,
.rule-table-section,
.rule-example {
  margin-bottom: 28px;
}

.rule-intro h3,
.rule-table-section h3,
.rule-example h3 {
  font-size: 16px;
  color: #333;
  margin: 0 0 12px 0;
}

.rule-intro p {
  font-size: 14px;
  color: #666;
  line-height: 1.6;
  margin: 0;
}

.rule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.rule-table th,
.rule-table td {
  padding: 12px 16px;
  text-align: left;
  border: 1px solid #e0e0e0;
}

.rule-table th {
  background: #f5f5f5;
  color: #333;
  font-weight: 600;
}

.rule-table td {
  color: #666;
}

.example-item {
  background: #FFF8E7;
  border-left: 4px solid #e67e22;
  border-radius: 8px;
  padding: 16px;
}

.example-title {
  font-size: 15px;
  font-weight: 600;
  color: #333;
  margin: 0 0 12px 0;
}

.example-explanation {
  font-size: 14px;
  color: #666;
  line-height: 2;
}

.example-explanation strong {
  color: #333;
}

.example-explanation .note {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #ddd;
  color: #e67e22;
}
