* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: #333;
}

.app {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 홈 화면 */
.home-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 40px);
  padding: 20px 0;
}

.home-hero {
  text-align: center;
  margin-bottom: 40px;
}

.home-hero h1 {
  font-size: 32px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.subtitle {
  color: rgba(255,255,255,0.85);
  font-size: 16px;
}

.home-actions {
  width: 100%;
  max-width: 400px;
}

.btn-create {
  width: 100%;
  padding: 20px;
  background: #fff;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-create:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(0,0,0,0.2);
}

.btn-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 12px;
  color: #fff;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-text {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.divider {
  display: flex;
  align-items: center;
  margin: 24px 0;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.3);
}

.divider span {
  padding: 0 16px;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
}

.upload-area {
  width: 100%;
}

.drop-zone {
  background: rgba(255,255,255,0.95);
  border: 2px dashed rgba(102,126,234,0.5);
  border-radius: 16px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.drop-zone:hover {
  border-color: #667eea;
  background: #fff;
}

.drop-zone.dragover {
  border-color: #667eea;
  background: #fff;
  transform: scale(1.02);
}

.drop-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.drop-text {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
}

.drop-hint {
  font-size: 13px;
  color: #888;
}

/* 수정 화면 */
.edit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 12px 0;
}

.save-buttons {
  display: flex;
  gap: 8px;
}

.btn-back {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-back:hover {
  background: rgba(255,255,255,0.3);
}

.btn-save,
.btn-save-share {
  background: #fff;
  border: none;
  color: #667eea;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  transition: transform 0.2s;
}

.btn-save:hover,
.btn-save-share:hover {
  transform: scale(1.05);
}

@media (max-width: 600px) {
  .save-buttons {
    flex-direction: column;
    gap: 4px;
  }
  
  .btn-save,
  .btn-save-share {
    font-size: 13px;
    padding: 8px 16px;
  }
}

.edit-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 2px 15px rgba(0,0,0,0.08);
}

.card-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #888;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.name-input {
  width: 100%;
  border: none;
  border-bottom: 2px solid #eee;
  padding: 12px 0;
  font-size: 20px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s;
}

.name-input:focus {
  border-color: #667eea;
}

.name-input::placeholder {
  color: #ccc;
}

.card-header {
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.pattern-input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.pattern-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #eee;
  border-radius: 10px;
  font-size: 15px;
  font-family: "Consolas", monospace;
  outline: none;
  transition: border-color 0.2s;
}

.pattern-input:focus {
  border-color: #667eea;
}

.btn-add {
  padding: 12px 20px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-add:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(102,126,234,0.4);
}

.pattern-help {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  padding: 10px 12px;
  background: #f8f9fa;
  border-radius: 8px;
}

.help-item {
  font-size: 12px;
  color: #666;
  font-family: "Consolas", monospace;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #eee;
  margin-bottom: 8px;
}

.select-all-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #666;
  cursor: pointer;
}

.select-all-label input {
  width: 18px;
  height: 18px;
  accent-color: #667eea;
}

.btn-delete {
  background: none;
  border: none;
  color: #e74c3c;
  font-size: 14px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background 0.2s;
}

.btn-delete:hover {
  background: #fef0f0;
}

.list-empty {
  text-align: center;
  padding: 40px 20px;
  color: #aaa;
}

.list-empty p {
  font-size: 14px;
}

/* 생성 패널 */
.generate-panel {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.form {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 8px;
  margin-bottom: 12px;
}

.form input {
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
}

.preview {
  font-size: 13px;
  color: #555;
  min-height: 20px;
}

/* 연락처 목록 */
.contacts-list {
  list-style: none;
  max-height: 350px;
  overflow-y: auto;
}

.contacts-list:empty + .list-empty {
  display: block;
}

.contacts-list:not(:empty) + .list-empty {
  display: none;
}

.contacts-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin: 4px 0;
  background: #f8f9fa;
  border-radius: 10px;
  transition: background 0.2s;
}

.contacts-list li:hover {
  background: #f0f1f3;
}

.contacts-list input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #667eea;
}

.pattern-label {
  font-family: "Consolas", monospace;
  font-size: 15px;
  flex: 1;
  color: #333;
}

.pattern-count {
  font-size: 12px;
  color: #fff;
  background: linear-gradient(135deg, #667eea, #764ba2);
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
}

/* 다이얼로그 */
.dialog {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  display: none;
  align-items: center;
  justify-content: center;
}

.dialog:not([hidden]) {
  display: flex;
}

.dialog-content {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 24px;
  width: 90%;
  max-width: 400px;
}

.dialog-content h3 {
  margin-bottom: 12px;
}

.dialog-content input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  margin-bottom: 16px;
  font-size: 14px;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

@media (max-width: 600px) {
  .form {
    grid-template-columns: 1fr;
  }
  
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .contacts-list li {
    grid-template-columns: 30px 1fr;
  }
}
