/**
 * DDE マイフレーズ帳
 * クラス名を dde- で統一し、SWELLや他プラグインとの衝突を避ける。
 */

.dde-phrase,
.dde-phrase-list {
  --dde-accent: #2e7d32;
  --dde-accent-soft: #edf7ee;
  --dde-border: #dddddd;
  --dde-text-muted: #626262;
  box-sizing: border-box;
}

.dde-phrase *,
.dde-phrase-list * {
  box-sizing: border-box;
}

/* 保存カード */
.dde-phrase {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "body actions"
    "related related"
    "status status";
  align-items: center;
  gap: 0.65em 1em;
  margin: 1.25em 0;
  padding: 0.9em 1em;
  border: 1px solid var(--dde-border);
  border-left: 4px solid var(--dde-accent);
  border-radius: 8px;
  background: #fafafa;
}

.dde-phrase__body {
  grid-area: body;
  display: flex;
  flex-direction: column;
  gap: 0.15em;
  min-width: 0;
}

.dde-phrase__text {
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.dde-phrase__meaning {
  color: var(--dde-text-muted);
  font-size: 0.86em;
}

.dde-phrase__actions {
  grid-area: actions;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45em;
}

.dde-phrase__btn,
.dde-phrase-list__clear,
.dde-phrase-list__delete {
  font: inherit;
  cursor: pointer;
}

.dde-phrase__btn {
  padding: 0.5em 1em;
  border: 1px solid var(--dde-accent);
  border-radius: 999px;
  background: #ffffff;
  color: var(--dde-accent);
  font-size: 0.86em;
  line-height: 1;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s;
}

.dde-phrase__btn:hover,
.dde-phrase__btn:focus-visible,
.dde-phrase__btn.is-saved {
  background: var(--dde-accent);
  color: #ffffff;
}

.dde-phrase-help {
  color: #777777;
  font-size: 0.72em;
  line-height: 1.3;
  text-decoration: underline;
}

.dde-phrase-help:hover,
.dde-phrase-help:focus-visible {
  color: #444444;
}

.dde-phrase__related {
  grid-area: related;
}

.dde-phrase__status {
  grid-area: status;
  min-height: 1em;
  margin: 0;
  color: var(--dde-accent);
  font-size: 0.78em;
  line-height: 1.35;
}

.dde-phrase__status:empty {
  display: none;
}

/* 関連記事 */
.dde-related {
  margin-top: 0.75em;
  padding: 0.85em 0.95em;
  border-radius: 7px;
  background: var(--dde-accent-soft);
}

.dde-related--compact {
  margin-top: 0.2em;
}

.dde-related__heading {
  margin: 0 0 0.35em;
  color: #3f5941;
  font-size: 0.78em;
  font-weight: 700;
}

.dde-related__heading:not(:first-child) {
  margin-top: 0.75em;
}

.dde-related__links {
  display: grid;
  gap: 0.35em;
}

.dde-related__link {
  display: flex;
  align-items: baseline;
  gap: 0.45em;
  color: #245f2a;
  font-size: 0.84em;
  line-height: 1.45;
  text-decoration: underline;
  overflow-wrap: anywhere;
}

.dde-related__link--summary {
  font-weight: 700;
}

.dde-related__series {
  flex: 0 0 auto;
  padding: 0.05em 0.4em;
  border-radius: 4px;
  background: #ffffff;
  color: #506252;
  font-size: 0.78em;
  text-decoration: none;
}

/* マイフレーズ帳一覧 */
.dde-phrase-list__help {
  margin: 1em 0 0;
  text-align: center;
}

.dde-phrase-list__empty {
  padding: 1em;
  border: 1px dashed var(--dde-border);
  border-radius: 7px;
  color: var(--dde-text-muted);
  font-size: 0.9em;
}

.dde-phrase-list__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  margin-bottom: 0.8em;
}

.dde-phrase-list__count {
  color: #555555;
  font-size: 0.9em;
}

.dde-phrase-list__clear {
  padding: 0.4em 0.9em;
  border: 1px solid #b52323;
  border-radius: 999px;
  background: #ffffff;
  color: #a51f1f;
  font-size: 0.78em;
}

.dde-phrase-list__clear:hover,
.dde-phrase-list__clear:focus-visible {
  background: #b52323;
  color: #ffffff;
}

.dde-phrase-list__items {
  display: grid;
  gap: 0.9em;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dde-phrase-list__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "main delete"
    "related related";
  align-items: start;
  gap: 0.8em 1em;
  padding: 1em;
  border: 1px solid var(--dde-border);
  border-radius: 8px;
  background: #ffffff;
}

.dde-phrase-list__main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.dde-phrase-list__phrase {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.dde-phrase-list__meaning {
  margin-top: 0.1em;
  color: var(--dde-text-muted);
  font-size: 0.86em;
}

.dde-phrase-list__source {
  margin-top: 0.35em;
  color: var(--dde-accent);
  font-size: 0.78em;
  text-decoration: underline;
  overflow-wrap: anywhere;
}

.dde-phrase-list__delete {
  grid-area: delete;
  padding: 0.4em 0.85em;
  border: 1px solid #999999;
  border-radius: 999px;
  background: #ffffff;
  color: #555555;
  font-size: 0.78em;
}

.dde-phrase-list__delete:hover,
.dde-phrase-list__delete:focus-visible {
  border-color: #b52323;
  color: #a51f1f;
}

.dde-phrase-list__item > .dde-related {
  grid-area: related;
  margin-top: 0;
}

@media (max-width: 600px) {
  .dde-phrase {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "body"
      "actions"
      "related"
      "status";
  }

  .dde-phrase__actions {
    align-items: flex-start;
  }

  .dde-phrase-list__item {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 0.85em;
  }

  .dde-related__link {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.15em;
  }
}
